| 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_SERVICE_WORKER_DEVTOOLS_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_MANAGER_H_ |
| 6 #define CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_MANAGER_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "content/public/browser/devtools_agent_host.h" | 14 #include "content/public/browser/devtools_agent_host.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 class DevToolsAgentHostImpl; | 18 class DevToolsAgentHostImpl; |
| 19 class ServiceWorkerDevToolsAgentHost; | 19 class ServiceWorkerDevToolsAgentHost; |
| 20 class ServiceWorkerContextCore; | 20 class ServiceWorkerContextCore; |
| 21 | 21 |
| 22 // Manages WorkerDevToolsAgentHost's for Service Workers. | 22 // Manages WorkerDevToolsAgentHost's for Service Workers. |
| 23 // This class lives on UI thread. | 23 // This class lives on UI thread. |
| 24 class CONTENT_EXPORT ServiceWorkerDevToolsManager { | 24 class CONTENT_EXPORT ServiceWorkerDevToolsManager { |
| 25 public: | 25 public: |
| 26 typedef std::pair<int, int> WorkerId; | 26 using WorkerId = std::pair<int, int>; |
| 27 using AgentList = std::vector<scoped_refptr<ServiceWorkerDevToolsAgentHost>>; |
| 27 | 28 |
| 28 class Observer { | 29 class Observer { |
| 29 public: | 30 public: |
| 30 virtual void WorkerCreated(DevToolsAgentHost* host) {} | 31 virtual void WorkerCreated(ServiceWorkerDevToolsAgentHost* host) {} |
| 31 virtual void WorkerDestroyed(DevToolsAgentHost* host) {} | 32 virtual void WorkerReadyForInspection( |
| 33 ServiceWorkerDevToolsAgentHost* host) {} |
| 34 virtual void WorkerDestroyed(ServiceWorkerDevToolsAgentHost* host) {} |
| 32 | 35 |
| 33 protected: | 36 protected: |
| 34 virtual ~Observer() {} | 37 virtual ~Observer() {} |
| 35 }; | 38 }; |
| 36 | 39 |
| 37 class ServiceWorkerIdentifier { | 40 class ServiceWorkerIdentifier { |
| 38 public: | 41 public: |
| 39 ServiceWorkerIdentifier( | 42 ServiceWorkerIdentifier( |
| 40 const ServiceWorkerContextCore* context, | 43 const ServiceWorkerContextCore* context, |
| 41 base::WeakPtr<ServiceWorkerContextCore> context_weak, | 44 base::WeakPtr<ServiceWorkerContextCore> context_weak, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 58 const base::WeakPtr<ServiceWorkerContextCore> context_weak_; | 61 const base::WeakPtr<ServiceWorkerContextCore> context_weak_; |
| 59 const int64 version_id_; | 62 const int64 version_id_; |
| 60 const GURL url_; | 63 const GURL url_; |
| 61 }; | 64 }; |
| 62 | 65 |
| 63 // Returns the ServiceWorkerDevToolsManager singleton. | 66 // Returns the ServiceWorkerDevToolsManager singleton. |
| 64 static ServiceWorkerDevToolsManager* GetInstance(); | 67 static ServiceWorkerDevToolsManager* GetInstance(); |
| 65 | 68 |
| 66 DevToolsAgentHostImpl* GetDevToolsAgentHostForWorker(int worker_process_id, | 69 DevToolsAgentHostImpl* GetDevToolsAgentHostForWorker(int worker_process_id, |
| 67 int worker_route_id); | 70 int worker_route_id); |
| 68 void AddAllAgentHosts(DevToolsAgentHost::List* result); | 71 void AddAllAgentHosts( |
| 72 std::vector<scoped_refptr<ServiceWorkerDevToolsAgentHost>>* result); |
| 69 | 73 |
| 70 // Returns true when the worker must be paused on start because a DevTool | 74 // Returns true when the worker must be paused on start because a DevTool |
| 71 // window for the same former ServiceWorkerIdentifier is still opened or | 75 // window for the same former ServiceWorkerIdentifier is still opened or |
| 72 // debug-on-start is enabled in chrome://serviceworker-internals. | 76 // debug-on-start is enabled in chrome://serviceworker-internals. |
| 73 bool WorkerCreated(int worker_process_id, | 77 bool WorkerCreated(int worker_process_id, |
| 74 int worker_route_id, | 78 int worker_route_id, |
| 75 const ServiceWorkerIdentifier& service_worker_id); | 79 const ServiceWorkerIdentifier& service_worker_id); |
| 76 void WorkerReadyForInspection(int worker_process_id, int worker_route_id); | 80 void WorkerReadyForInspection(int worker_process_id, int worker_route_id); |
| 77 void WorkerStopIgnored(int worker_process_id, int worker_route_id); | 81 void WorkerStopIgnored(int worker_process_id, int worker_route_id); |
| 78 void WorkerDestroyed(int worker_process_id, int worker_route_id); | 82 void WorkerDestroyed(int worker_process_id, int worker_route_id); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 106 ObserverList<Observer> observer_list_; | 110 ObserverList<Observer> observer_list_; |
| 107 AgentHostMap workers_; | 111 AgentHostMap workers_; |
| 108 bool debug_service_worker_on_start_; | 112 bool debug_service_worker_on_start_; |
| 109 | 113 |
| 110 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDevToolsManager); | 114 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDevToolsManager); |
| 111 }; | 115 }; |
| 112 | 116 |
| 113 } // namespace content | 117 } // namespace content |
| 114 | 118 |
| 115 #endif // CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_MANAGER_H_ | 119 #endif // CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_MANAGER_H_ |
| OLD | NEW |