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 <map> | 8 #include <map> |
9 #include <set> | |
9 #include <string> | 10 #include <string> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
13 #include "base/cancelable_callback.h" | |
12 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
13 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
16 #include "base/observer_list.h" | |
17 #include "content/public/browser/devtools_manager_delegate.h" | |
14 | 18 |
15 namespace content { | 19 namespace content { |
16 | 20 |
17 class DevToolsManagerDelegate; | 21 class DevToolsAgentHost; |
22 class RenderViewHost; | |
23 class WebContents; | |
18 | 24 |
19 // This class is a singleton that manage global DevTools state for the whole | 25 // This class is a singleton that manage global DevTools state for the whole |
20 // browser. | 26 // browser. |
21 class DevToolsManager { | 27 class DevToolsManager { |
22 public: | 28 public: |
29 class Observer { | |
pfeldman
2014/09/22 16:16:50
This is something in between of listener and obser
dgozman
2014/09/24 13:18:28
I've added all empty implementations, and left thi
| |
30 public: | |
31 virtual ~Observer() {} | |
32 | |
33 typedef DevToolsManagerDelegate::TargetList TargetList; | |
34 | |
35 // Called when any target information changed. | |
36 virtual void TargetListChanged(const TargetList& targets) = 0; | |
37 }; | |
38 | |
23 // Returns single instance of this class. The instance is destroyed on the | 39 // Returns single instance of this class. The instance is destroyed on the |
24 // browser main loop exit so this method MUST NOT be called after that point. | 40 // browser main loop exit so this method MUST NOT be called after that point. |
25 static DevToolsManager* GetInstance(); | 41 static DevToolsManager* GetInstance(); |
26 | 42 |
27 DevToolsManager(); | 43 DevToolsManager(); |
28 virtual ~DevToolsManager(); | 44 virtual ~DevToolsManager(); |
29 | 45 |
30 DevToolsManagerDelegate* delegate() const { return delegate_.get(); } | 46 DevToolsManagerDelegate* delegate() const { return delegate_.get(); } |
31 void OnClientAttached(); | 47 |
32 void OnClientDetached(); | 48 void AddObserver(Observer* observer); |
49 void RemoveObserver(Observer* observer); | |
50 | |
51 void RenderViewCreated(WebContents* web_contents, RenderViewHost* rvh); | |
52 void AgentHostChanged(scoped_refptr<DevToolsAgentHost> agent_host); | |
53 | |
54 static void SetObserverThrottleIntervalForTest(base::TimeDelta interval); | |
33 | 55 |
34 private: | 56 private: |
35 friend struct DefaultSingletonTraits<DevToolsManager>; | 57 friend struct DefaultSingletonTraits<DevToolsManager>; |
36 | 58 |
59 void UpdateTargetList(); | |
60 void UpdateTargetListThrottled(); | |
61 void NotifyTargetListChanged(const Observer::TargetList& targets); | |
62 | |
37 scoped_ptr<DevToolsManagerDelegate> delegate_; | 63 scoped_ptr<DevToolsManagerDelegate> delegate_; |
38 int client_count_; | 64 ObserverList<Observer> observer_list_; |
65 std::set<DevToolsAgentHost*> attached_hosts_; | |
66 bool update_target_list_required_; | |
67 bool update_target_list_scheduled_; | |
68 base::CancelableClosure update_target_list_callback_; | |
69 | |
70 static base::TimeDelta observer_throttle_interval_; | |
39 | 71 |
40 DISALLOW_COPY_AND_ASSIGN(DevToolsManager); | 72 DISALLOW_COPY_AND_ASSIGN(DevToolsManager); |
41 }; | 73 }; |
42 | 74 |
43 } // namespace content | 75 } // namespace content |
44 | 76 |
45 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_H_ | 77 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_H_ |
OLD | NEW |