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

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: incorporated kinuko's comment 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
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" 10 #include "base/files/file_path.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "content/browser/shared_worker/shared_worker_instance.h" 15 #include "content/browser/shared_worker/shared_worker_instance.h"
16 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 17
18 class GURL;
19
20 namespace content { 18 namespace content {
21 class DevToolsAgentHost; 19 class DevToolsAgentHost;
22 20
23 // EmbeddedWorkerDevToolsManager is used instead of WorkerDevToolsManager when 21 // EmbeddedWorkerDevToolsManager is used instead of WorkerDevToolsManager when
24 // "enable-embedded-shared-worker" flag is set. 22 // "enable-embedded-shared-worker" flag is set.
25 // This class lives on UI thread. 23 // This class lives on UI thread.
26 class CONTENT_EXPORT EmbeddedWorkerDevToolsManager { 24 class CONTENT_EXPORT EmbeddedWorkerDevToolsManager {
27 public: 25 public:
28 typedef std::pair<int, int> WorkerId; 26 typedef std::pair<int, int> WorkerId;
29 class EmbeddedWorkerDevToolsAgentHost; 27 class EmbeddedWorkerDevToolsAgentHost;
30 28
31 // Returns the EmbeddedWorkerDevToolsManager singleton. 29 // Returns the EmbeddedWorkerDevToolsManager singleton.
32 static EmbeddedWorkerDevToolsManager* GetInstance(); 30 static EmbeddedWorkerDevToolsManager* GetInstance();
33 31
34 DevToolsAgentHost* GetDevToolsAgentHostForWorker(int worker_process_id, 32 DevToolsAgentHost* GetDevToolsAgentHostForWorker(int worker_process_id,
35 int worker_route_id); 33 int worker_route_id);
36 DevToolsAgentHost* GetDevToolsAgentHostForServiceWorker( 34 DevToolsAgentHost* GetDevToolsAgentHostForServiceWorker(
37 const base::FilePath& storage_partition_path, 35 const base::FilePath& storage_partition_path,
38 const GURL& service_worker_scope); 36 int64 service_worker_version_id);
39 37
40 // Returns true when the worker must be paused on start. 38 // Returns true when the worker must be paused on start.
41 bool SharedWorkerCreated(int worker_process_id, 39 bool SharedWorkerCreated(int worker_process_id,
42 int worker_route_id, 40 int worker_route_id,
43 const SharedWorkerInstance& instance); 41 const SharedWorkerInstance& instance);
44 // Returns true when the worker must be paused on start. 42 // Returns true when the worker must be paused on start.
45 // TODO(horo): Currently we identify ServiceWorkers with the path of storage 43 // TODO(horo): Currently we identify ServiceWorkers with the path of storage
46 // partition and the scope of ServiceWorker. Consider having a class like 44 // partition and the version id of ServiceWorker. Consider having a class like
michaeln 2014/05/15 19:15:15 identifying by path is a good idea, one possible p
horo 2014/05/16 03:55:21 Thank you for pointing out. I didn't know that. I
47 // SharedWorkerInstance instead of the pair. 45 // SharedWorkerInstance instead of the pair.
48 bool ServiceWorkerCreated(int worker_process_id, 46 bool ServiceWorkerCreated(int worker_process_id,
49 int worker_route_id, 47 int worker_route_id,
50 const base::FilePath& storage_partition_path, 48 const base::FilePath& storage_partition_path,
51 const GURL& service_worker_scope); 49 int64 service_worker_version_id);
52 void WorkerContextStarted(int worker_process_id, int worker_route_id); 50 void WorkerContextStarted(int worker_process_id, int worker_route_id);
53 void WorkerDestroyed(int worker_process_id, int worker_route_id); 51 void WorkerDestroyed(int worker_process_id, int worker_route_id);
54 52
55 private: 53 private:
56 friend struct DefaultSingletonTraits<EmbeddedWorkerDevToolsManager>; 54 friend struct DefaultSingletonTraits<EmbeddedWorkerDevToolsManager>;
57 friend class EmbeddedWorkerDevToolsManagerTest; 55 friend class EmbeddedWorkerDevToolsManagerTest;
58 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, BasicTest); 56 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, BasicTest);
59 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, AttachTest); 57 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, AttachTest);
60 58
61 enum WorkerState { 59 enum WorkerState {
62 WORKER_UNINSPECTED, 60 WORKER_UNINSPECTED,
63 WORKER_INSPECTED, 61 WORKER_INSPECTED,
64 WORKER_TERMINATED, 62 WORKER_TERMINATED,
65 WORKER_PAUSED, 63 WORKER_PAUSED,
66 }; 64 };
67 65
68 class WorkerInfo { 66 class WorkerInfo {
69 public: 67 public:
70 // Creates WorkerInfo for SharedWorker. 68 // Creates WorkerInfo for SharedWorker.
71 explicit WorkerInfo(const SharedWorkerInstance& instance); 69 explicit WorkerInfo(const SharedWorkerInstance& instance);
72 // Creates WorkerInfo for ServiceWorker. 70 // Creates WorkerInfo for ServiceWorker.
73 WorkerInfo(const base::FilePath& storage_partition_path, 71 WorkerInfo(const base::FilePath& storage_partition_path,
74 const GURL& service_worker_scope); 72 int64 service_worker_version_id);
75 ~WorkerInfo(); 73 ~WorkerInfo();
76 74
77 WorkerState state() { return state_; } 75 WorkerState state() { return state_; }
78 void set_state(WorkerState new_state) { state_ = new_state; } 76 void set_state(WorkerState new_state) { state_ = new_state; }
79 EmbeddedWorkerDevToolsAgentHost* agent_host() { return agent_host_; } 77 EmbeddedWorkerDevToolsAgentHost* agent_host() { return agent_host_; }
80 void set_agent_host(EmbeddedWorkerDevToolsAgentHost* agent_host) { 78 void set_agent_host(EmbeddedWorkerDevToolsAgentHost* agent_host) {
81 agent_host_ = agent_host; 79 agent_host_ = agent_host;
82 } 80 }
83 bool Matches(const SharedWorkerInstance& other); 81 bool Matches(const SharedWorkerInstance& other);
84 bool Matches(const base::FilePath& other_storage_partition_path, 82 bool Matches(const base::FilePath& other_storage_partition_path,
85 const GURL& other_service_worker_scope); 83 int64 other_service_worker_version_id);
86 84
87 private: 85 private:
88 scoped_ptr<SharedWorkerInstance> shared_worker_instance_; 86 scoped_ptr<SharedWorkerInstance> shared_worker_instance_;
89 scoped_ptr<base::FilePath> storage_partition_path_; 87 scoped_ptr<base::FilePath> storage_partition_path_;
90 scoped_ptr<GURL> service_worker_scope_; 88 int64 service_worker_version_id_;
91 WorkerState state_; 89 WorkerState state_;
92 EmbeddedWorkerDevToolsAgentHost* agent_host_; 90 EmbeddedWorkerDevToolsAgentHost* agent_host_;
93 }; 91 };
94 92
95 typedef base::ScopedPtrHashMap<WorkerId, WorkerInfo> WorkerInfoMap; 93 typedef base::ScopedPtrHashMap<WorkerId, WorkerInfo> WorkerInfoMap;
96 94
97 EmbeddedWorkerDevToolsManager(); 95 EmbeddedWorkerDevToolsManager();
98 virtual ~EmbeddedWorkerDevToolsManager(); 96 virtual ~EmbeddedWorkerDevToolsManager();
99 97
100 void RemoveInspectedWorkerData(EmbeddedWorkerDevToolsAgentHost* agent_host); 98 void RemoveInspectedWorkerData(EmbeddedWorkerDevToolsAgentHost* agent_host);
101 99
102 WorkerInfoMap::iterator FindExistingSharedWorkerInfo( 100 WorkerInfoMap::iterator FindExistingSharedWorkerInfo(
103 const SharedWorkerInstance& instance); 101 const SharedWorkerInstance& instance);
104 WorkerInfoMap::iterator FindExistingServiceWorkerInfo( 102 WorkerInfoMap::iterator FindExistingServiceWorkerInfo(
105 const base::FilePath& storage_partition_path, 103 const base::FilePath& storage_partition_path,
106 const GURL& service_worker_scope); 104 int64 service_worker_version_id);
107 105
108 void MoveToPausedState(const WorkerId& id, const WorkerInfoMap::iterator& it); 106 void MoveToPausedState(const WorkerId& id, const WorkerInfoMap::iterator& it);
109 107
110 // Resets to its initial state as if newly created. 108 // Resets to its initial state as if newly created.
111 void ResetForTesting(); 109 void ResetForTesting();
112 110
113 WorkerInfoMap workers_; 111 WorkerInfoMap workers_;
114 112
115 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsManager); 113 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsManager);
116 }; 114 };
117 115
118 } // namespace content 116 } // namespace content
119 117
120 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_ 118 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698