Chromium Code Reviews| 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_SHARED_WORKER_DEVTOOLS_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_SHARED_WORKER_DEVTOOLS_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_DEVTOOLS_SHARED_WORKER_DEVTOOLS_MANAGER_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_SHARED_WORKER_DEVTOOLS_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 9 | |
| 8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 9 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 10 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 11 #include "content/browser/devtools/worker_devtools_manager.h" | 13 #include "content/public/browser/devtools_agent_host.h" |
| 12 | 14 |
| 13 namespace content { | 15 namespace content { |
| 14 | 16 |
| 17 class DevToolsAgentHostImpl; | |
| 15 class SharedWorkerDevToolsAgentHost; | 18 class SharedWorkerDevToolsAgentHost; |
| 16 class SharedWorkerInstance; | 19 class SharedWorkerInstance; |
| 17 | 20 |
| 18 // Manages WorkerDevToolsAgentHost's for Shared Workers. | 21 // Manages WorkerDevToolsAgentHost's for Shared Workers. |
| 19 // This class lives on UI thread. | 22 // This class lives on UI thread. |
| 20 class CONTENT_EXPORT SharedWorkerDevToolsManager | 23 class CONTENT_EXPORT SharedWorkerDevToolsManager { |
| 21 : public WorkerDevToolsManager { | |
| 22 public: | 24 public: |
| 25 typedef std::pair<int, int> WorkerId; | |
| 26 | |
| 23 // Returns the SharedWorkerDevToolsManager singleton. | 27 // Returns the SharedWorkerDevToolsManager singleton. |
| 24 static SharedWorkerDevToolsManager* GetInstance(); | 28 static SharedWorkerDevToolsManager* GetInstance(); |
| 25 | 29 |
| 30 DevToolsAgentHostImpl* GetDevToolsAgentHostForWorker(int worker_process_id, | |
|
dgozman
2015/03/07 20:46:40
SharedWorkerDevToolsAgentHost*
pfeldman
2015/03/08 12:17:28
Clients don't need it to be that specific, you onl
| |
| 31 int worker_route_id); | |
| 32 void AddAllAgentHosts(DevToolsAgentHost::List* result); | |
| 33 | |
| 26 // Returns true when the worker must be paused on start because a DevTool | 34 // Returns true when the worker must be paused on start because a DevTool |
| 27 // window for the same former SharedWorkerInstance is still opened. | 35 // window for the same former SharedWorkerInstance is still opened. |
| 28 bool WorkerCreated(int worker_process_id, | 36 bool WorkerCreated(int worker_process_id, |
| 29 int worker_route_id, | 37 int worker_route_id, |
| 30 const SharedWorkerInstance& instance); | 38 const SharedWorkerInstance& instance); |
| 39 void WorkerReadyForInspection(int worker_process_id, int worker_route_id); | |
|
dgozman
2015/03/07 20:46:40
Same comment regarding public vs. private.
pfeldman
2015/03/08 12:17:28
Ditto
| |
| 40 void WorkerDestroyed(int worker_process_id, int worker_route_id); | |
| 41 void RemoveInspectedWorkerData(WorkerId id); | |
| 31 | 42 |
| 32 private: | 43 private: |
| 33 friend struct DefaultSingletonTraits<SharedWorkerDevToolsManager>; | 44 friend struct DefaultSingletonTraits<SharedWorkerDevToolsManager>; |
| 34 friend class SharedWorkerDevToolsAgentHost; | 45 friend class SharedWorkerDevToolsAgentHost; |
| 35 friend class SharedWorkerDevToolsManagerTest; | 46 friend class SharedWorkerDevToolsManagerTest; |
| 36 FRIEND_TEST_ALL_PREFIXES(SharedWorkerDevToolsManagerTest, BasicTest); | 47 FRIEND_TEST_ALL_PREFIXES(SharedWorkerDevToolsManagerTest, BasicTest); |
| 37 FRIEND_TEST_ALL_PREFIXES(SharedWorkerDevToolsManagerTest, AttachTest); | 48 FRIEND_TEST_ALL_PREFIXES(SharedWorkerDevToolsManagerTest, AttachTest); |
| 38 | 49 |
| 50 using AgentHostMap = std::map<WorkerId, SharedWorkerDevToolsAgentHost*>; | |
| 51 | |
| 39 SharedWorkerDevToolsManager(); | 52 SharedWorkerDevToolsManager(); |
| 40 ~SharedWorkerDevToolsManager() override; | 53 ~SharedWorkerDevToolsManager(); |
| 41 | 54 |
| 42 AgentHostMap::iterator FindExistingWorkerAgentHost( | 55 AgentHostMap::iterator FindExistingWorkerAgentHost( |
| 43 const SharedWorkerInstance& instance); | 56 const SharedWorkerInstance& instance); |
| 44 | 57 |
| 58 // Resets to its initial state as if newly created. | |
| 59 void ResetForTesting(); | |
| 60 | |
| 61 AgentHostMap workers_; | |
| 45 DISALLOW_COPY_AND_ASSIGN(SharedWorkerDevToolsManager); | 62 DISALLOW_COPY_AND_ASSIGN(SharedWorkerDevToolsManager); |
| 46 }; | 63 }; |
| 47 | 64 |
| 48 } // namespace content | 65 } // namespace content |
| 49 | 66 |
| 50 #endif // CONTENT_BROWSER_DEVTOOLS_SHARED_WORKER_DEVTOOLS_MANAGER_H_ | 67 #endif // CONTENT_BROWSER_DEVTOOLS_SHARED_WORKER_DEVTOOLS_MANAGER_H_ |
| OLD | NEW |