Chromium Code Reviews| Index: content/browser/debugger/devtools_manager_impl.h |
| diff --git a/content/browser/debugger/devtools_manager.h b/content/browser/debugger/devtools_manager_impl.h |
| similarity index 60% |
| rename from content/browser/debugger/devtools_manager.h |
| rename to content/browser/debugger/devtools_manager_impl.h |
| index 1801d0c1eb5638bd7772d52b6a4a1a33ec1caf3f..1bb4d0e2f14cccb1c2b10d7b4f9037aa5e271820 100644 |
| --- a/content/browser/debugger/devtools_manager.h |
| +++ b/content/browser/debugger/devtools_manager_impl.h |
| @@ -2,19 +2,22 @@ |
| // 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_MANAGER_H_ |
| -#define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ |
| +#ifndef CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_IMPL_H_ |
| +#define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_IMPL_H_ |
| #pragma once |
| #include <map> |
| #include <string> |
| #include "base/compiler_specific.h" |
| +#include "base/memory/singleton.h" |
| #include "content/browser/debugger/devtools_agent_host.h" |
| -#include "content/browser/debugger/devtools_client_host.h" |
| #include "content/common/content_export.h" |
| +#include "content/public/browser/devtools/devtools_client_host.h" |
| +#include "content/public/browser/devtools/devtools_manager.h" |
| +#include "content/public/browser/notification_observer.h" |
| +#include "content/public/browser/notification_registrar.h" |
| -class DevToolsAgentHost; |
| class GURL; |
| class RenderViewHost; |
| class TabContents; |
| @@ -23,33 +26,31 @@ namespace IPC { |
| class Message; |
| } |
| +namespace content { |
| + |
| +class DevToolsAgentHost; |
| + |
| // 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 CONTENT_EXPORT DevToolsManager |
| +class CONTENT_EXPORT DevToolsManagerImpl |
| : public DevToolsClientHost::CloseListener, |
| - public DevToolsAgentHost::CloseListener { |
| + public DevToolsAgentHost::CloseListener, |
| + public NotificationObserver, |
| + public DevToolsManager { |
| public: |
| - static DevToolsManager* GetInstance(); |
| - |
| - DevToolsManager(); |
| - virtual ~DevToolsManager(); |
| + // Returns single instance of this class. The instance is destroyed on the |
| + // browser main loop exit so this method MUST NOT be called after that point. |
| + static DevToolsManagerImpl* GetInstance(); |
| - // Returns DevToolsClientHost registered for |inspected_rvh| or NULL if |
| - // there is no alive DevToolsClientHost registered for |inspected_rvh|. |
| - DevToolsClientHost* GetDevToolsClientHostFor(RenderViewHost* inspected_rvh); |
| + DevToolsManagerImpl(); |
| + virtual ~DevToolsManagerImpl(); |
| - // Registers new DevToolsClientHost for |inspected_rvh|. There must be no |
| - // other DevToolsClientHosts registered for the RenderViewHost at the moment. |
| - void RegisterDevToolsClientHostFor(RenderViewHost* inspected_rvh, |
| - DevToolsClientHost* client_host); |
| - void UnregisterDevToolsClientHostFor(RenderViewHost* inspected_rvh); |
| - |
| - bool ForwardToDevToolsAgent(DevToolsClientHost* from, |
| - const IPC::Message& message); |
| + virtual bool ForwardToDevToolsAgent(DevToolsClientHost* from, |
| + const IPC::Message& message) OVERRIDE; |
| void ForwardToDevToolsClient(DevToolsAgentHost* agent_host, |
| const IPC::Message& message); |
| @@ -66,28 +67,25 @@ class CONTENT_EXPORT DevToolsManager |
| // Invoked when a tab is replaced by another tab. This is triggered by |
| // TabStripModel::ReplaceTabContentsAt. |
| - void TabReplaced(TabContents* old_tab, TabContents* new_tab); |
| - |
| - // Detaches client host and returns cookie that can be used in |
| - // AttachClientHost. |
| - int DetachClientHost(RenderViewHost* from_rvh); |
| - |
| - // Attaches orphan client host to new render view host. |
| - void AttachClientHost(int client_host_cookie, |
| - RenderViewHost* to_rvh); |
| + virtual void TabReplaced(TabContents* old_tab, TabContents* new_tab) OVERRIDE; |
| // Closes all open developer tools windows. |
| - void CloseAllClientHosts(); |
| - |
| - void AttachClientHost(int client_host_cookie, |
| - DevToolsAgentHost* to_agent); |
| - DevToolsClientHost* GetDevToolsClientHostFor(DevToolsAgentHost* agent_host); |
| - void RegisterDevToolsClientHostFor(DevToolsAgentHost* agent_host, |
| - DevToolsClientHost* client_host); |
| - void UnregisterDevToolsClientHostFor(DevToolsAgentHost* agent_host); |
| - int DetachClientHost(DevToolsAgentHost* from_agent); |
| + virtual void CloseAllClientHosts() OVERRIDE; |
| + |
| + virtual void AttachClientHost(int client_host_cookie, |
| + DevToolsAgentHost* to_agent) OVERRIDE; |
| + virtual DevToolsClientHost* GetDevToolsClientHostFor( |
| + DevToolsAgentHost* agent_host) OVERRIDE; |
| + virtual void RegisterDevToolsClientHostFor( |
| + DevToolsAgentHost* agent_host, |
| + DevToolsClientHost* client_host) OVERRIDE; |
| + virtual void UnregisterDevToolsClientHostFor( |
| + DevToolsAgentHost* agent_host) OVERRIDE; |
| + virtual int DetachClientHost(DevToolsAgentHost* from_agent) OVERRIDE; |
| private: |
| + friend struct DefaultSingletonTraits<DevToolsManagerImpl>; |
| + |
| // DevToolsClientHost::CloseListener override. |
| // This method will remove all references from the manager to the |
| // DevToolsClientHost and unregister all listeners related to the |
| @@ -97,6 +95,11 @@ class CONTENT_EXPORT DevToolsManager |
| // DevToolsAgentHost::CloseListener implementation. |
| virtual void AgentHostClosing(DevToolsAgentHost* host) OVERRIDE; |
| + // NotificationObserver implementation. |
| + virtual void Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) OVERRIDE; |
| + |
| // Returns DevToolsAgentHost inspected by the DevToolsClientHost. |
| DevToolsAgentHost* GetAgentHost(DevToolsClientHost* client_host); |
| @@ -105,12 +108,16 @@ class CONTENT_EXPORT DevToolsManager |
| void UnbindClientHost(DevToolsAgentHost* agent_host, |
| DevToolsClientHost* client_host); |
| + int DetachClientHost(RenderViewHost* from_rvh); |
|
pfeldman
2011/11/21 14:52:21
Could you leave comments to these methods?
yurys
2011/11/21 15:07:14
Done.
|
| + void AttachClientHost(int client_host_cookie, |
| + RenderViewHost* to_rvh); |
| + |
| // These two maps are for tracking dependencies between inspected tabs and |
| // their DevToolsClientHosts. They are useful for routing devtools messages |
| // and allow us to have at most one devtools client host per tab. |
| // |
| - // DevToolsManager start listening to DevToolsClientHosts when they are put |
| - // into these maps and removes them when they are closing. |
| + // DevToolsManagerImpl starts listening to DevToolsClientHosts when they are |
| + // put into these maps and removes them when they are closing. |
| typedef std::map<DevToolsAgentHost*, DevToolsClientHost*> |
| AgentToClientHostMap; |
| AgentToClientHostMap agent_to_client_host_; |
| @@ -126,8 +133,11 @@ class CONTENT_EXPORT DevToolsManager |
| OrphanClientHosts; |
| OrphanClientHosts orphan_client_hosts_; |
| int last_orphan_cookie_; |
| + content::NotificationRegistrar notification_registrar_; |
| - DISALLOW_COPY_AND_ASSIGN(DevToolsManager); |
| + DISALLOW_COPY_AND_ASSIGN(DevToolsManagerImpl); |
| }; |
| -#endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_IMPL_H_ |