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

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

Issue 2590293003: [DevTools] Rework DevToolsSession interaction with domain handlers. (Closed)
Patch Set: includes Created 4 years 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/forwarding_agent_host.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 60ccb85ebebdd22377769751c2bcd04697f7bb2a..c11aa30fd1111da98c308d01f9ea47ff2aab45b6 100644
--- a/content/browser/devtools/devtools_session.cc
+++ b/content/browser/devtools/devtools_session.cc
@@ -15,26 +15,48 @@ namespace content {
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)) {
}
-DevToolsSession::~DevToolsSession() {}
-
-void DevToolsSession::ResetDispatcher() {
+DevToolsSession::~DevToolsSession() {
dispatcher_.reset();
+ for (auto& pair : handlers_)
+ pair.second->Disable();
+ handlers_.clear();
+}
+
+void DevToolsSession::AddHandler(
+ std::unique_ptr<protocol::DevToolsDomainHandler> handler) {
+ handler->Wire(dispatcher_.get());
+ handler->SetRenderFrameHost(host_);
+ handlers_[handler->name()] = std::move(handler);
+}
+
+void DevToolsSession::SetRenderFrameHost(RenderFrameHostImpl* host) {
+ host_ = host;
+ for (auto& pair : handlers_)
+ pair.second->SetRenderFrameHost(host_);
+}
+
+void DevToolsSession::SetFallThroughForNotFound(bool value) {
+ dispatcher_->setFallThroughForNotFound(value);
}
protocol::Response::Status DevToolsSession::Dispatch(
const std::string& message,
+ bool offer_to_delegate,
int* call_id,
std::string* method) {
std::unique_ptr<base::Value> value = base::JSONReader::Read(message);
- DevToolsManagerDelegate* delegate =
- DevToolsManager::GetInstance()->delegate();
+ DevToolsManagerDelegate* delegate = offer_to_delegate ?
+ DevToolsManager::GetInstance()->delegate() : nullptr;
if (value && value->IsType(base::Value::Type::DICTIONARY) && delegate) {
std::unique_ptr<base::DictionaryValue> response(delegate->HandleCommand(
agent_host_,
@@ -65,4 +87,12 @@ void DevToolsSession::sendProtocolNotification(
void DevToolsSession::flushProtocolNotifications() {
}
+protocol::DevToolsDomainHandler* DevToolsSession::GetHandlerByName(
+ const std::string& name) {
+ auto it = handlers_.find(name);
+ if (it == handlers_.end())
+ return nullptr;
+ return it->second.get();
+}
+
} // namespace content
« no previous file with comments | « content/browser/devtools/devtools_session.h ('k') | content/browser/devtools/forwarding_agent_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698