OLD | NEW |
---|---|
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_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_H_ |
6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | |
9 | 10 |
10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "base/observer_list.h" | |
13 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
14 #include "content/public/browser/devtools_manager_delegate.h" | 16 #include "content/public/browser/devtools_manager_delegate.h" |
15 | 17 |
16 namespace content { | 18 namespace content { |
17 | 19 |
18 class DevToolsAgentHostImpl; | 20 class DevToolsAgentHostImpl; |
19 class DevToolsHttpHandler; | 21 class DevToolsHttpHandler; |
22 class WebContentsImpl; | |
20 | 23 |
21 // This class is a singleton that manage global DevTools state for the whole | 24 // This class is a singleton that manage global DevTools state for the whole |
22 // browser. | 25 // browser. |
23 // TODO(dgozman): remove this class entirely. | |
24 class CONTENT_EXPORT DevToolsManager { | 26 class CONTENT_EXPORT DevToolsManager { |
25 public: | 27 public: |
26 // Returns single instance of this class. The instance is destroyed on the | 28 // Returns single instance of this class. The instance is destroyed on the |
27 // browser main loop exit so this method MUST NOT be called after that point. | 29 // browser main loop exit so this method MUST NOT be called after that point. |
28 static DevToolsManager* GetInstance(); | 30 static DevToolsManager* GetInstance(); |
29 | 31 |
32 class Observer { | |
33 public: | |
34 virtual void AgentHostCreated(DevToolsAgentHostImpl* agent_host) {} | |
35 virtual void AgentHostDestroyed(DevToolsAgentHostImpl* agent_host) {} | |
36 virtual ~Observer() {} | |
37 }; | |
38 | |
30 DevToolsManager(); | 39 DevToolsManager(); |
31 virtual ~DevToolsManager(); | 40 virtual ~DevToolsManager(); |
32 | 41 |
33 DevToolsManagerDelegate* delegate() const { return delegate_.get(); } | 42 void AddObserver(Observer* observer); |
43 void RemoveObserver(Observer* observer); | |
34 | 44 |
45 DevToolsManagerDelegate* GetDelegate(); | |
46 | |
47 void WebContentsCreated(WebContentsImpl* web_contents); | |
pfeldman
2016/10/12 23:11:18
These seem random / hacky.
dgozman
2016/10/12 23:23:12
Any ideas?
| |
48 void AgentHostCreated(DevToolsAgentHostImpl* agent_host); | |
49 void AgentHostDestroyed(DevToolsAgentHostImpl* agent_host); | |
35 void AgentHostStateChanged(DevToolsAgentHostImpl* agent_host, bool attached); | 50 void AgentHostStateChanged(DevToolsAgentHostImpl* agent_host, bool attached); |
36 | 51 |
37 void SetHttpHandler(std::unique_ptr<DevToolsHttpHandler> http_handler); | 52 void SetHttpHandler(std::unique_ptr<DevToolsHttpHandler> http_handler); |
38 | 53 |
39 private: | 54 private: |
40 friend struct base::DefaultSingletonTraits<DevToolsManager>; | 55 friend struct base::DefaultSingletonTraits<DevToolsManager>; |
41 | 56 |
57 bool delegate_initialized_; | |
42 std::unique_ptr<DevToolsManagerDelegate> delegate_; | 58 std::unique_ptr<DevToolsManagerDelegate> delegate_; |
43 std::unique_ptr<DevToolsHttpHandler> http_handler_; | 59 std::unique_ptr<DevToolsHttpHandler> http_handler_; |
44 int attached_hosts_count_; | 60 int attached_hosts_count_; |
61 std::set<DevToolsAgentHostImpl*> agent_hosts_; | |
62 base::ObserverList<Observer> observers_; | |
45 | 63 |
46 DISALLOW_COPY_AND_ASSIGN(DevToolsManager); | 64 DISALLOW_COPY_AND_ASSIGN(DevToolsManager); |
47 }; | 65 }; |
48 | 66 |
49 } // namespace content | 67 } // namespace content |
50 | 68 |
51 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_H_ | 69 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_H_ |
OLD | NEW |