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_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/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
11 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
12 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
14 #include "content/browser/shared_worker/shared_worker_instance.h" | 15 #include "content/browser/shared_worker/shared_worker_instance.h" |
15 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
16 | 17 |
17 class GURL; | 18 class GURL; |
18 | 19 |
19 namespace content { | 20 namespace content { |
(...skipping 10 matching lines...) Expand all Loading... | |
30 // Returns the EmbeddedWorkerDevToolsManager singleton. | 31 // Returns the EmbeddedWorkerDevToolsManager singleton. |
31 static EmbeddedWorkerDevToolsManager* GetInstance(); | 32 static EmbeddedWorkerDevToolsManager* GetInstance(); |
32 | 33 |
33 DevToolsAgentHost* GetDevToolsAgentHostForWorker(int worker_process_id, | 34 DevToolsAgentHost* GetDevToolsAgentHostForWorker(int worker_process_id, |
34 int worker_route_id); | 35 int worker_route_id); |
35 | 36 |
36 // Returns true when the worker must be paused on start. | 37 // Returns true when the worker must be paused on start. |
37 bool SharedWorkerCreated(int worker_process_id, | 38 bool SharedWorkerCreated(int worker_process_id, |
38 int worker_route_id, | 39 int worker_route_id, |
39 const SharedWorkerInstance& instance); | 40 const SharedWorkerInstance& instance); |
41 // Returns true when the worker must be paused on start. | |
42 // TODO(horo): Currently we identify ServiceWorkers with the FilePath of | |
43 // ServiceWorkerStorage and the scope of ServiceWorker. Consider having | |
kinuko
2014/05/02 08:51:05
'FilePath of ServiceWorkerStorage' is the informat
horo
2014/05/02 09:58:16
Changed the comment.
I think it would occur when t
| |
44 // a class like SharedWorkerInstance instead of the pair. | |
45 bool ServiceWorkerCreated(int worker_process_id, | |
46 int worker_route_id, | |
47 const base::FilePath& service_worker_path, | |
48 const GURL& service_worker_scope); | |
49 void WorkerContextStarted(int worker_process_id, int worker_route_id); | |
40 void WorkerDestroyed(int worker_process_id, int worker_route_id); | 50 void WorkerDestroyed(int worker_process_id, int worker_route_id); |
41 void WorkerContextStarted(int worker_process_id, int worker_route_id); | |
42 | 51 |
43 private: | 52 private: |
44 friend struct DefaultSingletonTraits<EmbeddedWorkerDevToolsManager>; | 53 friend struct DefaultSingletonTraits<EmbeddedWorkerDevToolsManager>; |
45 friend class EmbeddedWorkerDevToolsManagerTest; | 54 friend class EmbeddedWorkerDevToolsManagerTest; |
46 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, BasicTest); | 55 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, BasicTest); |
47 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, AttachTest); | 56 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, AttachTest); |
48 | 57 |
49 enum WorkerState { | 58 enum WorkerState { |
50 WORKER_UNINSPECTED, | 59 WORKER_UNINSPECTED, |
51 WORKER_INSPECTED, | 60 WORKER_INSPECTED, |
52 WORKER_TERMINATED, | 61 WORKER_TERMINATED, |
53 WORKER_PAUSED, | 62 WORKER_PAUSED, |
54 }; | 63 }; |
55 | 64 |
56 class WorkerInfo { | 65 class WorkerInfo { |
57 public: | 66 public: |
58 explicit WorkerInfo(const SharedWorkerInstance& instance) | 67 explicit WorkerInfo(const SharedWorkerInstance& instance); |
59 : instance_(instance), state_(WORKER_UNINSPECTED), agent_host_(NULL) {} | 68 WorkerInfo(const base::FilePath& service_worker_path, |
69 const GURL& service_worker_scope); | |
70 ~WorkerInfo(); | |
60 | 71 |
61 const SharedWorkerInstance& instance() const { return instance_; } | |
62 WorkerState state() { return state_; } | 72 WorkerState state() { return state_; } |
63 void set_state(WorkerState new_state) { state_ = new_state; } | 73 void set_state(WorkerState new_state) { state_ = new_state; } |
64 EmbeddedWorkerDevToolsAgentHost* agent_host() { return agent_host_; } | 74 EmbeddedWorkerDevToolsAgentHost* agent_host() { return agent_host_; } |
65 void set_agent_host(EmbeddedWorkerDevToolsAgentHost* agent_host) { | 75 void set_agent_host(EmbeddedWorkerDevToolsAgentHost* agent_host) { |
66 agent_host_ = agent_host; | 76 agent_host_ = agent_host; |
67 } | 77 } |
78 bool Matches(const SharedWorkerInstance& other); | |
79 bool Matches(const base::FilePath& other_service_worker_path, | |
80 const GURL& other_service_worker_scope); | |
68 | 81 |
69 private: | 82 private: |
70 const SharedWorkerInstance instance_; | 83 scoped_ptr<SharedWorkerInstance> shared_worker_instance_; |
84 scoped_ptr<base::FilePath> service_worker_path_; | |
85 scoped_ptr<GURL> service_worker_scope_; | |
71 WorkerState state_; | 86 WorkerState state_; |
72 EmbeddedWorkerDevToolsAgentHost* agent_host_; | 87 EmbeddedWorkerDevToolsAgentHost* agent_host_; |
73 }; | 88 }; |
74 | 89 |
75 typedef base::ScopedPtrHashMap<WorkerId, WorkerInfo> WorkerInfoMap; | 90 typedef base::ScopedPtrHashMap<WorkerId, WorkerInfo> WorkerInfoMap; |
76 | 91 |
77 EmbeddedWorkerDevToolsManager(); | 92 EmbeddedWorkerDevToolsManager(); |
78 virtual ~EmbeddedWorkerDevToolsManager(); | 93 virtual ~EmbeddedWorkerDevToolsManager(); |
79 | 94 |
80 void RemoveInspectedWorkerData(EmbeddedWorkerDevToolsAgentHost* agent_host); | 95 void RemoveInspectedWorkerData(EmbeddedWorkerDevToolsAgentHost* agent_host); |
81 | 96 |
82 WorkerInfoMap::iterator FindExistingSharedWorkerInfo( | 97 WorkerInfoMap::iterator FindExistingSharedWorkerInfo( |
83 const SharedWorkerInstance& instance); | 98 const SharedWorkerInstance& instance); |
99 WorkerInfoMap::iterator FindExistingServiceWorkerInfo( | |
100 const base::FilePath& service_worker_path, | |
101 const GURL& service_worker_scope); | |
102 | |
103 void MoveToPausedState(const WorkerId& id, const WorkerInfoMap::iterator& it); | |
84 | 104 |
85 // Resets to its initial state as if newly created. | 105 // Resets to its initial state as if newly created. |
86 void ResetForTesting(); | 106 void ResetForTesting(); |
87 | 107 |
88 WorkerInfoMap workers_; | 108 WorkerInfoMap workers_; |
89 | 109 |
90 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsManager); | 110 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsManager); |
91 }; | 111 }; |
92 | 112 |
93 } // namespace content | 113 } // namespace content |
94 | 114 |
95 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_ | 115 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_ |
OLD | NEW |