Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: content/browser/devtools/service_worker_devtools_manager.h

Issue 988003002: DevTools: pick sw targets to attach to on the backend side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: track url, not frame Created 5 years, 9 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 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/browser/shared_worker/shared_worker_instance.h" 14 #include "content/browser/shared_worker/shared_worker_instance.h"
15 #include "content/public/browser/devtools_agent_host.h" 15 #include "content/public/browser/devtools_agent_host.h"
16 16
17 namespace content { 17 namespace content {
18 18
19 class DevToolsAgentHostImpl; 19 class DevToolsAgentHostImpl;
20 class ServiceWorkerDevToolsAgentHost; 20 class ServiceWorkerDevToolsAgentHost;
21 class ServiceWorkerContextCore; 21 class ServiceWorkerContextCore;
22 22
23 // Manages WorkerDevToolsAgentHost's for Service Workers. 23 // Manages WorkerDevToolsAgentHost's for Service Workers.
24 // This class lives on UI thread. 24 // This class lives on UI thread.
25 class CONTENT_EXPORT ServiceWorkerDevToolsManager { 25 class CONTENT_EXPORT ServiceWorkerDevToolsManager {
26 public: 26 public:
27 typedef std::pair<int, int> WorkerId; 27 using WorkerId = std::pair<int, int>;
28 using AgentList = std::vector<scoped_refptr<ServiceWorkerDevToolsAgentHost>>;
28 29
29 class Observer { 30 class Observer {
30 public: 31 public:
31 virtual void WorkerCreated(DevToolsAgentHost* host) {} 32 virtual void WorkerCreated(ServiceWorkerDevToolsAgentHost* host) {}
32 virtual void WorkerDestroyed(DevToolsAgentHost* host) {} 33 virtual void WorkerReadyForInspection(
34 ServiceWorkerDevToolsAgentHost* host) {}
35 virtual void WorkerDestroyed(ServiceWorkerDevToolsAgentHost* host) {}
33 36
34 protected: 37 protected:
35 virtual ~Observer() {} 38 virtual ~Observer() {}
36 }; 39 };
37 40
38 class ServiceWorkerIdentifier { 41 class ServiceWorkerIdentifier {
39 public: 42 public:
40 ServiceWorkerIdentifier( 43 ServiceWorkerIdentifier(
41 const ServiceWorkerContextCore* context, 44 const ServiceWorkerContextCore* context,
42 base::WeakPtr<ServiceWorkerContextCore> context_weak, 45 base::WeakPtr<ServiceWorkerContextCore> context_weak,
(...skipping 16 matching lines...) Expand all
59 const base::WeakPtr<ServiceWorkerContextCore> context_weak_; 62 const base::WeakPtr<ServiceWorkerContextCore> context_weak_;
60 const int64 version_id_; 63 const int64 version_id_;
61 const GURL url_; 64 const GURL url_;
62 }; 65 };
63 66
64 // Returns the ServiceWorkerDevToolsManager singleton. 67 // Returns the ServiceWorkerDevToolsManager singleton.
65 static ServiceWorkerDevToolsManager* GetInstance(); 68 static ServiceWorkerDevToolsManager* GetInstance();
66 69
67 DevToolsAgentHostImpl* GetDevToolsAgentHostForWorker(int worker_process_id, 70 DevToolsAgentHostImpl* GetDevToolsAgentHostForWorker(int worker_process_id,
68 int worker_route_id); 71 int worker_route_id);
69 void AddAllAgentHosts(DevToolsAgentHost::List* result); 72 void AddAllAgentHosts(
73 std::vector<scoped_refptr<ServiceWorkerDevToolsAgentHost>>* result);
70 74
71 // Returns true when the worker must be paused on start because a DevTool 75 // Returns true when the worker must be paused on start because a DevTool
72 // window for the same former ServiceWorkerIdentifier is still opened or 76 // window for the same former ServiceWorkerIdentifier is still opened or
73 // debug-on-start is enabled in chrome://serviceworker-internals. 77 // debug-on-start is enabled in chrome://serviceworker-internals.
74 bool WorkerCreated(int worker_process_id, 78 bool WorkerCreated(int worker_process_id,
75 int worker_route_id, 79 int worker_route_id,
76 const ServiceWorkerIdentifier& service_worker_id); 80 const ServiceWorkerIdentifier& service_worker_id);
77 void WorkerReadyForInspection(int worker_process_id, int worker_route_id); 81 void WorkerReadyForInspection(int worker_process_id, int worker_route_id);
78 void WorkerStopIgnored(int worker_process_id, int worker_route_id); 82 void WorkerStopIgnored(int worker_process_id, int worker_route_id);
79 void WorkerDestroyed(int worker_process_id, int worker_route_id); 83 void WorkerDestroyed(int worker_process_id, int worker_route_id);
(...skipping 27 matching lines...) Expand all
107 ObserverList<Observer> observer_list_; 111 ObserverList<Observer> observer_list_;
108 AgentHostMap workers_; 112 AgentHostMap workers_;
109 bool debug_service_worker_on_start_; 113 bool debug_service_worker_on_start_;
110 114
111 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDevToolsManager); 115 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDevToolsManager);
112 }; 116 };
113 117
114 } // namespace content 118 } // namespace content
115 119
116 #endif // CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_MANAGER_H_ 120 #endif // CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698