Commit 8a429d0f authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

DevTools: [remote debugging] terminate web socket connection upon renderer disconnect.

BUG=154253


Review URL: https://chromiumcodereview.appspot.com/11141024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162123 0039d316-1c4b-4281-b951-d872f2087c98
parent 7884757e
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include "content/public/browser/devtools_manager.h" #include "content/public/browser/devtools_manager.h"
#include "content/public/browser/favicon_status.h" #include "content/public/browser/favicon_status.h"
#include "content/public/browser/navigation_entry.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_process_host.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h" #include "content/public/browser/render_widget_host.h"
...@@ -81,20 +83,31 @@ class DevToolsDefaultBindingHandler ...@@ -81,20 +83,31 @@ class DevToolsDefaultBindingHandler
// An internal implementation of DevToolsClientHost that delegates // An internal implementation of DevToolsClientHost that delegates
// messages sent for DevToolsClient to a DebuggerShell instance. // messages sent for DevToolsClient to a DebuggerShell instance.
class DevToolsClientHostImpl : public DevToolsClientHost { class DevToolsClientHostImpl : public DevToolsClientHost,
public NotificationObserver {
public: public:
DevToolsClientHostImpl( DevToolsClientHostImpl(
MessageLoop* message_loop, MessageLoop* message_loop,
net::HttpServer* server, net::HttpServer* server,
int connection_id) int connection_id,
RenderProcessHost* process_host)
: message_loop_(message_loop), : message_loop_(message_loop),
server_(server), 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,
Source<RenderProcessHost>(process_host));
} }
~DevToolsClientHostImpl() {} ~DevToolsClientHostImpl() {}
// DevToolsClientHost interface // DevToolsClientHost interface
virtual void InspectedContentsClosing() { virtual void InspectedContentsClosing() {
if (is_closed_)
return;
is_closed_ = true;
message_loop_->PostTask( message_loop_->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&net::HttpServer::Close, server_, connection_id_)); base::Bind(&net::HttpServer::Close, server_, connection_id_));
...@@ -113,10 +126,18 @@ class DevToolsClientHostImpl : public DevToolsClientHost { ...@@ -113,10 +126,18 @@ class DevToolsClientHostImpl : public DevToolsClientHost {
} }
private: private:
virtual void Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) {
InspectedContentsClosing();
}
virtual void FrameNavigating(const std::string& url) {} virtual void FrameNavigating(const std::string& url) {}
MessageLoop* message_loop_; MessageLoop* message_loop_;
net::HttpServer* server_; net::HttpServer* server_;
int connection_id_; int connection_id_;
bool is_closed_;
NotificationRegistrar registrar_;
}; };
} // namespace } // namespace
...@@ -486,7 +507,8 @@ void DevToolsHttpHandlerImpl::OnWebSocketRequestUI( ...@@ -486,7 +507,8 @@ void DevToolsHttpHandlerImpl::OnWebSocketRequestUI(
DevToolsClientHostImpl* client_host = DevToolsClientHostImpl* client_host =
new DevToolsClientHostImpl(thread_->message_loop(), new DevToolsClientHostImpl(thread_->message_loop(),
server_, server_,
connection_id); connection_id,
rvh->GetProcess());
connection_to_client_host_ui_[connection_id] = client_host; connection_to_client_host_ui_[connection_id] = client_host;
manager->RegisterDevToolsClientHostFor(agent, client_host); manager->RegisterDevToolsClientHostFor(agent, client_host);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment