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

Side by Side Diff: content/browser/devtools/devtools_agent_host_impl.cc

Issue 2047833002: DevTools: introduce browser domain for basic target discovery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/devtools/devtools_agent_host_impl.h" 5 #include "content/browser/devtools/devtools_agent_host_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/guid.h" 10 #include "base/guid.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 return NULL; 95 return NULL;
96 return it->second; 96 return it->second;
97 } 97 }
98 98
99 // static 99 // static
100 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::Create( 100 scoped_refptr<DevToolsAgentHost> DevToolsAgentHost::Create(
101 DevToolsExternalAgentProxyDelegate* delegate) { 101 DevToolsExternalAgentProxyDelegate* delegate) {
102 return new ForwardingAgentHost(delegate); 102 return new ForwardingAgentHost(delegate);
103 } 103 }
104 104
105 void DevToolsAgentHostImpl::AttachClient(DevToolsAgentHostClient* client) { 105 bool DevToolsAgentHostImpl::InnerAttach(DevToolsAgentHostClient* client,
106 bool force) {
107 if (client_ && !force)
108 return false;
109
106 scoped_refptr<DevToolsAgentHostImpl> protect(this); 110 scoped_refptr<DevToolsAgentHostImpl> protect(this);
107 ++session_id_; 111 ++session_id_;
108 if (client_) { 112 if (client_) {
109 client_->AgentHostClosed(this, true); 113 client_->AgentHostClosed(this, true);
110 InnerDetach(); 114 InnerDetach();
111 } 115 }
112 client_ = client; 116 client_ = client;
113 Attach(); 117 Attach();
118 return true;
114 } 119 }
115 120
116 void DevToolsAgentHostImpl::DetachClient() { 121 bool DevToolsAgentHostImpl::AttachClient(DevToolsAgentHostClient* client) {
117 if (!client_) 122 return InnerAttach(client, false);
118 return; 123 }
124
125 void DevToolsAgentHostImpl::ForceAttachClient(DevToolsAgentHostClient* client) {
126 InnerAttach(client, true);
127 }
128
129 bool DevToolsAgentHostImpl::DetachClient(DevToolsAgentHostClient* client) {
130 if (!client_ || client_ != client)
131 return false;
119 132
120 scoped_refptr<DevToolsAgentHostImpl> protect(this); 133 scoped_refptr<DevToolsAgentHostImpl> protect(this);
121 client_ = NULL; 134 client_ = NULL;
122 InnerDetach(); 135 InnerDetach();
136 return true;
137 }
138
139 bool DevToolsAgentHostImpl::DispatchProtocolMessage(
140 DevToolsAgentHostClient* client,
141 const std::string& message) {
142 if (!client_ || client_ != client)
143 return false;
144 return DispatchProtocolMessage(message);
123 } 145 }
124 146
125 void DevToolsAgentHostImpl::InnerDetach() { 147 void DevToolsAgentHostImpl::InnerDetach() {
126 Detach(); 148 Detach();
127 io_context_.DiscardAllStreams(); 149 io_context_.DiscardAllStreams();
128 } 150 }
129 151
130 bool DevToolsAgentHostImpl::IsAttached() { 152 bool DevToolsAgentHostImpl::IsAttached() {
131 return !!client_; 153 return !!client_;
132 } 154 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 303
282 if (chunk.is_last) { 304 if (chunk.is_last) {
283 CHECK(message_buffer_.size() == message_buffer_size_); 305 CHECK(message_buffer_.size() == message_buffer_size_);
284 callback_.Run(chunk.session_id, message_buffer_); 306 callback_.Run(chunk.session_id, message_buffer_);
285 message_buffer_ = std::string(); 307 message_buffer_ = std::string();
286 message_buffer_size_ = 0; 308 message_buffer_size_ = 0;
287 } 309 }
288 } 310 }
289 311
290 } // namespace content 312 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_agent_host_impl.h ('k') | content/browser/devtools/devtools_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698