| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_WORKER_DEVTOOLS_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_MANAGER_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 #include "content/public/browser/devtools_agent_host.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 class DevToolsAgentHost; | |
| 19 class DevToolsAgentHostImpl; | 19 class DevToolsAgentHostImpl; |
| 20 class WorkerDevToolsAgentHost; | 20 class WorkerDevToolsAgentHost; |
| 21 | 21 |
| 22 // A base class of SharedWorkerDevToolsManager and ServiceWorkerDevToolsManager, | 22 // A base class of SharedWorkerDevToolsManager and ServiceWorkerDevToolsManager, |
| 23 // provides common default implementation for them. | 23 // provides common default implementation for them. |
| 24 // This class lives on UI thread. | 24 // This class lives on UI thread. |
| 25 class CONTENT_EXPORT WorkerDevToolsManager { | 25 class CONTENT_EXPORT WorkerDevToolsManager { |
| 26 public: | 26 public: |
| 27 typedef std::pair<int, int> WorkerId; | 27 typedef std::pair<int, int> WorkerId; |
| 28 | 28 |
| 29 class Observer { | 29 class Observer { |
| 30 public: | 30 public: |
| 31 virtual void WorkerCreated(DevToolsAgentHost* host) {} | 31 virtual void WorkerCreated(DevToolsAgentHost* host) {} |
| 32 virtual void WorkerDestroyed(DevToolsAgentHost* host) {} | 32 virtual void WorkerDestroyed(DevToolsAgentHost* host) {} |
| 33 | 33 |
| 34 protected: | 34 protected: |
| 35 virtual ~Observer() {} | 35 virtual ~Observer() {} |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 DevToolsAgentHostImpl* GetDevToolsAgentHostForWorker(int worker_process_id, | 38 DevToolsAgentHostImpl* GetDevToolsAgentHostForWorker(int worker_process_id, |
| 39 int worker_route_id); | 39 int worker_route_id); |
| 40 void AddAllAgentHosts(std::vector<scoped_refptr<DevToolsAgentHost>>* result); | 40 void AddAllAgentHosts(DevToolsAgentHost::List* result); |
| 41 void WorkerReadyForInspection(int worker_process_id, int worker_route_id); | 41 void WorkerReadyForInspection(int worker_process_id, int worker_route_id); |
| 42 void WorkerDestroyed(int worker_process_id, int worker_route_id); | 42 void WorkerDestroyed(int worker_process_id, int worker_route_id); |
| 43 | 43 |
| 44 void AddObserver(Observer* observer); | 44 void AddObserver(Observer* observer); |
| 45 void RemoveObserver(Observer* observer); | 45 void RemoveObserver(Observer* observer); |
| 46 | 46 |
| 47 protected: | 47 protected: |
| 48 using AgentHostMap = std::map<WorkerId, WorkerDevToolsAgentHost*>; | 48 using AgentHostMap = std::map<WorkerId, WorkerDevToolsAgentHost*>; |
| 49 friend class SharedWorkerDevToolsManagerTest; | 49 friend class SharedWorkerDevToolsManagerTest; |
| 50 | 50 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 61 void ResetForTesting(); | 61 void ResetForTesting(); |
| 62 | 62 |
| 63 ObserverList<Observer> observer_list_; | 63 ObserverList<Observer> observer_list_; |
| 64 AgentHostMap workers_; | 64 AgentHostMap workers_; |
| 65 DISALLOW_COPY_AND_ASSIGN(WorkerDevToolsManager); | 65 DISALLOW_COPY_AND_ASSIGN(WorkerDevToolsManager); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 } // namespace content | 68 } // namespace content |
| 69 | 69 |
| 70 #endif // CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_MANAGER_H_ | 70 #endif // CONTENT_BROWSER_DEVTOOLS_WORKER_DEVTOOLS_MANAGER_H_ |
| OLD | NEW |