|
@@ -60,11 +60,13 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host,
|
|
|
std::string method;
|
|
|
if (!dict->GetString("method", &method))
|
|
|
return;
|
|
|
+ std::string session_id;
|
|
|
+ dict->GetString("sessionId", &session_id);
|
|
|
base::DictionaryValue* params_value = nullptr;
|
|
|
base::DictionaryValue params;
|
|
|
if (dict->GetDictionary("params", ¶ms_value))
|
|
|
params.Swap(params_value);
|
|
|
- Emit("message", method, params);
|
|
|
+ Emit("message", method, params, session_id);
|
|
|
} else {
|
|
|
auto it = pending_requests_.find(id);
|
|
|
if (it == pending_requests_.end())
|
|
@@ -152,14 +154,25 @@ v8::Local<v8::Promise> Debugger::SendCommand(gin::Arguments* args) {
|
|
|
base::DictionaryValue command_params;
|
|
|
args->GetNext(&command_params);
|
|
|
|
|
|
+ std::string session_id;
|
|
|
+ if (args->GetNext(&session_id) && session_id.empty()) {
|
|
|
+ promise.RejectWithErrorMessage("Empty session id is not allowed");
|
|
|
+ return handle;
|
|
|
+ }
|
|
|
+
|
|
|
base::DictionaryValue request;
|
|
|
int request_id = ++previous_request_id_;
|
|
|
pending_requests_.emplace(request_id, std::move(promise));
|
|
|
request.SetInteger("id", request_id);
|
|
|
request.SetString("method", method);
|
|
|
- if (!command_params.empty())
|
|
|
+ if (!command_params.empty()) {
|
|
|
request.Set("params",
|
|
|
base::Value::ToUniquePtrValue(command_params.Clone()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!session_id.empty()) {
|
|
|
+ request.SetString("sessionId", session_id);
|
|
|
+ }
|
|
|
|
|
|
std::string json_args;
|
|
|
base::JSONWriter::Write(request, &json_args);
|