Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(777)

Unified Diff: content/browser/devtools/protocol/devtools_protocol_handler_generator.py

Issue 1408363004: [DevTools] Filter any messages from previous sessions in DevToolsAgentHostImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/devtools/protocol/devtools_protocol_handler_generator.py
diff --git a/content/browser/devtools/protocol/devtools_protocol_handler_generator.py b/content/browser/devtools/protocol/devtools_protocol_handler_generator.py
index 6bce71e604749801f63191a919c7c24633d9630f..3b003953fcbbb1358db9519c9538735065d2da1a 100755
--- a/content/browser/devtools/protocol/devtools_protocol_handler_generator.py
+++ b/content/browser/devtools/protocol/devtools_protocol_handler_generator.py
@@ -76,7 +76,7 @@ class DevToolsProtocolDispatcher {
public:
using Notifier = DevToolsProtocolClient::RawMessageCallback;
using CommandHandler =
- base::Callback<bool(int, scoped_ptr<base::DictionaryValue>)>;
+ base::Callback<bool(int, int, scoped_ptr<base::DictionaryValue>)>;
explicit DevToolsProtocolDispatcher(const Notifier& notifier);
~DevToolsProtocolDispatcher();
@@ -223,6 +223,7 @@ tmpl_event = string.Template("""\
tmpl_response = string.Template("""\
void Send${Command}Response(
+ int session_id,
DevToolsCommandId command_id,
scoped_refptr<${Command}Response> params);
""")
@@ -234,6 +235,7 @@ tmpl_setter = string.Template("""\
tmpl_callback = string.Template("""\
bool On${Domain}${Command}(
+ int session_id,
DevToolsCommandId command_id,
scoped_ptr<base::DictionaryValue> params);
""")
@@ -323,18 +325,18 @@ tmpl_init_client = string.Template("""\
tmpl_callback_impl = string.Template("""\
bool DevToolsProtocolDispatcher::On${Domain}${Command}(
- DevToolsCommandId command_id,
+ int session_id, DevToolsCommandId command_id,
scoped_ptr<base::DictionaryValue> params) {
${prep}\
Response response = ${domain}_handler_->${Command}(${args});
scoped_ptr<base::DictionaryValue> protocol_response;
- if (client_.SendError(command_id, response))
+ if (client_.SendError(session_id, command_id, response))
return true;
if (response.IsFallThrough())
return false;
scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue());
${wrap}\
- client_.SendSuccess(command_id, result.Pass());
+ client_.SendSuccess(session_id, command_id, result.Pass());
return true;
}
""")
@@ -345,11 +347,12 @@ tmpl_wrap = string.Template("""\
tmpl_callback_async_impl = string.Template("""\
bool DevToolsProtocolDispatcher::On${Domain}${Command}(
+ int session_id,
DevToolsCommandId command_id,
scoped_ptr<base::DictionaryValue> params) {
${prep}\
Response response = ${domain}_handler_->${Command}(${args});
- if (client_.SendError(command_id, response))
+ if (client_.SendError(session_id, command_id, response))
return true;
return !response.IsFallThrough();
}
@@ -358,7 +361,7 @@ ${prep}\
tmpl_prep_req = string.Template("""\
${raw_type} in_${param}${init};
if (!params || !params->Get${Type}("${proto_param}", &in_${param})) {
- client_.SendError(command_id, Response::InvalidParams("${proto_param}"));
+ client_.SendError(session_id, command_id, Response::InvalidParams("${proto_param}"));
return true;
}
""")
@@ -366,7 +369,7 @@ tmpl_prep_req = string.Template("""\
tmpl_prep_req_list = string.Template("""\
base::ListValue* list_${param} = nullptr;
if (!params || !params->GetList("${proto_param}", &list_${param})) {
- client_.SendError(command_id, Response::InvalidParams("${proto_param}"));
+ client_.SendError(session_id, command_id, Response::InvalidParams("${proto_param}"));
return true;
}
std::vector<${item_type}> in_${param};
@@ -374,7 +377,7 @@ tmpl_prep_req_list = string.Template("""\
list_${param}->begin(); it != list_${param}->end(); ++it) {
${item_raw_type} item;
if (!(*it)->GetAs${ItemType}(&item)) {
- client_.SendError(command_id, Response::InvalidParams("${proto_param}"));
+ client_.SendError(session_id, command_id, Response::InvalidParams("${proto_param}"));
return true;
}
in_${param}.push_back(${item_pass});
@@ -427,9 +430,10 @@ void Client::${Command}(
tmpl_response_impl = string.Template("""\
void Client::Send${Command}Response(
+ int session_id,
DevToolsCommandId command_id,
scoped_refptr<${Command}Response> params) {
- SendSuccess(command_id, params->ToValue().Pass());
+ SendSuccess(session_id, command_id, params->ToValue().Pass());
}
""")
@@ -708,7 +712,8 @@ for json_domain in all_domains:
# TODO(vkuzkokov) Pass async callback instance similar to how
# InspectorBackendDispatcher does it. This, however, can work
# only if Blink and Chrome are in the same repo.
- args.insert(0, "command_id")
+ args.insert(0, "session_id")
+ args.insert(1, "command_id")
handler_method_impls.append(
tmpl_callback_async_impl.substitute(command_map,
prep = "".join(prep),

Powered by Google App Engine
This is Rietveld 408576698