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 <map> | |
9 | |
8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
9 #include "base/containers/scoped_ptr_hash_map.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 namespace content { | 18 namespace content { |
18 | 19 |
19 class DevToolsAgentHost; | 20 class DevToolsAgentHost; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 bool debug_service_worker_on_start() const { | 71 bool debug_service_worker_on_start() const { |
71 return debug_service_worker_on_start_; | 72 return debug_service_worker_on_start_; |
72 } | 73 } |
73 | 74 |
74 private: | 75 private: |
75 friend struct DefaultSingletonTraits<EmbeddedWorkerDevToolsManager>; | 76 friend struct DefaultSingletonTraits<EmbeddedWorkerDevToolsManager>; |
76 friend class EmbeddedWorkerDevToolsManagerTest; | 77 friend class EmbeddedWorkerDevToolsManagerTest; |
77 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, BasicTest); | 78 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, BasicTest); |
78 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, AttachTest); | 79 FRIEND_TEST_ALL_PREFIXES(EmbeddedWorkerDevToolsManagerTest, AttachTest); |
79 | 80 |
80 enum WorkerState { | 81 enum WorkerState { |
horo
2014/08/06 07:47:50
nit: Move this to .cc.
vkuzkokov
2014/08/06 09:07:39
Done.
| |
81 WORKER_UNINSPECTED, | 82 WORKER_UNINSPECTED, |
82 WORKER_INSPECTED, | 83 WORKER_INSPECTED, |
83 WORKER_TERMINATED, | 84 WORKER_TERMINATED, |
84 WORKER_PAUSED_FOR_DEBUG_ON_START, | 85 WORKER_PAUSED_FOR_DEBUG_ON_START, |
85 WORKER_PAUSED_FOR_REATTACH, | 86 WORKER_PAUSED_FOR_REATTACH, |
86 }; | 87 }; |
87 | 88 |
88 class WorkerInfo { | 89 typedef std::map<WorkerId, EmbeddedWorkerDevToolsAgentHost*> WorkerInfoMap; |
horo
2014/08/06 07:47:50
I think if you use
std::map<WorkerId, scoped_refp
horo
2014/08/06 07:47:50
nit: I prefer WorkerAgentHostMap.
vkuzkokov
2014/08/06 09:07:39
workers_ keeps live instances of EWDTAH. they are
vkuzkokov
2014/08/06 09:07:39
AgentHostMap.
horo
2014/08/06 10:08:40
I see.
Sorry I misunderstood
| |
89 public: | |
90 // Creates WorkerInfo for SharedWorker. | |
91 explicit WorkerInfo(const SharedWorkerInstance& instance); | |
92 // Creates WorkerInfo for ServiceWorker. | |
93 explicit WorkerInfo(const ServiceWorkerIdentifier& service_worker_id); | |
94 ~WorkerInfo(); | |
95 | |
96 WorkerState state() { return state_; } | |
97 void set_state(WorkerState new_state) { state_ = new_state; } | |
98 EmbeddedWorkerDevToolsAgentHost* agent_host() { return agent_host_; } | |
99 void set_agent_host(EmbeddedWorkerDevToolsAgentHost* agent_host) { | |
100 agent_host_ = agent_host; | |
101 } | |
102 bool Matches(const SharedWorkerInstance& other); | |
103 bool Matches(const ServiceWorkerIdentifier& other); | |
104 | |
105 private: | |
106 scoped_ptr<SharedWorkerInstance> shared_worker_instance_; | |
107 scoped_ptr<ServiceWorkerIdentifier> service_worker_id_; | |
108 WorkerState state_; | |
109 EmbeddedWorkerDevToolsAgentHost* agent_host_; | |
110 }; | |
111 | |
112 typedef base::ScopedPtrHashMap<WorkerId, WorkerInfo> WorkerInfoMap; | |
113 | 90 |
114 EmbeddedWorkerDevToolsManager(); | 91 EmbeddedWorkerDevToolsManager(); |
115 virtual ~EmbeddedWorkerDevToolsManager(); | 92 virtual ~EmbeddedWorkerDevToolsManager(); |
116 | 93 |
117 void RemoveInspectedWorkerData(EmbeddedWorkerDevToolsAgentHost* agent_host); | 94 void RemoveInspectedWorkerData(EmbeddedWorkerDevToolsAgentHost* agent_host); |
118 | 95 |
119 WorkerInfoMap::iterator FindExistingSharedWorkerInfo( | 96 WorkerInfoMap::iterator FindExistingSharedWorkerInfo( |
120 const SharedWorkerInstance& instance); | 97 const SharedWorkerInstance& instance); |
121 WorkerInfoMap::iterator FindExistingServiceWorkerInfo( | 98 WorkerInfoMap::iterator FindExistingServiceWorkerInfo( |
122 const ServiceWorkerIdentifier& service_worker_id); | 99 const ServiceWorkerIdentifier& service_worker_id); |
123 | 100 |
124 void MoveToPausedState(const WorkerId& id, const WorkerInfoMap::iterator& it); | 101 void WorkerRestarted(const WorkerId& id, const WorkerInfoMap::iterator& it); |
125 | 102 |
126 // Resets to its initial state as if newly created. | 103 // Resets to its initial state as if newly created. |
127 void ResetForTesting(); | 104 void ResetForTesting(); |
128 | 105 |
129 WorkerInfoMap workers_; | 106 WorkerInfoMap workers_; |
130 | 107 |
131 bool debug_service_worker_on_start_; | 108 bool debug_service_worker_on_start_; |
132 | 109 |
133 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsManager); | 110 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerDevToolsManager); |
134 }; | 111 }; |
135 | 112 |
136 } // namespace content | 113 } // namespace content |
137 | 114 |
138 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_ | 115 #endif // CONTENT_BROWSER_DEVTOOLS_EMBEDDED_WORKER_DEVTOOLS_MANAGER_H_ |
OLD | NEW |