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

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

Issue 261753008: Call EmbeddedWorkerDevToolsManager::ServiceWorkerCreated, WorkerContextStarted and WorkerDestroyed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add explicit Created 6 years, 7 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
« no previous file with comments | « no previous file | content/browser/devtools/embedded_worker_devtools_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_
6 #define CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_ 6 #define CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/containers/scoped_ptr_hash_map.h" 9 #include "base/containers/scoped_ptr_hash_map.h"
10 #include "base/files/file_path.h"
11 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
13 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
14 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
15 #include "content/browser/shared_worker/shared_worker_instance.h" 14 #include "content/browser/shared_worker/shared_worker_instance.h"
16 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
17 16
18 class GURL; 17 namespace content {
19 18
20 namespace content {
21 class DevToolsAgentHost; 19 class DevToolsAgentHost;
20 class ServiceWorkerContextCore;
22 21
23 // EmbeddedWorkerDevToolsManager is used instead of WorkerDevToolsManager when 22 // EmbeddedWorkerDevToolsManager is used instead of WorkerDevToolsManager when
24 // "enable-embedded-shared-worker" flag is set. 23 // "enable-embedded-shared-worker" flag is set.
25 // This class lives on UI thread. 24 // This class lives on UI thread.
26 class CONTENT_EXPORT EmbeddedWorkerDevToolsManager { 25 class CONTENT_EXPORT EmbeddedWorkerDevToolsManager {
27 public: 26 public:
28 typedef std::pair<int, int> WorkerId; 27 typedef std::pair<int, int> WorkerId;
29 class EmbeddedWorkerDevToolsAgentHost; 28 class EmbeddedWorkerDevToolsAgentHost;
30 29
30 class ServiceWorkerIdentifier {
31 public:
32 ServiceWorkerIdentifier(
33 const ServiceWorkerContextCore* const service_worker_context,
34 int64 service_worker_version_id);
35 explicit ServiceWorkerIdentifier(const ServiceWorkerIdentifier& other);
36 ~ServiceWorkerIdentifier() {}
37
38 bool Matches(const ServiceWorkerIdentifier& other) const;
39
40 private:
41 const ServiceWorkerContextCore* const service_worker_context_;
42 const int64 service_worker_version_id_;
43 };
44
31 // Returns the EmbeddedWorkerDevToolsManager singleton. 45 // Returns the EmbeddedWorkerDevToolsManager singleton.
32 static EmbeddedWorkerDevToolsManager* GetInstance(); 46 static EmbeddedWorkerDevToolsManager* GetInstance();
33 47
34 DevToolsAgentHost* GetDevToolsAgentHostForWorker(int worker_process_id, 48 DevToolsAgentHost* GetDevToolsAgentHostForWorker(int worker_process_id,
35 int worker_route_id); 49 int worker_route_id);
36 DevToolsAgentHost* GetDevToolsAgentHostForServiceWorker( 50 DevToolsAgentHost* GetDevToolsAgentHostForServiceWorker(
37 const base::FilePath& storage_partition_path, 51 const ServiceWorkerIdentifier& service_worker_id);
38 const GURL& service_worker_scope);
39 52
40 // Returns true when the worker must be paused on start. 53 // Returns true when the worker must be paused on start.
41 bool SharedWorkerCreated(int worker_process_id, 54 bool SharedWorkerCreated(int worker_process_id,
42 int worker_route_id, 55 int worker_route_id,
43 const SharedWorkerInstance& instance); 56 const SharedWorkerInstance& instance);
44 // Returns true when the worker must be paused on start. 57 // Returns true when the worker must be paused on start.
45 // TODO(horo): Currently we identify ServiceWorkers with the path of storage
46 // partition and the scope of ServiceWorker. Consider having a class like
47 // SharedWorkerInstance instead of the pair.
48 bool ServiceWorkerCreated(int worker_process_id, 58 bool ServiceWorkerCreated(int worker_process_id,
49 int worker_route_id, 59 int worker_route_id,
50 const base::FilePath& storage_partition_path, 60 const ServiceWorkerIdentifier& service_worker_id);
51 const GURL& service_worker_scope);
52 void WorkerContextStarted(int worker_process_id, int worker_route_id); 61 void WorkerContextStarted(int worker_process_id, int worker_route_id);
53 void WorkerDestroyed(int worker_process_id, int worker_route_id); 62 void WorkerDestroyed(int worker_process_id, int worker_route_id);
54 63
55 private: 64 private:
56 friend struct DefaultSingletonTraits<EmbeddedWorkerDevToolsManager>; 65 friend struct DefaultSingletonTraits<EmbeddedWorkerDevToolsManager>;
57 friend class EmbeddedWorkerDevToolsManagerTest; 66 friend class EmbeddedWorkerDevToolsManagerTest;
58 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, BasicTest); 67 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, BasicTest);
59 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, AttachTest); 68 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, AttachTest);
60 69
61 enum WorkerState { 70 enum WorkerState {
62 WORKER_UNINSPECTED, 71 WORKER_UNINSPECTED,
63 WORKER_INSPECTED, 72 WORKER_INSPECTED,
64 WORKER_TERMINATED, 73 WORKER_TERMINATED,
65 WORKER_PAUSED, 74 WORKER_PAUSED,
66 }; 75 };
67 76
68 class WorkerInfo { 77 class WorkerInfo {
69 public: 78 public:
70 // Creates WorkerInfo for SharedWorker. 79 // Creates WorkerInfo for SharedWorker.
71 explicit WorkerInfo(const SharedWorkerInstance& instance); 80 explicit WorkerInfo(const SharedWorkerInstance& instance);
72 // Creates WorkerInfo for ServiceWorker. 81 // Creates WorkerInfo for ServiceWorker.
73 WorkerInfo(const base::FilePath& storage_partition_path, 82 explicit WorkerInfo(const ServiceWorkerIdentifier& service_worker_id);
74 const GURL& service_worker_scope);
75 ~WorkerInfo(); 83 ~WorkerInfo();
76 84
77 WorkerState state() { return state_; } 85 WorkerState state() { return state_; }
78 void set_state(WorkerState new_state) { state_ = new_state; } 86 void set_state(WorkerState new_state) { state_ = new_state; }
79 EmbeddedWorkerDevToolsAgentHost* agent_host() { return agent_host_; } 87 EmbeddedWorkerDevToolsAgentHost* agent_host() { return agent_host_; }
80 void set_agent_host(EmbeddedWorkerDevToolsAgentHost* agent_host) { 88 void set_agent_host(EmbeddedWorkerDevToolsAgentHost* agent_host) {
81 agent_host_ = agent_host; 89 agent_host_ = agent_host;
82 } 90 }
83 bool Matches(const SharedWorkerInstance& other); 91 bool Matches(const SharedWorkerInstance& other);
84 bool Matches(const base::FilePath& other_storage_partition_path, 92 bool Matches(const ServiceWorkerIdentifier& other);
85 const GURL& other_service_worker_scope);
86 93
87 private: 94 private:
88 scoped_ptr<SharedWorkerInstance> shared_worker_instance_; 95 scoped_ptr<SharedWorkerInstance> shared_worker_instance_;
89 scoped_ptr<base::FilePath> storage_partition_path_; 96 scoped_ptr<ServiceWorkerIdentifier> service_worker_id_;
90 scoped_ptr<GURL> service_worker_scope_;
91 WorkerState state_; 97 WorkerState state_;
92 EmbeddedWorkerDevToolsAgentHost* agent_host_; 98 EmbeddedWorkerDevToolsAgentHost* agent_host_;
93 }; 99 };
94 100
95 typedef base::ScopedPtrHashMap<WorkerId, WorkerInfo> WorkerInfoMap; 101 typedef base::ScopedPtrHashMap<WorkerId, WorkerInfo> WorkerInfoMap;
96 102
97 EmbeddedWorkerDevToolsManager(); 103 EmbeddedWorkerDevToolsManager();
98 virtual ~EmbeddedWorkerDevToolsManager(); 104 virtual ~EmbeddedWorkerDevToolsManager();
99 105
100 void RemoveInspectedWorkerData(EmbeddedWorkerDevToolsAgentHost* agent_host); 106 void RemoveInspectedWorkerData(EmbeddedWorkerDevToolsAgentHost* agent_host);
101 107
102 WorkerInfoMap::iterator FindExistingSharedWorkerInfo( 108 WorkerInfoMap::iterator FindExistingSharedWorkerInfo(
103 const SharedWorkerInstance& instance); 109 const SharedWorkerInstance& instance);
104 WorkerInfoMap::iterator FindExistingServiceWorkerInfo( 110 WorkerInfoMap::iterator FindExistingServiceWorkerInfo(
105 const base::FilePath& storage_partition_path, 111 const ServiceWorkerIdentifier& service_worker_id);
106 const GURL& service_worker_scope);
107 112
108 void MoveToPausedState(const WorkerId& id, const WorkerInfoMap::iterator& it); 113 void MoveToPausedState(const WorkerId& id, const WorkerInfoMap::iterator& it);
109 114
110 // Resets to its initial state as if newly created. 115 // Resets to its initial state as if newly created.
111 void ResetForTesting(); 116 void ResetForTesting();
112 117
113 WorkerInfoMap workers_; 118 WorkerInfoMap workers_;
114 119
115 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsManager); 120 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsManager);
116 }; 121 };
117 122
118 } // namespace content 123 } // namespace content
119 124
120 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_ 125 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/devtools/embedded_worker_devtools_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698