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

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

Issue 1053833002: Revert of [DevTools] Unpause renderer when paused RenderFrame is closed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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"
15 #include "content/renderer/devtools/devtools_client.h" 16 #include "content/renderer/devtools/devtools_client.h"
16 #include "content/renderer/render_frame_impl.h" 17 #include "content/renderer/render_frame_impl.h"
17 #include "content/renderer/render_widget.h" 18 #include "content/renderer/render_widget.h"
18 #include "ipc/ipc_channel.h" 19 #include "ipc/ipc_channel.h"
19 #include "third_party/WebKit/public/platform/WebPoint.h" 20 #include "third_party/WebKit/public/platform/WebPoint.h"
20 #include "third_party/WebKit/public/platform/WebString.h" 21 #include "third_party/WebKit/public/platform/WebString.h"
21 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 22 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
22 #include "third_party/WebKit/public/web/WebDevToolsAgent.h" 23 #include "third_party/WebKit/public/web/WebDevToolsAgent.h"
23 #include "third_party/WebKit/public/web/WebLocalFrame.h" 24 #include "third_party/WebKit/public/web/WebLocalFrame.h"
24 25
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 base::LazyInstance<IdToAgentMap>::Leaky 63 base::LazyInstance<IdToAgentMap>::Leaky
63 g_agent_for_routing_id = LAZY_INSTANCE_INITIALIZER; 64 g_agent_for_routing_id = LAZY_INSTANCE_INITIALIZER;
64 65
65 } // namespace 66 } // namespace
66 67
67 DevToolsAgent::DevToolsAgent(RenderFrameImpl* frame) 68 DevToolsAgent::DevToolsAgent(RenderFrameImpl* frame)
68 : RenderFrameObserver(frame), 69 : RenderFrameObserver(frame),
69 is_attached_(false), 70 is_attached_(false),
70 is_devtools_client_(false), 71 is_devtools_client_(false),
71 paused_in_mouse_move_(false), 72 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)
99 ContinueProgram(); // Don't want to swallow the message. 100 ContinueProgram(); // Don't want to swallow the message.
100 101
101 return handled; 102 return handled;
102 } 103 }
103 104
104 void DevToolsAgent::WidgetWillClose() {
105 ContinueProgram();
106 }
107
108 void DevToolsAgent::sendProtocolMessage( 105 void DevToolsAgent::sendProtocolMessage(
109 int call_id, 106 int call_id,
110 const blink::WebString& message, 107 const blink::WebString& message,
111 const blink::WebString& state_cookie) { 108 const blink::WebString& state_cookie) {
112 SendChunkedProtocolMessage( 109 SendChunkedProtocolMessage(
113 this, routing_id(), call_id, message.utf8(), state_cookie.utf8()); 110 this, routing_id(), call_id, message.utf8(), state_cookie.utf8());
114 } 111 }
115 112
116 blink::WebDevToolsAgentClient::WebKitClientMessageLoop* 113 blink::WebDevToolsAgentClient::WebKitClientMessageLoop*
117 DevToolsAgent::createClientMessageLoop() { 114 DevToolsAgent::createClientMessageLoop() {
118 return new WebKitClientMessageLoopImpl(); 115 return new WebKitClientMessageLoopImpl();
119 } 116 }
120 117
121 void DevToolsAgent::willEnterDebugLoop() { 118 void DevToolsAgent::willEnterDebugLoop() {
122 paused_ = true;
123 if (RenderWidget* widget = frame_->GetRenderWidget()) 119 if (RenderWidget* widget = frame_->GetRenderWidget())
124 paused_in_mouse_move_ = widget->SendAckForMouseMoveFromDebugger(); 120 paused_in_mouse_move_ = widget->SendAckForMouseMoveFromDebugger();
125 } 121 }
126 122
127 void DevToolsAgent::didExitDebugLoop() { 123 void DevToolsAgent::didExitDebugLoop() {
128 paused_ = false;
129 if (!paused_in_mouse_move_) 124 if (!paused_in_mouse_move_)
130 return; 125 return;
131 if (RenderWidget* widget = frame_->GetRenderWidget()) { 126 if (RenderWidget* widget = frame_->GetRenderWidget()) {
132 widget->IgnoreAckForMouseMoveFromDebugger(); 127 widget->IgnoreAckForMouseMoveFromDebugger();
133 paused_in_mouse_move_ = false; 128 paused_in_mouse_move_ = false;
134 } 129 }
135 } 130 }
136 131
137 void DevToolsAgent::enableTracing(const WebString& category_filter) { 132 void DevToolsAgent::enableTracing(const WebString& category_filter) {
138 TraceLog* trace_log = TraceLog::GetInstance(); 133 TraceLog* trace_log = TraceLog::GetInstance();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { 268 WebDevToolsAgent* DevToolsAgent::GetWebAgent() {
274 WebLocalFrame* web_frame = frame_->GetWebFrame(); 269 WebLocalFrame* web_frame = frame_->GetWebFrame();
275 return web_frame ? web_frame->devToolsAgent() : nullptr; 270 return web_frame ? web_frame->devToolsAgent() : nullptr;
276 } 271 }
277 272
278 bool DevToolsAgent::IsAttached() { 273 bool DevToolsAgent::IsAttached() {
279 return is_attached_; 274 return is_attached_;
280 } 275 }
281 276
282 } // namespace content 277 } // 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