Commit 3ec87e29 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[filesapp] Use |value| in DevToolsListener::DispatchProtocolMessage

The DevtoolsListener sends CDP commands to devtools to control it, and
uses host->DispatchProtocolMessage to do that via a SendCommandMessage
helper see CL:2473621.

The signature of DevToolsListener::DispatchProtocolMessage causes some
confusion when compared to host->DispatchProtocolMessage: has the same
name, is defined by the base class content::DevToolsAgentHostClient so
we can't change it, but the TL:DR; is it handles the reverse direction
of the devtools interaction - where the devtools host wants to tell us
about something (eg., Debugger.scriptParsed) or provide the "response"
to a DevtoolsListener CDP command.

Call whatever devtools emits a |value|, rather than a response. Values
in DevToolsListener::DispatchProtocolMessage are 1) a "message", which
always have a "method" in their value or else 2) a command "response",
which have an "id" in their value. The "id" is uniquely defined by the
associated DevtoolsListener CDP command.

Name change only response => value, no change in behavior. And this to
add some git blame details about DispatchProtocolMessage.

Tbr: benreich
Bug: 1113941
Change-Id: I4835eddf1bb3435ad82cdbdf786d9450b08e29ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2474214Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817406}
parent bde5ba55
...@@ -247,22 +247,22 @@ void DevToolsListener::DispatchProtocolMessage( ...@@ -247,22 +247,22 @@ void DevToolsListener::DispatchProtocolMessage(
if (!navigated_) if (!navigated_)
return; return;
std::unique_ptr<base::DictionaryValue> response = base::DictionaryValue::From( std::unique_ptr<base::DictionaryValue> value = base::DictionaryValue::From(
base::JSONReader::ReadDeprecated(SpanToStringPiece(message))); base::JSONReader::ReadDeprecated(SpanToStringPiece(message)));
CHECK(response); CHECK(value);
std::string* method = response->FindStringPath("method"); std::string* method = value->FindStringPath("method");
if (method) { if (method) {
if (*method == "Runtime.executionContextsCreated") if (*method == "Runtime.executionContextsCreated")
script_.clear(); script_.clear();
else if (*method == "Debugger.scriptParsed") else if (*method == "Debugger.scriptParsed")
script_.push_back(std::move(response)); script_.push_back(std::move(value));
return; return;
} }
base::Optional<int> id = response->FindIntPath("id"); base::Optional<int> id = value->FindIntPath("id");
if (id.has_value() && id.value() == value_id_) { if (id.has_value() && id.value() == value_id_) {
value_.reset(response.release()); value_.reset(value.release());
CHECK(value_closure_); CHECK(value_closure_);
std::move(value_closure_).Run(); std::move(value_closure_).Run();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment