Index: content/browser/debugger/devtools_http_handler_impl.cc |
diff --git a/content/browser/debugger/devtools_http_handler_impl.cc b/content/browser/debugger/devtools_http_handler_impl.cc |
index 70c0bf33b7b0996b100886ed9c8de6c5174c36b5..617f3c0aa47fd23c267fce4471082fec63a7198b 100644 |
--- a/content/browser/debugger/devtools_http_handler_impl.cc |
+++ b/content/browser/debugger/devtools_http_handler_impl.cc |
@@ -28,6 +28,8 @@ |
#include "content/public/browser/devtools_manager.h" |
#include "content/public/browser/favicon_status.h" |
#include "content/public/browser/navigation_entry.h" |
+#include "content/public/browser/notification_service.h" |
+#include "content/public/browser/notification_types.h" |
#include "content/public/browser/render_process_host.h" |
#include "content/public/browser/render_view_host.h" |
#include "content/public/browser/render_widget_host.h" |
@@ -81,20 +83,31 @@ class DevToolsDefaultBindingHandler |
// An internal implementation of DevToolsClientHost that delegates |
// messages sent for DevToolsClient to a DebuggerShell instance. |
-class DevToolsClientHostImpl : public DevToolsClientHost { |
+class DevToolsClientHostImpl : public DevToolsClientHost, |
+ public NotificationObserver { |
public: |
DevToolsClientHostImpl( |
MessageLoop* message_loop, |
net::HttpServer* server, |
- int connection_id) |
+ int connection_id, |
+ RenderProcessHost* process_host) |
: message_loop_(message_loop), |
server_(server), |
- connection_id_(connection_id) { |
+ connection_id_(connection_id), |
+ is_closed_(false) { |
+ registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
+ Source<RenderProcessHost>(process_host)); |
+ registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED, |
yurys
2012/10/16 06:18:20
We listen to the termination of the render process
pfeldman
2012/10/16 08:35:28
We maintain WebSocket connection (And DevToolsClie
|
+ Source<RenderProcessHost>(process_host)); |
} |
+ |
~DevToolsClientHostImpl() {} |
// DevToolsClientHost interface |
virtual void InspectedContentsClosing() { |
+ if (is_closed_) |
+ return; |
+ is_closed_ = true; |
message_loop_->PostTask( |
FROM_HERE, |
base::Bind(&net::HttpServer::Close, server_, connection_id_)); |
@@ -113,10 +126,18 @@ class DevToolsClientHostImpl : public DevToolsClientHost { |
} |
private: |
+ virtual void Observe(int type, |
+ const NotificationSource& source, |
+ const NotificationDetails& details) { |
+ InspectedContentsClosing(); |
+ } |
+ |
virtual void FrameNavigating(const std::string& url) {} |
MessageLoop* message_loop_; |
net::HttpServer* server_; |
int connection_id_; |
+ bool is_closed_; |
+ NotificationRegistrar registrar_; |
}; |
} // namespace |
@@ -486,7 +507,8 @@ void DevToolsHttpHandlerImpl::OnWebSocketRequestUI( |
DevToolsClientHostImpl* client_host = |
new DevToolsClientHostImpl(thread_->message_loop(), |
server_, |
- connection_id); |
+ connection_id, |
+ rvh->GetProcess()); |
yurys
2012/10/16 06:18:20
This will not work for clients attached to instanc
pfeldman
2012/10/16 08:35:28
Allowing workers will require a major rewrite of d
|
connection_to_client_host_ui_[connection_id] = client_host; |
manager->RegisterDevToolsClientHostFor(agent, client_host); |