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

Side by Side Diff: content/renderer/devtools/devtools_agent.cc

Issue 341513002: DevTools: pass agent host id to the renderer (content). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Same w/ reattach. Created 6 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 | Annotate | Revision Log
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/renderer/devtools/devtools_agent.h" 5 #include "content/renderer/devtools/devtools_agent.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 void DevToolsAgent::sendMessageToInspectorFrontend( 118 void DevToolsAgent::sendMessageToInspectorFrontend(
119 const blink::WebString& message) { 119 const blink::WebString& message) {
120 Send(new DevToolsClientMsg_DispatchOnInspectorFrontend(routing_id(), 120 Send(new DevToolsClientMsg_DispatchOnInspectorFrontend(routing_id(),
121 message.utf8())); 121 message.utf8()));
122 } 122 }
123 123
124 int DevToolsAgent::hostIdentifier() { 124 int DevToolsAgent::hostIdentifier() {
125 return routing_id(); 125 return routing_id();
126 } 126 }
127 127
128 int DevToolsAgent::debuggerId() {
129 return routing_id();
130 }
131
128 void DevToolsAgent::saveAgentRuntimeState( 132 void DevToolsAgent::saveAgentRuntimeState(
129 const blink::WebString& state) { 133 const blink::WebString& state) {
130 Send(new DevToolsHostMsg_SaveAgentRuntimeState(routing_id(), state.utf8())); 134 Send(new DevToolsHostMsg_SaveAgentRuntimeState(routing_id(), state.utf8()));
131 } 135 }
132 136
133 blink::WebDevToolsAgentClient::WebKitClientMessageLoop* 137 blink::WebDevToolsAgentClient::WebKitClientMessageLoop*
134 DevToolsAgent::createClientMessageLoop() { 138 DevToolsAgent::createClientMessageLoop() {
135 return new WebKitClientMessageLoopImpl(); 139 return new WebKitClientMessageLoopImpl();
136 } 140 }
137 141
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 270 }
267 #endif 271 #endif
268 272
269 void DevToolsAgent::visitAllocatedObjects(AllocatedObjectVisitor* visitor) { 273 void DevToolsAgent::visitAllocatedObjects(AllocatedObjectVisitor* visitor) {
270 #if defined(USE_TCMALLOC) && !defined(OS_WIN) 274 #if defined(USE_TCMALLOC) && !defined(OS_WIN)
271 IterateAllocatedObjects(&AllocationVisitor, visitor); 275 IterateAllocatedObjects(&AllocationVisitor, visitor);
272 #endif 276 #endif
273 } 277 }
274 278
275 // static 279 // static
276 DevToolsAgent* DevToolsAgent::FromHostId(int host_id) { 280 DevToolsAgent* DevToolsAgent::FromRoutingId(int routing_id) {
277 IdToAgentMap::iterator it = g_agent_for_routing_id.Get().find(host_id); 281 IdToAgentMap::iterator it = g_agent_for_routing_id.Get().find(routing_id);
278 if (it != g_agent_for_routing_id.Get().end()) { 282 if (it != g_agent_for_routing_id.Get().end()) {
279 return it->second; 283 return it->second;
280 } 284 }
281 return NULL; 285 return NULL;
282 } 286 }
283 287
284 void DevToolsAgent::OnAttach() { 288 void DevToolsAgent::OnAttach(const std::string& host_id) {
285 WebDevToolsAgent* web_agent = GetWebAgent(); 289 WebDevToolsAgent* web_agent = GetWebAgent();
286 if (web_agent) { 290 if (web_agent) {
287 web_agent->attach(); 291 web_agent->attach(WebString::fromUTF8(host_id));
288 is_attached_ = true; 292 is_attached_ = true;
289 } 293 }
290 } 294 }
291 295
292 void DevToolsAgent::OnReattach(const std::string& agent_state) { 296 void DevToolsAgent::OnReattach(const std::string& host_id,
297 const std::string& agent_state) {
293 WebDevToolsAgent* web_agent = GetWebAgent(); 298 WebDevToolsAgent* web_agent = GetWebAgent();
294 if (web_agent) { 299 if (web_agent) {
295 web_agent->reattach(WebString::fromUTF8(agent_state)); 300 web_agent->reattach(WebString::fromUTF8(host_id),
301 WebString::fromUTF8(agent_state));
296 is_attached_ = true; 302 is_attached_ = true;
297 } 303 }
298 } 304 }
299 305
300 void DevToolsAgent::OnDetach() { 306 void DevToolsAgent::OnDetach() {
301 WebDevToolsAgent* web_agent = GetWebAgent(); 307 WebDevToolsAgent* web_agent = GetWebAgent();
302 if (web_agent) { 308 if (web_agent) {
303 web_agent->detach(); 309 web_agent->detach();
304 is_attached_ = false; 310 is_attached_ = false;
305 } 311 }
306 } 312 }
307 313
308 void DevToolsAgent::OnDispatchOnInspectorBackend(const std::string& message) { 314 void DevToolsAgent::OnDispatchOnInspectorBackend(const std::string& message) {
309 TRACE_EVENT0("devtools", "DevToolsAgent::OnDispatchOnInspectorBackend"); 315 TRACE_EVENT0("devtools", "DevToolsAgent::OnDispatchOnInspectorBackend");
310 WebDevToolsAgent* web_agent = GetWebAgent(); 316 WebDevToolsAgent* web_agent = GetWebAgent();
311 if (web_agent) 317 if (web_agent)
312 web_agent->dispatchOnInspectorBackend(WebString::fromUTF8(message)); 318 web_agent->dispatchOnInspectorBackend(WebString::fromUTF8(message));
313 } 319 }
314 320
315 void DevToolsAgent::OnInspectElement(int x, int y) { 321 void DevToolsAgent::OnInspectElement(
322 const std::string& host_id, int x, int y) {
316 WebDevToolsAgent* web_agent = GetWebAgent(); 323 WebDevToolsAgent* web_agent = GetWebAgent();
317 if (web_agent) { 324 if (web_agent) {
318 web_agent->attach(); 325 web_agent->attach(WebString::fromUTF8(host_id));
319 web_agent->inspectElementAt(WebPoint(x, y)); 326 web_agent->inspectElementAt(WebPoint(x, y));
327 is_attached_ = true;
320 } 328 }
321 } 329 }
322 330
323 void DevToolsAgent::OnAddMessageToConsole(ConsoleMessageLevel level, 331 void DevToolsAgent::OnAddMessageToConsole(ConsoleMessageLevel level,
324 const std::string& message) { 332 const std::string& message) {
325 WebView* web_view = render_view()->GetWebView(); 333 WebView* web_view = render_view()->GetWebView();
326 if (!web_view) 334 if (!web_view)
327 return; 335 return;
328 336
329 WebFrame* main_frame = web_view->mainFrame(); 337 WebFrame* main_frame = web_view->mainFrame();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 if (!web_view) 378 if (!web_view)
371 return NULL; 379 return NULL;
372 return web_view->devToolsAgent(); 380 return web_view->devToolsAgent();
373 } 381 }
374 382
375 bool DevToolsAgent::IsAttached() { 383 bool DevToolsAgent::IsAttached() {
376 return is_attached_; 384 return is_attached_;
377 } 385 }
378 386
379 } // namespace content 387 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/devtools/devtools_agent.h ('k') | content/renderer/devtools/devtools_agent_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698