Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: content/browser/devtools/devtools_manager_impl.h

Issue 449043002: [DevTools] Make DevTools clients talk directly to DevToolsAgentHost instead of using DevToolsManage… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_IMPL_H_ 5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_IMPL_H_
6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_IMPL_H_ 6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "content/browser/devtools/devtools_agent_host_impl.h"
15 #include "content/common/content_export.h"
16 #include "content/public/browser/devtools_client_host.h"
17 #include "content/public/browser/devtools_manager.h"
18
19 class GURL;
20
21 namespace IPC {
22 class Message;
23 }
24 14
25 namespace content { 15 namespace content {
26 16
27 class BrowserContext;
28 class DevToolsManagerDelegate; 17 class DevToolsManagerDelegate;
29 class RenderViewHost;
30 18
31 // This class is a singleton that manages DevToolsClientHost instances and 19 // This class is a singleton that manage global DevTools state for the whole
32 // routes messages between developer tools clients and agents. 20 // browser.
33 // 21 class DevToolsManagerImpl {
34 // Methods below that accept inspected RenderViewHost as a parameter are
35 // just convenience methods that call corresponding methods accepting
36 // DevToolAgentHost.
37 class CONTENT_EXPORT DevToolsManagerImpl
38 : public DevToolsAgentHostImpl::CloseListener,
39 public DevToolsManager {
40 public: 22 public:
41 // Returns single instance of this class. The instance is destroyed on the 23 // Returns single instance of this class. The instance is destroyed on the
42 // browser main loop exit so this method MUST NOT be called after that point. 24 // browser main loop exit so this method MUST NOT be called after that point.
43 static DevToolsManagerImpl* GetInstance(); 25 static DevToolsManagerImpl* GetInstance();
44 26
45 DevToolsManagerImpl(); 27 DevToolsManagerImpl();
46 virtual ~DevToolsManagerImpl(); 28 virtual ~DevToolsManagerImpl();
47 29
48 // Opens the inspector for |agent_host|.
49 void Inspect(BrowserContext* browser_context, DevToolsAgentHost* agent_host);
50
51 void DispatchOnInspectorFrontend(DevToolsAgentHost* agent_host,
52 const std::string& message);
53
54 DevToolsManagerDelegate* delegate() const { return delegate_.get(); } 30 DevToolsManagerDelegate* delegate() const { return delegate_.get(); }
55 31 void OnClientAttached();
56 // DevToolsManager implementation 32 void OnClientDetached();
57 virtual bool DispatchOnInspectorBackend(DevToolsClientHost* from,
58 const std::string& message) OVERRIDE;
59 virtual void CloseAllClientHosts() OVERRIDE;
60 virtual DevToolsAgentHost* GetDevToolsAgentHostFor(
61 DevToolsClientHost* client_host) OVERRIDE;
62 virtual void RegisterDevToolsClientHostFor(
63 DevToolsAgentHost* agent_host,
64 DevToolsClientHost* client_host) OVERRIDE;
65 virtual void ClientHostClosing(DevToolsClientHost* host) OVERRIDE;
66 virtual void AddAgentStateCallback(const Callback& callback) OVERRIDE;
67 virtual void RemoveAgentStateCallback(const Callback& callback) OVERRIDE;
68 33
69 private: 34 private:
70 friend class DevToolsAgentHostImpl;
71 friend class RenderViewDevToolsAgentHost;
72 friend struct DefaultSingletonTraits<DevToolsManagerImpl>; 35 friend struct DefaultSingletonTraits<DevToolsManagerImpl>;
73 36
74 // DevToolsAgentHost::CloseListener implementation.
75 virtual void AgentHostClosing(DevToolsAgentHostImpl* host) OVERRIDE;
76
77 void BindClientHost(DevToolsAgentHostImpl* agent_host,
78 DevToolsClientHost* client_host);
79 void UnbindClientHost(DevToolsAgentHostImpl* agent_host,
80 DevToolsClientHost* client_host);
81
82 DevToolsClientHost* GetDevToolsClientHostFor(
83 DevToolsAgentHostImpl* agent_host);
84
85 void UnregisterDevToolsClientHostFor(DevToolsAgentHostImpl* agent_host);
86
87 void NotifyObservers(DevToolsAgentHost* agent_host, bool attached);
88
89 // These two maps are for tracking dependencies between inspected contents and
90 // their DevToolsClientHosts. They are useful for routing devtools messages
91 // and allow us to have at most one devtools client host per contents.
92 //
93 // DevToolsManagerImpl starts listening to DevToolsClientHosts when they are
94 // put into these maps and removes them when they are closing.
95 typedef std::map<DevToolsAgentHostImpl*, DevToolsClientHost*>
96 AgentToClientHostMap;
97 AgentToClientHostMap agent_to_client_host_;
98
99 typedef std::map<DevToolsClientHost*, scoped_refptr<DevToolsAgentHostImpl> >
100 ClientToAgentHostMap;
101 ClientToAgentHostMap client_to_agent_host_;
102
103 typedef std::vector<const Callback*> CallbackContainer;
104 CallbackContainer callbacks_;
105
106 scoped_ptr<DevToolsManagerDelegate> delegate_; 37 scoped_ptr<DevToolsManagerDelegate> delegate_;
38 int client_count_;
107 39
108 DISALLOW_COPY_AND_ASSIGN(DevToolsManagerImpl); 40 DISALLOW_COPY_AND_ASSIGN(DevToolsManagerImpl);
109 }; 41 };
110 42
111 } // namespace content 43 } // namespace content
112 44
113 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_IMPL_H_ 45 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698