diff options
author | yurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-23 10:43:58 +0000 |
---|---|---|
committer | yurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-23 10:43:58 +0000 |
commit | 7aa27fdf4e135daef7f49a37a61e506c165ce214 (patch) | |
tree | 20005ed71165173cd988d655a9534765439848ef /chrome/browser/debugger/devtools_manager.h | |
parent | 7197f4999afa5e767fa9ed76fdc7e67db080f9d2 (diff) | |
download | chromium_src-7aa27fdf4e135daef7f49a37a61e506c165ce214.zip chromium_src-7aa27fdf4e135daef7f49a37a61e506c165ce214.tar.gz chromium_src-7aa27fdf4e135daef7f49a37a61e506c165ce214.tar.bz2 |
Currently we have two types of devtools UI: Chrome built in developer tools window and remote debugger connected over TCP(apavlov is working on it). To allow DevToolsManager coordinate both types of devtools uniformly their API is extracted into DevToolsClientHost interface.
Fix purify errors in DevToolsManager unit tests.
BUG=9150
Review URL: http://codereview.chromium.org/50009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12274 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/debugger/devtools_manager.h')
-rw-r--r-- | chrome/browser/debugger/devtools_manager.h | 108 |
1 files changed, 44 insertions, 64 deletions
diff --git a/chrome/browser/debugger/devtools_manager.h b/chrome/browser/debugger/devtools_manager.h index ce6ee73..fe1c803 100644 --- a/chrome/browser/debugger/devtools_manager.h +++ b/chrome/browser/debugger/devtools_manager.h @@ -9,104 +9,84 @@ #include "base/basictypes.h" #include "base/scoped_ptr.h" +#include "chrome/browser/debugger/devtools_client_host.h" #include "chrome/common/notification_service.h" namespace IPC { class Message; } -class DevToolsInstanceDescriptor; -class DevToolsInstanceDescriptorImpl; -class DevToolsWindow; -class DevToolsWindowFactory; +class DevToolsClientHost; class NavigationController; class NotificationRegistrar; class RenderViewHost; class WebContents; -// This class is a singleton that manages DevToolsWindow instances and routes -// messages between developer tools clients and agents. -class DevToolsManager : public NotificationObserver { +// This class is a singleton that manages DevToolsClientHost instances and +// routes messages between developer tools clients and agents. +class DevToolsManager : public NotificationObserver, + public DevToolsClientHost::CloseListener { public: - // If the factory is NULL, this will create DevToolsWindow objects using - // DevToolsWindow::Create static method. - DevToolsManager(DevToolsWindowFactory* factory); + DevToolsManager(); virtual ~DevToolsManager(); - // Opend developer tools window for |web_contents|. If there is already - // one it will be revealed otherwise a new instance will be created. The - // devtools window is actually opened for the tab owning |web_contents|. If - // navigation occurs in it causing change of contents in the tab the devtools - // window will attach to the new contents. When the tab is closed the manager - // will close related devtools window. - void ShowDevToolsForWebContents(WebContents* web_contents); + // Returns DevToolsClientHost registered for |web_contents| or NULL if + // there is no alive DevToolsClientHost registered for |web_contents|. + DevToolsClientHost* GetDevToolsClientHostFor(const WebContents& web_contents); - void ForwardToDevToolsAgent(RenderViewHost* from, + // Registers new DevToolsClientHost for |web_contents|. There must be no + // other DevToolsClientHosts registered for the WebContents at the moment. + void RegisterDevToolsClientHostFor(const WebContents& web_contents, + DevToolsClientHost* client_host); + + void ForwardToDevToolsAgent(const RenderViewHost& client_rvh, + const IPC::Message& message); + void ForwardToDevToolsAgent(const DevToolsClientHost& from, const IPC::Message& message); - void ForwardToDevToolsClient(RenderViewHost* from, + void ForwardToDevToolsClient(const RenderViewHost& from, const IPC::Message& message); private: - // Creates a DevToolsWindow using devtools_window_factory_ or by calling - // DevToolsWindow::Create, if the factory is NULL. All DevToolsWindows should - // be created by means of this method. - DevToolsWindow* CreateDevToolsWindow(DevToolsInstanceDescriptor* descriptor); - // NotificationObserver override. virtual void Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details); - friend class DevToolsInstanceDescriptorImpl; + // DevToolsClientHost::CloseListener override. + // This method will remove all references from the manager to the + // DevToolsClientHost and unregister all listeners related to the + // DevToolsClientHost. + virtual void ClientHostClosing(DevToolsClientHost* host); - // This method is called by DevToolsInstanceDescriptorImpl when it's about - // to be destroyed. It will remove all references from the manager to the - // descriptor and unregister all listeners related to the descriptor. - void RemoveDescriptor(DevToolsInstanceDescriptorImpl* descriptor); + // Returns NavigationController for the tab that is inspected by devtools + // client hosted by DevToolsClientHost. + NavigationController* GetDevToolsAgentNavigationController( + const DevToolsClientHost& client_host); void StartListening(NavigationController* navigation_controller); void StopListening(NavigationController* navigation_controller); - // This object is not NULL iff there is at least one open DevToolsWindow. + // This object is not NULL iff there is at least one registered + // DevToolsClientHost. scoped_ptr<NotificationRegistrar> web_contents_listeners_; - // This maps is for tracking devtools instances opened for browser tabs. It - // allows us to have at most one devtools window per tab. - // We use NavigationController* as key because it survives crosee-site - // navigation in cases when tab contents may change. + // These two maps are for tracking dependencies between inspected tabs and + // their DevToolsClientHosts. They are usful for routing devtools messages + // and allow us to have at most one devtools client host per tab. We use + // NavigationController* as key because it survives crosee-site navigation in + // cases when tab contents may change. // - // This map doesn't own its values but DevToolsInstanceDescriptorImpl is - // expected to call RemoveDescriptor before dying to remove itself from the - // map. - typedef std::map<NavigationController*, - DevToolsInstanceDescriptorImpl*> DescriptorMap; - DescriptorMap navcontroller_to_descriptor_; - DevToolsWindowFactory* devtools_window_factory_; - - DISALLOW_COPY_AND_ASSIGN(DevToolsManager); -}; + // DevToolsManager start listening to DevToolsClientHosts when they are put + // into these maps and removes them when they are closing. + typedef std::map<const NavigationController*, + DevToolsClientHost*> ClientHostMap; + ClientHostMap navcontroller_to_client_host_; + typedef std::map<const DevToolsClientHost*, + NavigationController*> NavControllerMap; + NavControllerMap client_host_to_navcontroller_; -// Incapsulates information about devtools window instance necessary for -// routing devtools messages and managing the window. It should be initialized -// by DevToolsWindow concrete implementation. -class DevToolsInstanceDescriptor { - public: - DevToolsInstanceDescriptor() {} - - virtual void SetDevToolsHost(RenderViewHost* render_view_host) = 0; - virtual void SetDevToolsWindow(DevToolsWindow* window) = 0; - - // This method is called when DevToolsWindow is closing and the descriptor - // becomes invalid. It will clean up DevToolsManager and delete this instance. - virtual void Destroy() = 0; - - protected: - // This method should be called from Destroy only. - virtual ~DevToolsInstanceDescriptor() {} - - private: - DISALLOW_COPY_AND_ASSIGN(DevToolsInstanceDescriptor); + DISALLOW_COPY_AND_ASSIGN(DevToolsManager); }; #endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ |