diff options
-rw-r--r-- | content/browser/debugger/devtools_agent_host.cc | 18 | ||||
-rw-r--r-- | content/browser/debugger/devtools_agent_host.h | 44 | ||||
-rw-r--r-- | content/browser/debugger/devtools_manager.cc | 201 | ||||
-rw-r--r-- | content/browser/debugger/devtools_manager.h | 47 | ||||
-rw-r--r-- | content/browser/debugger/render_view_devtools_agent_host.cc | 58 | ||||
-rw-r--r-- | content/browser/debugger/render_view_devtools_agent_host.h | 46 | ||||
-rw-r--r-- | content/content_browser.gypi | 4 |
7 files changed, 300 insertions, 118 deletions
diff --git a/content/browser/debugger/devtools_agent_host.cc b/content/browser/debugger/devtools_agent_host.cc new file mode 100644 index 0000000..3e897e3 --- /dev/null +++ b/content/browser/debugger/devtools_agent_host.cc @@ -0,0 +1,18 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/browser/debugger/devtools_agent_host.h" + +#include "base/basictypes.h" + +DevToolsAgentHost::DevToolsAgentHost() : close_listener_(NULL) { +} + +void DevToolsAgentHost::NotifyCloseListener() { + if (close_listener_) { + close_listener_->AgentHostClosing(this); + close_listener_ = NULL; + } +} + diff --git a/content/browser/debugger/devtools_agent_host.h b/content/browser/debugger/devtools_agent_host.h new file mode 100644 index 0000000..7208e72 --- /dev/null +++ b/content/browser/debugger/devtools_agent_host.h @@ -0,0 +1,44 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_DEBUGGER_DEVTOOLS_AGENT_HOST_H_ +#define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_AGENT_HOST_H_ +#pragma once + +namespace IPC { +class Message; +} + +// Describes interface for managing devtools agents from the browser process. +class DevToolsAgentHost { + public: + class CloseListener { + public: + virtual void AgentHostClosing(DevToolsAgentHost*) = 0; + protected: + virtual ~CloseListener() {} + }; + + // Sends the message to the devtools agent hosted by this object. + virtual void SendMessageToAgent(IPC::Message* msg) = 0; + + // TODO(yurys): get rid of this method + virtual void NotifyClientClosing() = 0; + + virtual int GetRenderProcessId() = 0; + + void set_close_listener(CloseListener* listener) { + close_listener_ = listener; + } + + protected: + DevToolsAgentHost(); + virtual ~DevToolsAgentHost() {} + + void NotifyCloseListener(); + + CloseListener* close_listener_; +}; + +#endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_AGENT_HOST_H_ diff --git a/content/browser/debugger/devtools_manager.cc b/content/browser/debugger/devtools_manager.cc index 383d6c4..7878c64 100644 --- a/content/browser/debugger/devtools_manager.cc +++ b/content/browser/debugger/devtools_manager.cc @@ -13,12 +13,11 @@ #include "content/browser/content_browser_client.h" #include "content/browser/debugger/devtools_client_host.h" #include "content/browser/debugger/devtools_netlog_observer.h" +#include "content/browser/debugger/render_view_devtools_agent_host.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/common/content_client.h" #include "content/common/devtools_messages.h" -#include "content/common/notification_service.h" #include "googleurl/src/gurl.h" // static @@ -28,13 +27,11 @@ DevToolsManager* DevToolsManager::GetInstance() { DevToolsManager::DevToolsManager() : last_orphan_cookie_(0) { - registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, - NotificationService::AllSources()); } DevToolsManager::~DevToolsManager() { - DCHECK(inspected_rvh_to_client_host_.empty()); - DCHECK(client_host_to_inspected_rvh_.empty()); + DCHECK(agent_to_client_host_.empty()); + DCHECK(client_to_agent_host_.empty()); // By the time we destroy devtools manager, all orphan client hosts should // have been delelted, no need to notify them upon tab closing. DCHECK(orphan_client_hosts_.empty()); @@ -42,9 +39,15 @@ DevToolsManager::~DevToolsManager() { DevToolsClientHost* DevToolsManager::GetDevToolsClientHostFor( RenderViewHost* inspected_rvh) { - InspectedRvhToClientHostMap::iterator it = - inspected_rvh_to_client_host_.find(inspected_rvh); - if (it != inspected_rvh_to_client_host_.end()) + DevToolsAgentHost* agent_host = RenderViewDevToolsAgentHost::FindFor( + inspected_rvh); + return GetDevToolsClientHostFor(agent_host); +} + +DevToolsClientHost* DevToolsManager::GetDevToolsClientHostFor( + DevToolsAgentHost* agent_host) { + AgentToClientHostMap::iterator it = agent_to_client_host_.find(agent_host); + if (it != agent_to_client_host_.end()) return it->second; return NULL; } @@ -55,20 +58,20 @@ void DevToolsManager::RegisterDevToolsClientHostFor( DCHECK(!GetDevToolsClientHostFor(inspected_rvh)); DevToolsRuntimeProperties initial_properties; - BindClientHost(inspected_rvh, client_host, initial_properties); + DevToolsAgentHost* agent_host = RenderViewDevToolsAgentHost::FindFor( + inspected_rvh); + BindClientHost(agent_host, client_host, initial_properties); client_host->set_close_listener(this); - SendAttachToAgent(inspected_rvh); + SendAttachToAgent(agent_host); } bool DevToolsManager::ForwardToDevToolsAgent(DevToolsClientHost* from, const IPC::Message& message) { - RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(from); - if (!inspected_rvh) + DevToolsAgentHost* agent_host = GetAgentHost(from); + if (!agent_host) return false; - IPC::Message* m = new IPC::Message(message); - m->set_routing_id(inspected_rvh->routing_id()); - inspected_rvh->Send(m); + agent_host->SendMessageToAgent(new IPC::Message(message)); return true; } @@ -86,11 +89,13 @@ void DevToolsManager::ForwardToDevToolsClient(RenderViewHost* inspected_rvh, void DevToolsManager::RuntimePropertyChanged(RenderViewHost* inspected_rvh, const std::string& name, const std::string& value) { + DevToolsAgentHost* agent_host = RenderViewDevToolsAgentHost::FindFor( + inspected_rvh); RuntimePropertiesMap::iterator it = - runtime_properties_map_.find(inspected_rvh); + runtime_properties_map_.find(agent_host); if (it == runtime_properties_map_.end()) { - std::pair<RenderViewHost*, DevToolsRuntimeProperties> value( - inspected_rvh, + std::pair<DevToolsAgentHost*, DevToolsRuntimeProperties> value( + agent_host, DevToolsRuntimeProperties()); it = runtime_properties_map_.insert(value).first; } @@ -106,13 +111,13 @@ void DevToolsManager::SendInspectElement(RenderViewHost* inspected_rvh, y)); } -void DevToolsManager::ClientHostClosing(DevToolsClientHost* host) { - RenderViewHost* inspected_rvh = GetInspectedRenderViewHost(host); - if (!inspected_rvh) { +void DevToolsManager::ClientHostClosing(DevToolsClientHost* client_host) { + DevToolsAgentHost* agent_host = GetAgentHost(client_host); + if (!agent_host) { // It might be in the list of orphan client hosts, remove it from there. for (OrphanClientHosts::iterator it = orphan_client_hosts_.begin(); it != orphan_client_hosts_.end(); ++it) { - if (it->second.first == host) { + if (it->second.first == client_host) { orphan_client_hosts_.erase(it->first); return; } @@ -120,38 +125,38 @@ void DevToolsManager::ClientHostClosing(DevToolsClientHost* host) { return; } - NotificationService::current()->Notify( - content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING, - Source<content::BrowserContext>( - inspected_rvh->site_instance()->GetProcess()->browser_context()), - Details<RenderViewHost>(inspected_rvh)); + agent_host->NotifyClientClosing(); - UnbindClientHost(inspected_rvh, host); + UnbindClientHost(agent_host, client_host); } -void DevToolsManager::Observe(int type, - const NotificationSource& source, - const NotificationDetails& details) { - DCHECK(type == content::NOTIFICATION_RENDER_VIEW_HOST_DELETED); - UnregisterDevToolsClientHostFor(Source<RenderViewHost>(source).ptr()); +void DevToolsManager::AgentHostClosing(DevToolsAgentHost* agent_host) { + UnregisterDevToolsClientHostFor(agent_host); } -RenderViewHost* DevToolsManager::GetInspectedRenderViewHost( +DevToolsAgentHost* DevToolsManager::GetAgentHost( DevToolsClientHost* client_host) { ClientHostToInspectedRvhMap::iterator it = - client_host_to_inspected_rvh_.find(client_host); - if (it != client_host_to_inspected_rvh_.end()) + client_to_agent_host_.find(client_host); + if (it != client_to_agent_host_.end()) return it->second; return NULL; } void DevToolsManager::UnregisterDevToolsClientHostFor( RenderViewHost* inspected_rvh) { - DevToolsClientHost* host = GetDevToolsClientHostFor(inspected_rvh); - if (!host) + DevToolsAgentHost* agent_host = RenderViewDevToolsAgentHost::FindFor( + inspected_rvh); + UnregisterDevToolsClientHostFor(agent_host); +} + +void DevToolsManager::UnregisterDevToolsClientHostFor( + DevToolsAgentHost* agent_host) { + DevToolsClientHost* client_host = GetDevToolsClientHostFor(agent_host); + if (!client_host) return; - UnbindClientHost(inspected_rvh, host); - host->InspectedTabClosing(); + UnbindClientHost(agent_host, client_host); + client_host->InspectedTabClosing(); } void DevToolsManager::OnNavigatingToPendingEntry(RenderViewHost* rvh, @@ -182,16 +187,18 @@ void DevToolsManager::TabReplaced(TabContents* old_tab, } int DevToolsManager::DetachClientHost(RenderViewHost* from_rvh) { - DevToolsClientHost* client_host = GetDevToolsClientHostFor(from_rvh); + DevToolsAgentHost* agent_host = RenderViewDevToolsAgentHost::FindFor( + from_rvh); + DevToolsClientHost* client_host = GetDevToolsClientHostFor(agent_host); if (!client_host) return -1; int cookie = last_orphan_cookie_++; orphan_client_hosts_[cookie] = std::pair<DevToolsClientHost*, DevToolsRuntimeProperties>( - client_host, runtime_properties_map_[from_rvh]); + client_host, runtime_properties_map_[agent_host]); - UnbindClientHost(from_rvh, client_host); + UnbindClientHost(agent_host, client_host); return cookie; } @@ -203,82 +210,86 @@ void DevToolsManager::AttachClientHost(int client_host_cookie, return; DevToolsClientHost* client_host = (*it).second.first; - BindClientHost(to_rvh, client_host, (*it).second.second); - SendAttachToAgent(to_rvh); + DevToolsAgentHost* agent_host = RenderViewDevToolsAgentHost::FindFor( + to_rvh); + BindClientHost(agent_host, client_host, (*it).second.second); + SendAttachToAgent(agent_host); orphan_client_hosts_.erase(client_host_cookie); } -void DevToolsManager::SendAttachToAgent(RenderViewHost* inspected_rvh) { - if (inspected_rvh) { - ChildProcessSecurityPolicy::GetInstance()->GrantReadRawCookies( - inspected_rvh->process()->id()); - - DevToolsRuntimeProperties properties; - RuntimePropertiesMap::iterator it = - runtime_properties_map_.find(inspected_rvh); - if (it != runtime_properties_map_.end()) { - properties = DevToolsRuntimeProperties(it->second.begin(), - it->second.end()); - } - inspected_rvh->Send(new DevToolsAgentMsg_Attach( - inspected_rvh->routing_id(), - properties)); +void DevToolsManager::SendAttachToAgent(DevToolsAgentHost* agent_host) { + DevToolsRuntimeProperties properties; + RuntimePropertiesMap::iterator it = + runtime_properties_map_.find(agent_host); + if (it != runtime_properties_map_.end()) { + properties = DevToolsRuntimeProperties(it->second.begin(), + it->second.end()); } + agent_host->SendMessageToAgent(new DevToolsAgentMsg_Attach( + MSG_ROUTING_NONE, + properties)); } -void DevToolsManager::SendDetachToAgent(RenderViewHost* inspected_rvh) { - if (inspected_rvh) { - inspected_rvh->Send(new DevToolsAgentMsg_Detach( - inspected_rvh->routing_id())); +void DevToolsManager::SendDetachToAgent(DevToolsAgentHost* agent_host) { + if (agent_host) { + agent_host->SendMessageToAgent(new DevToolsAgentMsg_Detach( + MSG_ROUTING_NONE)); } } void DevToolsManager::BindClientHost( - RenderViewHost* inspected_rvh, + DevToolsAgentHost* agent_host, DevToolsClientHost* client_host, const DevToolsRuntimeProperties& runtime_properties) { - DCHECK(inspected_rvh_to_client_host_.find(inspected_rvh) == - inspected_rvh_to_client_host_.end()); - DCHECK(client_host_to_inspected_rvh_.find(client_host) == - client_host_to_inspected_rvh_.end()); + DCHECK(agent_to_client_host_.find(agent_host) == + agent_to_client_host_.end()); + DCHECK(client_to_agent_host_.find(client_host) == + client_to_agent_host_.end()); - if (client_host_to_inspected_rvh_.empty()) { + if (client_to_agent_host_.empty()) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, NewRunnableFunction(&DevToolsNetLogObserver::Attach)); } - inspected_rvh_to_client_host_[inspected_rvh] = client_host; - client_host_to_inspected_rvh_[client_host] = inspected_rvh; - runtime_properties_map_[inspected_rvh] = runtime_properties; + agent_to_client_host_[agent_host] = client_host; + client_to_agent_host_[client_host] = agent_host; + runtime_properties_map_[agent_host] = runtime_properties; + agent_host->set_close_listener(this); + + int process_id = agent_host->GetRenderProcessId(); + if (process_id != -1) + ChildProcessSecurityPolicy::GetInstance()->GrantReadRawCookies(process_id); } -void DevToolsManager::UnbindClientHost(RenderViewHost* inspected_rvh, +void DevToolsManager::UnbindClientHost(DevToolsAgentHost* agent_host, DevToolsClientHost* client_host) { - DCHECK(inspected_rvh_to_client_host_.find(inspected_rvh)->second == + DCHECK(agent_host); + DCHECK(agent_to_client_host_.find(agent_host)->second == client_host); - DCHECK(client_host_to_inspected_rvh_.find(client_host)->second == - inspected_rvh); + DCHECK(client_to_agent_host_.find(client_host)->second == + agent_host); - inspected_rvh_to_client_host_.erase(inspected_rvh); - client_host_to_inspected_rvh_.erase(client_host); - runtime_properties_map_.erase(inspected_rvh); + agent_to_client_host_.erase(agent_host); + client_to_agent_host_.erase(client_host); + runtime_properties_map_.erase(agent_host); - if (client_host_to_inspected_rvh_.empty()) { + if (client_to_agent_host_.empty()) { BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, NewRunnableFunction(&DevToolsNetLogObserver::Detach)); } - SendDetachToAgent(inspected_rvh); + SendDetachToAgent(agent_host); - int process_id = inspected_rvh->process()->id(); - for (InspectedRvhToClientHostMap::iterator it = - inspected_rvh_to_client_host_.begin(); - it != inspected_rvh_to_client_host_.end(); + int process_id = agent_host->GetRenderProcessId(); + if (process_id == -1) + return; + for (AgentToClientHostMap::iterator it = agent_to_client_host_.begin(); + it != agent_to_client_host_.end(); ++it) { - if (it->first->process()->id() == process_id) + if (it->first->GetRenderProcessId() == process_id) return; } // We've disconnected from the last renderer -> revoke cookie permissions. @@ -286,14 +297,14 @@ void DevToolsManager::UnbindClientHost(RenderViewHost* inspected_rvh, } void DevToolsManager::CloseAllClientHosts() { - std::vector<RenderViewHost*> rhvs; - for (InspectedRvhToClientHostMap::iterator it = - inspected_rvh_to_client_host_.begin(); - it != inspected_rvh_to_client_host_.end(); ++it) { - rhvs.push_back(it->first); + std::vector<DevToolsAgentHost*> agents; + for (AgentToClientHostMap::iterator it = + agent_to_client_host_.begin(); + it != agent_to_client_host_.end(); ++it) { + agents.push_back(it->first); } - for (std::vector<RenderViewHost*>::iterator it = rhvs.begin(); - it != rhvs.end(); ++it) { + for (std::vector<DevToolsAgentHost*>::iterator it = agents.begin(); + it != agents.end(); ++it) { UnregisterDevToolsClientHostFor(*it); } } diff --git a/content/browser/debugger/devtools_manager.h b/content/browser/debugger/devtools_manager.h index 4334904..8aabfd6 100644 --- a/content/browser/debugger/devtools_manager.h +++ b/content/browser/debugger/devtools_manager.h @@ -9,14 +9,14 @@ #include <map> #include <string> +#include "content/browser/debugger/devtools_agent_host.h" #include "content/browser/debugger/devtools_client_host.h" -#include "content/common/notification_observer.h" -#include "content/common/notification_registrar.h" namespace IPC { class Message; } +class DevToolsAgentHost; class DevToolsNetLogObserver; class GURL; class IOThread; @@ -28,8 +28,12 @@ typedef std::map<std::string, std::string> DevToolsRuntimeProperties; // This class is a singleton that manages DevToolsClientHost instances and // routes messages between developer tools clients and agents. +// +// Methods below that accept inspected RenderViewHost as a parameter are +// just convenience methods that call corresponding methods accepting +// DevToolAgentHost. class DevToolsManager : public DevToolsClientHost::CloseListener, - public NotificationObserver { + public DevToolsAgentHost::CloseListener { public: static DevToolsManager* GetInstance(); @@ -79,6 +83,9 @@ class DevToolsManager : public DevToolsClientHost::CloseListener, // Closes all open developer tools windows. void CloseAllClientHosts(); + DevToolsClientHost* GetDevToolsClientHostFor(DevToolsAgentHost* agent_host); + void UnregisterDevToolsClientHostFor(DevToolsAgentHost* agent_host); + private: // DevToolsClientHost::CloseListener override. // This method will remove all references from the manager to the @@ -86,23 +93,19 @@ class DevToolsManager : public DevToolsClientHost::CloseListener, // DevToolsClientHost. virtual void ClientHostClosing(DevToolsClientHost* host); - // Overridden from NotificationObserver: - virtual void Observe(int type, - const NotificationSource& source, - const NotificationDetails& details); + // DevToolsAgentHost::CloseListener implementation. + virtual void AgentHostClosing(DevToolsAgentHost* host); - // Returns RenderViewHost for the tab that is inspected by devtools - // client hosted by DevToolsClientHost. - RenderViewHost* GetInspectedRenderViewHost(DevToolsClientHost* client_host); + // Returns DevToolsAgentHost inspected by the DevToolsClientHost. + DevToolsAgentHost* GetAgentHost(DevToolsClientHost* client_host); - void SendAttachToAgent(RenderViewHost* inspected_rvh); - void SendDetachToAgent(RenderViewHost* inspected_rvh); + void SendAttachToAgent(DevToolsAgentHost*); + void SendDetachToAgent(DevToolsAgentHost*); - void BindClientHost(RenderViewHost* inspected_rvh, + void BindClientHost(DevToolsAgentHost* agent_host, DevToolsClientHost* client_host, const DevToolsRuntimeProperties& runtime_properties); - - void UnbindClientHost(RenderViewHost* inspected_rvh, + void UnbindClientHost(DevToolsAgentHost* agent_host, DevToolsClientHost* client_host); // These two maps are for tracking dependencies between inspected tabs and @@ -111,15 +114,15 @@ class DevToolsManager : public DevToolsClientHost::CloseListener, // // DevToolsManager start listening to DevToolsClientHosts when they are put // into these maps and removes them when they are closing. - typedef std::map<RenderViewHost*, DevToolsClientHost*> - InspectedRvhToClientHostMap; - InspectedRvhToClientHostMap inspected_rvh_to_client_host_; + typedef std::map<DevToolsAgentHost*, DevToolsClientHost*> + AgentToClientHostMap; + AgentToClientHostMap agent_to_client_host_; - typedef std::map<DevToolsClientHost*, RenderViewHost*> + typedef std::map<DevToolsClientHost*, DevToolsAgentHost*> ClientHostToInspectedRvhMap; - ClientHostToInspectedRvhMap client_host_to_inspected_rvh_; + ClientHostToInspectedRvhMap client_to_agent_host_; - typedef std::map<RenderViewHost*, DevToolsRuntimeProperties> + typedef std::map<DevToolsAgentHost*, DevToolsRuntimeProperties> RuntimePropertiesMap; RuntimePropertiesMap runtime_properties_map_; @@ -129,8 +132,6 @@ class DevToolsManager : public DevToolsClientHost::CloseListener, OrphanClientHosts orphan_client_hosts_; int last_orphan_cookie_; - NotificationRegistrar registrar_; - DISALLOW_COPY_AND_ASSIGN(DevToolsManager); }; diff --git a/content/browser/debugger/render_view_devtools_agent_host.cc b/content/browser/debugger/render_view_devtools_agent_host.cc new file mode 100644 index 0000000..47517e42 --- /dev/null +++ b/content/browser/debugger/render_view_devtools_agent_host.cc @@ -0,0 +1,58 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/browser/debugger/render_view_devtools_agent_host.h" + +#include "base/basictypes.h" +#include "content/browser/renderer_host/render_process_host.h" +#include "content/browser/renderer_host/render_view_host.h" +#include "content/browser/site_instance.h" +#include "content/common/notification_service.h" + +RenderViewDevToolsAgentHost::Instances RenderViewDevToolsAgentHost::instances_; + +DevToolsAgentHost* RenderViewDevToolsAgentHost::FindFor( + RenderViewHost* rvh) { + Instances::iterator it = instances_.find(rvh); + if (it != instances_.end()) + return it->second; + return new RenderViewDevToolsAgentHost(rvh); +} + +RenderViewDevToolsAgentHost::RenderViewDevToolsAgentHost(RenderViewHost* rvh) + : render_view_host_(rvh) { + registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_DELETED, + Source<RenderViewHost>(rvh)); + instances_[rvh] = this; +} + +void RenderViewDevToolsAgentHost::SendMessageToAgent(IPC::Message* msg) { + msg->set_routing_id(render_view_host_->routing_id()); + render_view_host_->Send(msg); +} + +void RenderViewDevToolsAgentHost::NotifyClientClosing() { + NotificationService::current()->Notify( + content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING, + Source<content::BrowserContext>( + render_view_host_->site_instance()->GetProcess()->browser_context()), + Details<RenderViewHost>(render_view_host_)); +} + +int RenderViewDevToolsAgentHost::GetRenderProcessId() { + return render_view_host_->process()->id(); +} + +void RenderViewDevToolsAgentHost::Observe(int type, + const NotificationSource& source, + const NotificationDetails& details) { + DCHECK(type == content::NOTIFICATION_RENDER_VIEW_HOST_DELETED); + NotifyCloseListener(); + delete this; +} + +RenderViewDevToolsAgentHost::~RenderViewDevToolsAgentHost() { + instances_.erase(render_view_host_); +} + diff --git a/content/browser/debugger/render_view_devtools_agent_host.h b/content/browser/debugger/render_view_devtools_agent_host.h new file mode 100644 index 0000000..9950f2a --- /dev/null +++ b/content/browser/debugger/render_view_devtools_agent_host.h @@ -0,0 +1,46 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_DEBUGGER_RENDER_VIEW_DEVTOOLS_AGENT_HOST_H_ +#define CONTENT_BROWSER_DEBUGGER_RENDER_VIEW_DEVTOOLS_AGENT_HOST_H_ +#pragma once + +#include <map> + +#include "base/basictypes.h" +#include "content/browser/debugger/devtools_agent_host.h" +#include "content/common/notification_observer.h" +#include "content/common/notification_registrar.h" + +class RenderViewHost; + +class RenderViewDevToolsAgentHost : public DevToolsAgentHost, + public NotificationObserver { + public: + static DevToolsAgentHost* FindFor(RenderViewHost*); + + private: + RenderViewDevToolsAgentHost(RenderViewHost*); + virtual ~RenderViewDevToolsAgentHost(); + + // DevToolsAgentHost implementation. + virtual void SendMessageToAgent(IPC::Message* msg); + virtual void NotifyClientClosing(); + virtual int GetRenderProcessId(); + + // Overridden from NotificationObserver: + virtual void Observe(int type, + const NotificationSource& source, + const NotificationDetails& details); + + RenderViewHost* render_view_host_; + NotificationRegistrar registrar_; + + typedef std::map<RenderViewHost*, RenderViewDevToolsAgentHost*> Instances; + static Instances instances_; + + DISALLOW_COPY_AND_ASSIGN(RenderViewDevToolsAgentHost); +}; + +#endif // CONTENT_BROWSER_DEBUGGER_RENDER_VIEW_DEVTOOLS_AGENT_HOST_H_ diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 3387f86..258d589 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -79,6 +79,8 @@ 'browser/content_browser_client.h', 'browser/cross_site_request_manager.cc', 'browser/cross_site_request_manager.h', + 'browser/debugger/devtools_agent_host.cc', + 'browser/debugger/devtools_agent_host.h', 'browser/debugger/devtools_client_host.cc', 'browser/debugger/devtools_client_host.h', 'browser/debugger/devtools_handler.cc', @@ -89,6 +91,8 @@ 'browser/debugger/devtools_manager.h', 'browser/debugger/devtools_netlog_observer.cc', 'browser/debugger/devtools_netlog_observer.h', + 'browser/debugger/render_view_devtools_agent_host.cc', + 'browser/debugger/render_view_devtools_agent_host.h', 'browser/debugger/worker_devtools_manager_io.cc', 'browser/debugger/worker_devtools_manager_io.h', 'browser/debugger/worker_devtools_message_filter.cc', |