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.h

Issue 591313006: Revert of [DevTools] Implement DevToolsManager::Observer which notifies about target updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-enumerate-to-dtm-delegate
Patch Set: Created 6 years, 2 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
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_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>
10 #include <string> 9 #include <string>
11 #include <vector> 10 #include <vector>
12 11
13 #include "base/cancelable_callback.h"
14 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
15 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
16 #include "base/observer_list.h"
17 #include "content/common/content_export.h"
18 #include "content/public/browser/devtools_manager_delegate.h"
19 14
20 namespace content { 15 namespace content {
21 16
22 class DevToolsAgentHost; 17 class DevToolsManagerDelegate;
23 class RenderViewHost;
24 class WebContents;
25 18
26 // This class is a singleton that manage global DevTools state for the whole 19 // This class is a singleton that manage global DevTools state for the whole
27 // browser. 20 // browser.
28 class CONTENT_EXPORT DevToolsManager { 21 class DevToolsManager {
29 public: 22 public:
30 class Observer {
31 public:
32 virtual ~Observer() {}
33
34 typedef DevToolsManagerDelegate::TargetList TargetList;
35
36 // Called when any target information changed.
37 virtual void TargetListChanged(const TargetList& targets) {}
38 };
39
40 // 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
41 // 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.
42 static DevToolsManager* GetInstance(); 25 static DevToolsManager* GetInstance();
43 26
44 DevToolsManager(); 27 DevToolsManager();
45 virtual ~DevToolsManager(); 28 virtual ~DevToolsManager();
46 29
47 DevToolsManagerDelegate* delegate() const { return delegate_.get(); } 30 DevToolsManagerDelegate* delegate() const { return delegate_.get(); }
48 31 void OnClientAttached();
49 void AddObserver(Observer* observer); 32 void OnClientDetached();
50 void RemoveObserver(Observer* observer);
51
52 void RenderViewCreated(WebContents* web_contents, RenderViewHost* rvh);
53 void AgentHostChanged(scoped_refptr<DevToolsAgentHost> agent_host);
54
55 static void SetObserverThrottleIntervalForTest(base::TimeDelta interval);
56 33
57 private: 34 private:
58 friend struct DefaultSingletonTraits<DevToolsManager>; 35 friend struct DefaultSingletonTraits<DevToolsManager>;
59 36
60 void UpdateTargetList();
61 void UpdateTargetListThrottled();
62 void NotifyTargetListChanged(const Observer::TargetList& targets);
63
64 scoped_ptr<DevToolsManagerDelegate> delegate_; 37 scoped_ptr<DevToolsManagerDelegate> delegate_;
65 ObserverList<Observer> observer_list_; 38 int client_count_;
66 std::set<DevToolsAgentHost*> attached_hosts_;
67 bool update_target_list_required_;
68 bool update_target_list_scheduled_;
69 base::CancelableClosure update_target_list_callback_;
70
71 static base::TimeDelta observer_throttle_interval_;
72 39
73 DISALLOW_COPY_AND_ASSIGN(DevToolsManager); 40 DISALLOW_COPY_AND_ASSIGN(DevToolsManager);
74 }; 41 };
75 42
76 } // namespace content 43 } // namespace content
77 44
78 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_H_ 45 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_MANAGER_H_
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_agent_host_impl.cc ('k') | content/browser/devtools/devtools_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698