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

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

Issue 1047653003: [DevTools] Unpause renderer when paused RenderFrame is closed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 5 years, 8 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
« no previous file with comments | « content/renderer/devtools/devtools_agent.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "content/common/devtools_messages.h" 13 #include "content/common/devtools_messages.h"
14 #include "content/common/frame_messages.h" 14 #include "content/common/frame_messages.h"
15 #include "content/common/view_messages.h"
16 #include "content/renderer/devtools/devtools_client.h" 15 #include "content/renderer/devtools/devtools_client.h"
17 #include "content/renderer/render_frame_impl.h" 16 #include "content/renderer/render_frame_impl.h"
18 #include "content/renderer/render_widget.h" 17 #include "content/renderer/render_widget.h"
19 #include "ipc/ipc_channel.h" 18 #include "ipc/ipc_channel.h"
20 #include "third_party/WebKit/public/platform/WebPoint.h" 19 #include "third_party/WebKit/public/platform/WebPoint.h"
21 #include "third_party/WebKit/public/platform/WebString.h" 20 #include "third_party/WebKit/public/platform/WebString.h"
22 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 21 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
23 #include "third_party/WebKit/public/web/WebDevToolsAgent.h" 22 #include "third_party/WebKit/public/web/WebDevToolsAgent.h"
24 #include "third_party/WebKit/public/web/WebLocalFrame.h" 23 #include "third_party/WebKit/public/web/WebLocalFrame.h"
25 24
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 base::LazyInstance<IdToAgentMap>::Leaky 62 base::LazyInstance<IdToAgentMap>::Leaky
64 g_agent_for_routing_id = LAZY_INSTANCE_INITIALIZER; 63 g_agent_for_routing_id = LAZY_INSTANCE_INITIALIZER;
65 64
66 } // namespace 65 } // namespace
67 66
68 DevToolsAgent::DevToolsAgent(RenderFrameImpl* frame) 67 DevToolsAgent::DevToolsAgent(RenderFrameImpl* frame)
69 : RenderFrameObserver(frame), 68 : RenderFrameObserver(frame),
70 is_attached_(false), 69 is_attached_(false),
71 is_devtools_client_(false), 70 is_devtools_client_(false),
72 paused_in_mouse_move_(false), 71 paused_in_mouse_move_(false),
72 paused_(false),
73 frame_(frame) { 73 frame_(frame) {
74 g_agent_for_routing_id.Get()[routing_id()] = this; 74 g_agent_for_routing_id.Get()[routing_id()] = this;
75 frame_->GetWebFrame()->setDevToolsAgentClient(this); 75 frame_->GetWebFrame()->setDevToolsAgentClient(this);
76 } 76 }
77 77
78 DevToolsAgent::~DevToolsAgent() { 78 DevToolsAgent::~DevToolsAgent() {
79 g_agent_for_routing_id.Get().erase(routing_id()); 79 g_agent_for_routing_id.Get().erase(routing_id());
80 } 80 }
81 81
82 // Called on the Renderer thread. 82 // Called on the Renderer thread.
83 bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) { 83 bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) {
84 bool handled = true; 84 bool handled = true;
85 IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message) 85 IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message)
86 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach) 86 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach)
87 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Reattach, OnReattach) 87 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Reattach, OnReattach)
88 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) 88 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach)
89 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, 89 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend,
90 OnDispatchOnInspectorBackend) 90 OnDispatchOnInspectorBackend)
91 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement) 91 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement)
92 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_AddMessageToConsole, 92 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_AddMessageToConsole,
93 OnAddMessageToConsole) 93 OnAddMessageToConsole)
94 IPC_MESSAGE_HANDLER(DevToolsMsg_SetupDevToolsClient, OnSetupDevToolsClient) 94 IPC_MESSAGE_HANDLER(DevToolsMsg_SetupDevToolsClient, OnSetupDevToolsClient)
95 IPC_MESSAGE_UNHANDLED(handled = false) 95 IPC_MESSAGE_UNHANDLED(handled = false)
96 IPC_END_MESSAGE_MAP() 96 IPC_END_MESSAGE_MAP()
97 97
98 if (message.type() == FrameMsg_Navigate::ID || 98 if (message.type() == FrameMsg_Navigate::ID)
99 message.type() == ViewMsg_Close::ID)
100 ContinueProgram(); // Don't want to swallow the message. 99 ContinueProgram(); // Don't want to swallow the message.
101 100
102 return handled; 101 return handled;
103 } 102 }
104 103
104 void DevToolsAgent::WidgetWillClose() {
105 ContinueProgram();
106 }
107
105 void DevToolsAgent::sendProtocolMessage( 108 void DevToolsAgent::sendProtocolMessage(
106 int call_id, 109 int call_id,
107 const blink::WebString& message, 110 const blink::WebString& message,
108 const blink::WebString& state_cookie) { 111 const blink::WebString& state_cookie) {
109 SendChunkedProtocolMessage( 112 SendChunkedProtocolMessage(
110 this, routing_id(), call_id, message.utf8(), state_cookie.utf8()); 113 this, routing_id(), call_id, message.utf8(), state_cookie.utf8());
111 } 114 }
112 115
113 blink::WebDevToolsAgentClient::WebKitClientMessageLoop* 116 blink::WebDevToolsAgentClient::WebKitClientMessageLoop*
114 DevToolsAgent::createClientMessageLoop() { 117 DevToolsAgent::createClientMessageLoop() {
115 return new WebKitClientMessageLoopImpl(); 118 return new WebKitClientMessageLoopImpl();
116 } 119 }
117 120
118 void DevToolsAgent::willEnterDebugLoop() { 121 void DevToolsAgent::willEnterDebugLoop() {
122 paused_ = true;
119 if (RenderWidget* widget = frame_->GetRenderWidget()) 123 if (RenderWidget* widget = frame_->GetRenderWidget())
120 paused_in_mouse_move_ = widget->SendAckForMouseMoveFromDebugger(); 124 paused_in_mouse_move_ = widget->SendAckForMouseMoveFromDebugger();
121 } 125 }
122 126
123 void DevToolsAgent::didExitDebugLoop() { 127 void DevToolsAgent::didExitDebugLoop() {
128 paused_ = false;
124 if (!paused_in_mouse_move_) 129 if (!paused_in_mouse_move_)
125 return; 130 return;
126 if (RenderWidget* widget = frame_->GetRenderWidget()) { 131 if (RenderWidget* widget = frame_->GetRenderWidget()) {
127 widget->IgnoreAckForMouseMoveFromDebugger(); 132 widget->IgnoreAckForMouseMoveFromDebugger();
128 paused_in_mouse_move_ = false; 133 paused_in_mouse_move_ = false;
129 } 134 }
130 } 135 }
131 136
132 void DevToolsAgent::enableTracing(const WebString& category_filter) { 137 void DevToolsAgent::enableTracing(const WebString& category_filter) {
133 TraceLog* trace_log = TraceLog::GetInstance(); 138 TraceLog* trace_log = TraceLog::GetInstance();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { 273 WebDevToolsAgent* DevToolsAgent::GetWebAgent() {
269 WebLocalFrame* web_frame = frame_->GetWebFrame(); 274 WebLocalFrame* web_frame = frame_->GetWebFrame();
270 return web_frame ? web_frame->devToolsAgent() : nullptr; 275 return web_frame ? web_frame->devToolsAgent() : nullptr;
271 } 276 }
272 277
273 bool DevToolsAgent::IsAttached() { 278 bool DevToolsAgent::IsAttached() {
274 return is_attached_; 279 return is_attached_;
275 } 280 }
276 281
277 } // namespace content 282 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/devtools/devtools_agent.h ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698