OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_DEBUGGER_DEVTOOLS_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ |
6 #define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ | 6 #define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/memory/ref_counted.h" | |
13 #include "content/browser/debugger/devtools_client_host.h" | 12 #include "content/browser/debugger/devtools_client_host.h" |
14 #include "content/common/notification_observer.h" | 13 #include "content/common/notification_observer.h" |
15 #include "content/common/notification_registrar.h" | 14 #include "content/common/notification_registrar.h" |
16 | 15 |
17 namespace IPC { | 16 namespace IPC { |
18 class Message; | 17 class Message; |
19 } | 18 } |
20 | 19 |
21 class DevToolsNetLogObserver; | 20 class DevToolsNetLogObserver; |
22 class GURL; | 21 class GURL; |
23 class IOThread; | 22 class IOThread; |
24 class PrefService; | 23 class PrefService; |
25 class RenderViewHost; | 24 class RenderViewHost; |
26 class TabContents; | 25 class TabContents; |
27 | 26 |
28 typedef std::map<std::string, std::string> DevToolsRuntimeProperties; | 27 typedef std::map<std::string, std::string> DevToolsRuntimeProperties; |
29 | 28 |
30 // This class is a singleton that manages DevToolsClientHost instances and | 29 // This class is a singleton that manages DevToolsClientHost instances and |
31 // routes messages between developer tools clients and agents. | 30 // routes messages between developer tools clients and agents. |
32 class DevToolsManager : public DevToolsClientHost::CloseListener, | 31 class DevToolsManager : public DevToolsClientHost::CloseListener, |
33 public NotificationObserver, | 32 public NotificationObserver { |
34 public base::RefCounted<DevToolsManager> { | |
35 public: | 33 public: |
36 static DevToolsManager* GetInstance(); | 34 static DevToolsManager* GetInstance(); |
37 | 35 |
38 DevToolsManager(); | 36 DevToolsManager(); |
| 37 virtual ~DevToolsManager(); |
39 | 38 |
40 // Returns DevToolsClientHost registered for |inspected_rvh| or NULL if | 39 // Returns DevToolsClientHost registered for |inspected_rvh| or NULL if |
41 // there is no alive DevToolsClientHost registered for |inspected_rvh|. | 40 // there is no alive DevToolsClientHost registered for |inspected_rvh|. |
42 DevToolsClientHost* GetDevToolsClientHostFor(RenderViewHost* inspected_rvh); | 41 DevToolsClientHost* GetDevToolsClientHostFor(RenderViewHost* inspected_rvh); |
43 | 42 |
44 // Registers new DevToolsClientHost for |inspected_rvh|. There must be no | 43 // Registers new DevToolsClientHost for |inspected_rvh|. There must be no |
45 // other DevToolsClientHosts registered for the RenderViewHost at the moment. | 44 // other DevToolsClientHosts registered for the RenderViewHost at the moment. |
46 void RegisterDevToolsClientHostFor(RenderViewHost* inspected_rvh, | 45 void RegisterDevToolsClientHostFor(RenderViewHost* inspected_rvh, |
47 DevToolsClientHost* client_host); | 46 DevToolsClientHost* client_host); |
48 void UnregisterDevToolsClientHostFor(RenderViewHost* inspected_rvh); | 47 void UnregisterDevToolsClientHostFor(RenderViewHost* inspected_rvh); |
(...skipping 25 matching lines...) Expand all Loading... |
74 int DetachClientHost(RenderViewHost* from_rvh); | 73 int DetachClientHost(RenderViewHost* from_rvh); |
75 | 74 |
76 // Attaches orphan client host to new render view host. | 75 // Attaches orphan client host to new render view host. |
77 void AttachClientHost(int client_host_cookie, | 76 void AttachClientHost(int client_host_cookie, |
78 RenderViewHost* to_rvh); | 77 RenderViewHost* to_rvh); |
79 | 78 |
80 // Closes all open developer tools windows. | 79 // Closes all open developer tools windows. |
81 void CloseAllClientHosts(); | 80 void CloseAllClientHosts(); |
82 | 81 |
83 private: | 82 private: |
84 friend class base::RefCounted<DevToolsManager>; | |
85 | |
86 virtual ~DevToolsManager(); | |
87 | |
88 // DevToolsClientHost::CloseListener override. | 83 // DevToolsClientHost::CloseListener override. |
89 // This method will remove all references from the manager to the | 84 // This method will remove all references from the manager to the |
90 // DevToolsClientHost and unregister all listeners related to the | 85 // DevToolsClientHost and unregister all listeners related to the |
91 // DevToolsClientHost. | 86 // DevToolsClientHost. |
92 virtual void ClientHostClosing(DevToolsClientHost* host); | 87 virtual void ClientHostClosing(DevToolsClientHost* host); |
93 | 88 |
94 // Overridden from NotificationObserver: | 89 // Overridden from NotificationObserver: |
95 virtual void Observe(int type, | 90 virtual void Observe(int type, |
96 const NotificationSource& source, | 91 const NotificationSource& source, |
97 const NotificationDetails& details); | 92 const NotificationDetails& details); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 OrphanClientHosts; | 128 OrphanClientHosts; |
134 OrphanClientHosts orphan_client_hosts_; | 129 OrphanClientHosts orphan_client_hosts_; |
135 int last_orphan_cookie_; | 130 int last_orphan_cookie_; |
136 | 131 |
137 NotificationRegistrar registrar_; | 132 NotificationRegistrar registrar_; |
138 | 133 |
139 DISALLOW_COPY_AND_ASSIGN(DevToolsManager); | 134 DISALLOW_COPY_AND_ASSIGN(DevToolsManager); |
140 }; | 135 }; |
141 | 136 |
142 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ | 137 #endif // CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_H_ |
OLD | NEW |