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

Unified Diff: content/browser/devtools/devtools_session.cc

Issue 2708563002: DevTools: allow embedder handling async remote debugger commands. (Closed)
Patch Set: extract variable Created 3 years, 10 months 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
« no previous file with comments | « content/browser/devtools/devtools_session.h ('k') | content/browser/devtools/protocol/page_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/devtools/devtools_session.cc
diff --git a/content/browser/devtools/devtools_session.cc b/content/browser/devtools/devtools_session.cc
index 8783f1723c2ff77a19c1524491e513fe2315a34f..ffe9eb476cd8d8eba3a37cba4c59d06b421f39b2 100644
--- a/content/browser/devtools/devtools_session.cc
+++ b/content/browser/devtools/devtools_session.cc
@@ -13,16 +13,15 @@
namespace content {
-DevToolsSession::DevToolsSession(
- DevToolsAgentHostImpl* agent_host,
- DevToolsAgentHostClient* client,
- int session_id)
+DevToolsSession::DevToolsSession(DevToolsAgentHostImpl* agent_host,
+ DevToolsAgentHostClient* client,
+ int session_id)
: agent_host_(agent_host),
client_(client),
session_id_(session_id),
host_(nullptr),
- dispatcher_(new protocol::UberDispatcher(this)) {
-}
+ dispatcher_(new protocol::UberDispatcher(this)),
+ weak_factory_(this) {}
DevToolsSession::~DevToolsSession() {
dispatcher_.reset();
@@ -48,6 +47,13 @@ void DevToolsSession::SetFallThroughForNotFound(bool value) {
dispatcher_->setFallThroughForNotFound(value);
}
+void DevToolsSession::sendResponse(
+ std::unique_ptr<base::DictionaryValue> response) {
+ std::string json;
+ base::JSONWriter::Write(*response.get(), &json);
+ agent_host_->SendMessageToClient(session_id_, json);
+}
+
protocol::Response::Status DevToolsSession::Dispatch(
const std::string& message,
int* call_id,
@@ -57,15 +63,19 @@ protocol::Response::Status DevToolsSession::Dispatch(
DevToolsManagerDelegate* delegate =
DevToolsManager::GetInstance()->delegate();
if (value && value->IsType(base::Value::Type::DICTIONARY) && delegate) {
- std::unique_ptr<base::DictionaryValue> response(delegate->HandleCommand(
- agent_host_,
- static_cast<base::DictionaryValue*>(value.get())));
+ base::DictionaryValue* dict_value =
+ static_cast<base::DictionaryValue*>(value.get());
+ std::unique_ptr<base::DictionaryValue> response(
+ delegate->HandleCommand(agent_host_, dict_value));
if (response) {
- std::string json;
- base::JSONWriter::Write(*response.get(), &json);
- agent_host_->SendMessageToClient(session_id_, json);
+ sendResponse(std::move(response));
return protocol::Response::kSuccess;
}
+ if (delegate->HandleAsyncCommand(agent_host_, dict_value,
+ base::Bind(&DevToolsSession::sendResponse,
+ weak_factory_.GetWeakPtr()))) {
+ return protocol::Response::kAsync;
+ }
}
return dispatcher_->dispatch(protocol::toProtocolValue(value.get(), 1000),
« no previous file with comments | « content/browser/devtools/devtools_session.h ('k') | content/browser/devtools/protocol/page_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698