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

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

Issue 2863623003: [DevTools] Support multiple sessions in content/ domain handlers (Closed)
Patch Set: addressed review comments Created 3 years, 7 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_agent_host_impl.h ('k') | content/browser/devtools/devtools_io_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/devtools/devtools_agent_host_impl.cc
diff --git a/content/browser/devtools/devtools_agent_host_impl.cc b/content/browser/devtools/devtools_agent_host_impl.cc
index 92e9aa079110f3b036bd5f802a90dd2ce6f04956..e91af24df845b4aea8a500af1f107eb7bda96cb5 100644
--- a/content/browser/devtools/devtools_agent_host_impl.cc
+++ b/content/browser/devtools/devtools_agent_host_impl.cc
@@ -118,8 +118,7 @@ scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::GetForWorker(
}
DevToolsAgentHostImpl::DevToolsAgentHostImpl(const std::string& id)
- : id_(id),
- last_session_id_(0) {
+ : id_(id), last_session_id_(0), session_(nullptr) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
@@ -157,8 +156,10 @@ bool DevToolsAgentHostImpl::InnerAttachClient(DevToolsAgentHostClient* client,
scoped_refptr<DevToolsAgentHostImpl> protect(this);
if (session_)
ForceDetach(true);
- session_.reset(new DevToolsSession(this, client, ++last_session_id_));
- AttachSession(session_.get());
+ DCHECK(!session_);
+ session_ = new DevToolsSession(this, client, ++last_session_id_);
+ sessions_.insert(std::unique_ptr<DevToolsSession>(session_));
+ AttachSession(session_);
NotifyAttached();
return true;
}
@@ -185,12 +186,13 @@ bool DevToolsAgentHostImpl::DispatchProtocolMessage(
const std::string& message) {
if (!session_ || session_->client() != client)
return false;
- return DispatchProtocolMessage(session_.get(), message);
+ return DispatchProtocolMessage(session_, message);
}
void DevToolsAgentHostImpl::InnerDetachClient() {
int session_id = session_->session_id();
- session_.reset();
+ session_ = nullptr;
+ sessions_.clear();
DetachSession(session_id);
io_context_.DiscardAllStreams();
NotifyDetached();
@@ -206,7 +208,7 @@ void DevToolsAgentHostImpl::InspectElement(
int y) {
if (!session_ || session_->client() != client)
return;
- InspectElement(session_.get(), x, y);
+ InspectElement(session_, x, y);
}
std::string DevToolsAgentHostImpl::GetId() {
« no previous file with comments | « content/browser/devtools/devtools_agent_host_impl.h ('k') | content/browser/devtools/devtools_io_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698