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

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

Issue 817653002: Split EmbeddedWorkerDevToolsManager into two for Shared- and ServiceWorker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_ 5 #ifndef CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_MANAGER_H_
6 #define CONTENT_BROWSER_DEVTOOLS_EMBEDDED_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/gtest_prod_util.h"
12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/singleton.h" 11 #include "base/memory/singleton.h"
14 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
15 #include "base/strings/string16.h" 13 #include "content/browser/devtools/worker_devtools_manager.h"
16 #include "content/browser/shared_worker/shared_worker_instance.h" 14 #include "content/browser/shared_worker/shared_worker_instance.h"
17 #include "content/common/content_export.h"
18 15
19 namespace content { 16 namespace content {
20 17
21 class DevToolsAgentHost; 18 class ServiceWorkerDevToolsAgentHost;
22 class DevToolsAgentHostImpl;
23 class EmbeddedWorkerDevToolsAgentHost;
24 class ServiceWorkerContextCore; 19 class ServiceWorkerContextCore;
25 20
26 // EmbeddedWorkerDevToolsManager is used instead of WorkerDevToolsManager when 21 // Manages WorkerDevToolsAgentHost's for Service Workers.
27 // "enable-embedded-shared-worker" flag is set.
28 // This class lives on UI thread. 22 // This class lives on UI thread.
29 class CONTENT_EXPORT EmbeddedWorkerDevToolsManager { 23 class CONTENT_EXPORT ServiceWorkerDevToolsManager
24 : public WorkerDevToolsManager {
30 public: 25 public:
31 typedef std::pair<int, int> WorkerId;
32
33 class ServiceWorkerIdentifier { 26 class ServiceWorkerIdentifier {
34 public: 27 public:
35 ServiceWorkerIdentifier( 28 ServiceWorkerIdentifier(
36 const ServiceWorkerContextCore* context, 29 const ServiceWorkerContextCore* context,
37 base::WeakPtr<ServiceWorkerContextCore> context_weak, 30 base::WeakPtr<ServiceWorkerContextCore> context_weak,
38 int64 version_id, 31 int64 version_id,
39 const GURL& url); 32 const GURL& url);
40 ServiceWorkerIdentifier(const ServiceWorkerIdentifier& other); 33 ServiceWorkerIdentifier(const ServiceWorkerIdentifier& other);
41 ~ServiceWorkerIdentifier(); 34 ~ServiceWorkerIdentifier();
42 35
43 bool Matches(const ServiceWorkerIdentifier& other) const; 36 bool Matches(const ServiceWorkerIdentifier& other) const;
44 37
45 const ServiceWorkerContextCore* context() const; 38 const ServiceWorkerContextCore* context() const { return context_; }
46 base::WeakPtr<ServiceWorkerContextCore> context_weak() const; 39 base::WeakPtr<ServiceWorkerContextCore> context_weak() const {
47 int64 version_id() const; 40 return context_weak_;
48 GURL url() const; 41 }
42 int64 version_id() const { return version_id_; }
43 GURL url() const { return url_; }
49 44
50 private: 45 private:
51 const ServiceWorkerContextCore* const context_; 46 const ServiceWorkerContextCore* const context_;
52 const base::WeakPtr<ServiceWorkerContextCore> context_weak_; 47 const base::WeakPtr<ServiceWorkerContextCore> context_weak_;
53 const int64 version_id_; 48 const int64 version_id_;
54 const GURL url_; 49 const GURL url_;
55 }; 50 };
56 51
57 // Returns the EmbeddedWorkerDevToolsManager singleton. 52 // Returns the ServiceWorkerDevToolsManager singleton.
58 static EmbeddedWorkerDevToolsManager* GetInstance(); 53 static ServiceWorkerDevToolsManager* GetInstance();
59 54
60 DevToolsAgentHostImpl* GetDevToolsAgentHostForWorker(int worker_process_id,
61 int worker_route_id);
62
63 std::vector<scoped_refptr<DevToolsAgentHost> > GetOrCreateAllAgentHosts();
64
65 // Returns true when the worker must be paused on start because a DevTool
66 // window for the same former SharedWorkerInstance is still opened.
67 bool SharedWorkerCreated(int worker_process_id,
68 int worker_route_id,
69 const SharedWorkerInstance& instance);
70 // Returns true when the worker must be paused on start because a DevTool 55 // Returns true when the worker must be paused on start because a DevTool
71 // window for the same former ServiceWorkerIdentifier is still opened or 56 // window for the same former ServiceWorkerIdentifier is still opened or
72 // debug-on-start is enabled in chrome://serviceworker-internals. 57 // debug-on-start is enabled in chrome://serviceworker-internals.
73 bool ServiceWorkerCreated(int worker_process_id, 58 bool WorkerCreated(int worker_process_id,
74 int worker_route_id, 59 int worker_route_id,
75 const ServiceWorkerIdentifier& service_worker_id); 60 const ServiceWorkerIdentifier& service_worker_id);
76 void WorkerReadyForInspection(int worker_process_id, int worker_route_id);
77 void WorkerDestroyed(int worker_process_id, int worker_route_id);
78 void WorkerStopIgnored(int worker_process_id, int worker_route_id); 61 void WorkerStopIgnored(int worker_process_id, int worker_route_id);
79 62
80 void set_debug_service_worker_on_start(bool debug_on_start) { 63 void set_debug_service_worker_on_start(bool debug_on_start) {
81 debug_service_worker_on_start_ = debug_on_start; 64 debug_service_worker_on_start_ = debug_on_start;
82 } 65 }
83 bool debug_service_worker_on_start() const { 66 bool debug_service_worker_on_start() const {
84 return debug_service_worker_on_start_; 67 return debug_service_worker_on_start_;
85 } 68 }
86 69
87 private: 70 private:
88 friend struct DefaultSingletonTraits<EmbeddedWorkerDevToolsManager>; 71 friend struct DefaultSingletonTraits<ServiceWorkerDevToolsManager>;
89 friend class EmbeddedWorkerDevToolsAgentHost; 72 friend class ServiceWorkerDevToolsAgentHost;
90 friend class EmbeddedWorkerDevToolsManagerTest;
91 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, BasicTest);
92 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, AttachTest);
93 73
94 typedef std::map<WorkerId, EmbeddedWorkerDevToolsAgentHost*> AgentHostMap; 74 ServiceWorkerDevToolsManager();
75 ~ServiceWorkerDevToolsManager() override;
95 76
96 EmbeddedWorkerDevToolsManager(); 77 AgentHostMap::iterator FindExistingWorkerAgentHost(
97 virtual ~EmbeddedWorkerDevToolsManager();
98
99 void RemoveInspectedWorkerData(WorkerId id);
100
101 AgentHostMap::iterator FindExistingSharedWorkerAgentHost(
102 const SharedWorkerInstance& instance);
103 AgentHostMap::iterator FindExistingServiceWorkerAgentHost(
104 const ServiceWorkerIdentifier& service_worker_id); 78 const ServiceWorkerIdentifier& service_worker_id);
105 79
106 void WorkerRestarted(const WorkerId& id, const AgentHostMap::iterator& it);
107
108 // Resets to its initial state as if newly created.
109 void ResetForTesting();
110
111 AgentHostMap workers_;
112
113 bool debug_service_worker_on_start_; 80 bool debug_service_worker_on_start_;
114 81
115 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsManager); 82 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerDevToolsManager);
116 }; 83 };
117 84
118 } // namespace content 85 } // namespace content
119 86
120 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_ 87 #endif // CONTENT_BROWSER_DEVTOOLS_SERVICE_WORKER_DEVTOOLS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698