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

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

Issue 12906011: Detect debugging target crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 9 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/browser/devtools/render_view_devtools_agent_host.h" 5 #include "content/browser/devtools/render_view_devtools_agent_host.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "content/browser/child_process_security_policy_impl.h" 10 #include "content/browser/child_process_security_policy_impl.h"
11 #include "content/browser/devtools/devtools_manager_impl.h" 11 #include "content/browser/devtools/devtools_manager_impl.h"
12 #include "content/browser/devtools/devtools_protocol.h" 12 #include "content/browser/devtools/devtools_protocol.h"
13 #include "content/browser/devtools/devtools_protocol_constants.h"
13 #include "content/browser/devtools/renderer_overrides_handler.h" 14 #include "content/browser/devtools/renderer_overrides_handler.h"
14 #include "content/browser/renderer_host/render_process_host_impl.h" 15 #include "content/browser/renderer_host/render_process_host_impl.h"
15 #include "content/browser/renderer_host/render_view_host_impl.h" 16 #include "content/browser/renderer_host/render_view_host_impl.h"
16 #include "content/browser/site_instance_impl.h" 17 #include "content/browser/site_instance_impl.h"
17 #include "content/browser/web_contents/web_contents_impl.h" 18 #include "content/browser/web_contents/web_contents_impl.h"
18 #include "content/common/devtools_messages.h" 19 #include "content/common/devtools_messages.h"
19 #include "content/public/browser/content_browser_client.h" 20 #include "content/public/browser/content_browser_client.h"
20 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/notification_types.h" 22 #include "content/public/browser/notification_types.h"
22 #include "content/public/browser/render_widget_host_view.h" 23 #include "content/public/browser/render_widget_host_view.h"
(...skipping 18 matching lines...) Expand all
41 if (rvh == (*it)->render_view_host()) 42 if (rvh == (*it)->render_view_host())
42 return *it; 43 return *it;
43 } 44 }
44 return NULL; 45 return NULL;
45 } 46 }
46 47
47 } // namespace 48 } // namespace
48 49
49 using WebKit::WebDevToolsAgent; 50 using WebKit::WebDevToolsAgent;
50 51
51 class DevToolsAgentHostRvhObserver : public RenderViewHostObserver { 52 class RenderViewDevToolsAgentHost::DevToolsAgentHostRvhObserver
53 : public RenderViewHostObserver {
52 public: 54 public:
53 DevToolsAgentHostRvhObserver(RenderViewHost* rvh, 55 DevToolsAgentHostRvhObserver(RenderViewHost* rvh,
54 RenderViewDevToolsAgentHost* agent_host) 56 RenderViewDevToolsAgentHost* agent_host)
55 : RenderViewHostObserver(rvh), 57 : RenderViewHostObserver(rvh),
56 agent_host_(agent_host) { 58 agent_host_(agent_host) {
57 } 59 }
58 virtual ~DevToolsAgentHostRvhObserver() {} 60 virtual ~DevToolsAgentHostRvhObserver() {}
59 61
60 // RenderViewHostObserver overrides. 62 // RenderViewHostObserver overrides.
61 virtual void RenderViewHostDestroyed(RenderViewHost* rvh) OVERRIDE { 63 virtual void RenderViewHostDestroyed(RenderViewHost* rvh) OVERRIDE {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 return; 272 return;
271 273
272 if (render_view_host_ == dest_rvh && static_cast<RenderViewHostImpl*>( 274 if (render_view_host_ == dest_rvh && static_cast<RenderViewHostImpl*>(
273 render_view_host_)->render_view_termination_status() == 275 render_view_host_)->render_view_termination_status() ==
274 base::TERMINATION_STATUS_STILL_RUNNING) 276 base::TERMINATION_STATUS_STILL_RUNNING)
275 return; 277 return;
276 DisconnectRenderViewHost(); 278 DisconnectRenderViewHost();
277 ConnectRenderViewHost(dest_rvh, true); 279 ConnectRenderViewHost(dest_rvh, true);
278 } 280 }
279 281
282 void RenderViewDevToolsAgentHost::RenderViewGone(
283 base::TerminationStatus status) {
284 switch(status) {
285 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION:
286 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED:
287 case base::TERMINATION_STATUS_PROCESS_CRASHED:
288 RenderViewCrashed();
289 break;
290 default:
291 break;
292 }
293 }
294
280 void RenderViewDevToolsAgentHost::ConnectRenderViewHost(RenderViewHost* rvh, 295 void RenderViewDevToolsAgentHost::ConnectRenderViewHost(RenderViewHost* rvh,
281 bool reattach) { 296 bool reattach) {
282 render_view_host_ = rvh; 297 render_view_host_ = rvh;
283 rvh_observer_.reset(new DevToolsAgentHostRvhObserver(rvh, this)); 298 rvh_observer_.reset(new DevToolsAgentHostRvhObserver(rvh, this));
284 if (reattach) 299 if (reattach)
285 Reattach(state_); 300 Reattach(state_);
286 } 301 }
287 302
288 void RenderViewDevToolsAgentHost::DisconnectRenderViewHost() { 303 void RenderViewDevToolsAgentHost::DisconnectRenderViewHost() {
289 NotifyClientDetaching(); 304 NotifyClientDetaching();
290 rvh_observer_.reset(); 305 rvh_observer_.reset();
291 render_view_host_ = NULL; 306 render_view_host_ = NULL;
292 } 307 }
293 308
294 void RenderViewDevToolsAgentHost::RenderViewHostDestroyed( 309 void RenderViewDevToolsAgentHost::RenderViewHostDestroyed(
295 RenderViewHost* rvh) { 310 RenderViewHost* rvh) {
296 DCHECK(render_view_host_); 311 DCHECK(render_view_host_);
297 scoped_refptr<RenderViewDevToolsAgentHost> protect(this); 312 scoped_refptr<RenderViewDevToolsAgentHost> protect(this);
298 NotifyCloseListener(); 313 NotifyCloseListener();
299 render_view_host_ = NULL; 314 render_view_host_ = NULL;
300 Release(); 315 Release();
301 } 316 }
302 317
318 void RenderViewDevToolsAgentHost::RenderViewCrashed() {
319 scoped_ptr<DevToolsProtocol::Event> event(
320 DevToolsProtocol::CreateEvent(
321 devtools::Inspector::targetCrashed::kName, NULL));
322 DevToolsManagerImpl::GetInstance()->
323 DispatchOnInspectorFrontend(this, event->Serialize());
324 }
325
303 bool RenderViewDevToolsAgentHost::OnRvhMessageReceived( 326 bool RenderViewDevToolsAgentHost::OnRvhMessageReceived(
304 const IPC::Message& message) { 327 const IPC::Message& message) {
305 bool handled = true; 328 bool handled = true;
306 IPC_BEGIN_MESSAGE_MAP(RenderViewDevToolsAgentHost, message) 329 IPC_BEGIN_MESSAGE_MAP(RenderViewDevToolsAgentHost, message)
307 IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend, 330 IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend,
308 OnDispatchOnInspectorFrontend) 331 OnDispatchOnInspectorFrontend)
309 IPC_MESSAGE_HANDLER(DevToolsHostMsg_SaveAgentRuntimeState, 332 IPC_MESSAGE_HANDLER(DevToolsHostMsg_SaveAgentRuntimeState,
310 OnSaveAgentRuntimeState) 333 OnSaveAgentRuntimeState)
311 IPC_MESSAGE_HANDLER(DevToolsHostMsg_ClearBrowserCache, OnClearBrowserCache) 334 IPC_MESSAGE_HANDLER(DevToolsHostMsg_ClearBrowserCache, OnClearBrowserCache)
312 IPC_MESSAGE_HANDLER(DevToolsHostMsg_ClearBrowserCookies, 335 IPC_MESSAGE_HANDLER(DevToolsHostMsg_ClearBrowserCookies,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 snapshot_bounds)) 405 snapshot_bounds))
383 return false; 406 return false;
384 407
385 return base::Base64Encode(base::StringPiece( 408 return base::Base64Encode(base::StringPiece(
386 reinterpret_cast<char*>(&*png.begin()), 409 reinterpret_cast<char*>(&*png.begin()),
387 png.size()), 410 png.size()),
388 base_64_data); 411 base_64_data);
389 } 412 }
390 413
391 } // namespace content 414 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/render_view_devtools_agent_host.h ('k') | content/browser/devtools/renderer_overrides_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698