| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_DEBUGGER_WORKER_DEVTOOLS_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_DEBUGGER_WORKER_DEVTOOLS_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_DEBUGGER_WORKER_DEVTOOLS_MANAGER_H_ | 6 #define CONTENT_BROWSER_DEBUGGER_WORKER_DEVTOOLS_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
| 16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 17 #include "content/public/browser/worker_service_observer.h" | 17 #include "content/browser/worker_host/worker_process_host.h" |
| 18 | |
| 19 namespace IPC { | |
| 20 class Message; | |
| 21 } | |
| 22 | 18 |
| 23 namespace content { | 19 namespace content { |
| 24 | 20 |
| 25 class DevToolsAgentHost; | 21 class DevToolsAgentHost; |
| 26 | 22 |
| 27 // All methods are supposed to be called on the IO thread. | 23 // All methods are supposed to be called on the IO thread. |
| 28 class WorkerDevToolsManager : private WorkerServiceObserver { | 24 class WorkerDevToolsManager { |
| 29 public: | 25 public: |
| 30 // Returns the WorkerDevToolsManager singleton. | 26 // Returns the WorkerDevToolsManager singleton. |
| 31 static WorkerDevToolsManager* GetInstance(); | 27 static WorkerDevToolsManager* GetInstance(); |
| 32 | 28 |
| 33 // Called on the UI thread. | 29 // Called on the UI thread. |
| 34 static DevToolsAgentHost* GetDevToolsAgentHostForWorker( | 30 static DevToolsAgentHost* GetDevToolsAgentHostForWorker( |
| 35 int worker_process_id, | 31 int worker_process_id, |
| 36 int worker_route_id); | 32 int worker_route_id); |
| 37 | 33 |
| 38 void ForwardToDevToolsClient(int worker_process_id, | 34 void ForwardToDevToolsClient(int worker_process_id, |
| 39 int worker_route_id, | 35 int worker_route_id, |
| 40 const std::string& message); | 36 const std::string& message); |
| 41 void SaveAgentRuntimeState(int worker_process_id, | 37 void SaveAgentRuntimeState(int worker_process_id, |
| 42 int worker_route_id, | 38 int worker_route_id, |
| 43 const std::string& state); | 39 const std::string& state); |
| 44 | 40 |
| 41 // Called on the IO thread. |
| 42 void WorkerCreated( |
| 43 WorkerProcessHost* process, |
| 44 const WorkerProcessHost::WorkerInstance& instance); |
| 45 void WorkerDestroyed(WorkerProcessHost* process, int worker_route_id); |
| 46 void WorkerContextStarted(WorkerProcessHost* process, int worker_route_id); |
| 47 |
| 45 private: | 48 private: |
| 46 friend struct DefaultSingletonTraits<WorkerDevToolsManager>; | 49 friend struct DefaultSingletonTraits<WorkerDevToolsManager>; |
| 47 typedef std::pair<int, int> WorkerId; | 50 typedef std::pair<int, int> WorkerId; |
| 48 class AgentHosts; | 51 class AgentHosts; |
| 49 class DetachedClientHosts; | 52 class DetachedClientHosts; |
| 50 class WorkerDevToolsAgentHost; | 53 class WorkerDevToolsAgentHost; |
| 51 struct InspectedWorker; | 54 struct InspectedWorker; |
| 52 typedef std::list<InspectedWorker> InspectedWorkersList; | 55 typedef std::list<InspectedWorker> InspectedWorkersList; |
| 53 | 56 |
| 54 WorkerDevToolsManager(); | 57 WorkerDevToolsManager(); |
| 55 virtual ~WorkerDevToolsManager(); | 58 virtual ~WorkerDevToolsManager(); |
| 56 | 59 |
| 57 // WorkerServiceObserver implementation. | |
| 58 virtual void WorkerCreated( | |
| 59 WorkerProcessHost* process, | |
| 60 const WorkerProcessHost::WorkerInstance& instance) OVERRIDE; | |
| 61 virtual void WorkerDestroyed( | |
| 62 WorkerProcessHost* process, | |
| 63 int worker_route_id) OVERRIDE; | |
| 64 virtual void WorkerContextStarted(WorkerProcessHost* process, | |
| 65 int worker_route_id) OVERRIDE; | |
| 66 | |
| 67 void RemoveInspectedWorkerData(const WorkerId& id); | 60 void RemoveInspectedWorkerData(const WorkerId& id); |
| 68 InspectedWorkersList::iterator FindInspectedWorker(int host_id, int route_id); | 61 InspectedWorkersList::iterator FindInspectedWorker(int host_id, int route_id); |
| 69 | 62 |
| 70 void RegisterDevToolsAgentHostForWorker(int worker_process_id, | 63 void RegisterDevToolsAgentHostForWorker(int worker_process_id, |
| 71 int worker_route_id); | 64 int worker_route_id); |
| 72 void ForwardToWorkerDevToolsAgent(int worker_process_host_id, | 65 void ForwardToWorkerDevToolsAgent(int worker_process_host_id, |
| 73 int worker_route_id, | 66 int worker_route_id, |
| 74 const IPC::Message& message); | 67 const IPC::Message& message); |
| 75 static void ForwardToDevToolsClientOnUIThread( | 68 static void ForwardToDevToolsClientOnUIThread( |
| 76 int worker_process_id, | 69 int worker_process_id, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // worker. | 102 // worker. |
| 110 // - Existing DevTools client was reattached to the new worker. | 103 // - Existing DevTools client was reattached to the new worker. |
| 111 PausedWorkers paused_workers_; | 104 PausedWorkers paused_workers_; |
| 112 | 105 |
| 113 DISALLOW_COPY_AND_ASSIGN(WorkerDevToolsManager); | 106 DISALLOW_COPY_AND_ASSIGN(WorkerDevToolsManager); |
| 114 }; | 107 }; |
| 115 | 108 |
| 116 } // namespace content | 109 } // namespace content |
| 117 | 110 |
| 118 #endif // CONTENT_BROWSER_DEBUGGER_WORKER_DEVTOOLS_MANAGER_H_ | 111 #endif // CONTENT_BROWSER_DEBUGGER_WORKER_DEVTOOLS_MANAGER_H_ |
| OLD | NEW |