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

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

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
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 #include "content/browser/devtools/embedded_worker_devtools_manager.h" 5 #include "content/browser/devtools/embedded_worker_devtools_manager.h"
6 6
7 #include "content/browser/devtools/devtools_manager_impl.h" 7 #include "content/browser/devtools/devtools_manager_impl.h"
8 #include "content/browser/devtools/devtools_protocol.h" 8 #include "content/browser/devtools/devtools_protocol.h"
9 #include "content/browser/devtools/devtools_protocol_constants.h" 9 #include "content/browser/devtools/devtools_protocol_constants.h"
10 #include "content/browser/devtools/ipc_devtools_agent_host.h" 10 #include "content/browser/devtools/ipc_devtools_agent_host.h"
(...skipping 16 matching lines...) Expand all
27 delete message; 27 delete message;
28 return false; 28 return false;
29 } 29 }
30 message->set_routing_id(worker_id.second); 30 message->set_routing_id(worker_id.second);
31 host->Send(message); 31 host->Send(message);
32 return true; 32 return true;
33 } 33 }
34 34
35 } // namespace 35 } // namespace
36 36
37 EmbeddedWorkerDevToolsManager::ServiceWorkerIdentifier::ServiceWorkerIdentifier(
38 const ServiceWorkerContextCore* const service_worker_context,
39 int64 service_worker_version_id)
40 : service_worker_context_(service_worker_context),
41 service_worker_version_id_(service_worker_version_id) {
42 }
43
44 EmbeddedWorkerDevToolsManager::ServiceWorkerIdentifier::ServiceWorkerIdentifier(
45 const ServiceWorkerIdentifier& other)
46 : service_worker_context_(other.service_worker_context_),
47 service_worker_version_id_(other.service_worker_version_id_) {
48 }
49
50 bool EmbeddedWorkerDevToolsManager::ServiceWorkerIdentifier::Matches(
51 const ServiceWorkerIdentifier& other) const {
52 return service_worker_context_ == other.service_worker_context_ &&
53 service_worker_version_id_ == other.service_worker_version_id_;
54 }
55
37 EmbeddedWorkerDevToolsManager::WorkerInfo::WorkerInfo( 56 EmbeddedWorkerDevToolsManager::WorkerInfo::WorkerInfo(
38 const SharedWorkerInstance& instance) 57 const SharedWorkerInstance& instance)
39 : shared_worker_instance_(new SharedWorkerInstance(instance)), 58 : shared_worker_instance_(new SharedWorkerInstance(instance)),
40 state_(WORKER_UNINSPECTED), 59 state_(WORKER_UNINSPECTED),
41 agent_host_(NULL) { 60 agent_host_(NULL) {
42 } 61 }
43 62
44 EmbeddedWorkerDevToolsManager::WorkerInfo::WorkerInfo( 63 EmbeddedWorkerDevToolsManager::WorkerInfo::WorkerInfo(
45 const base::FilePath& storage_partition_path, 64 const ServiceWorkerIdentifier& service_worker_id)
46 const GURL& service_worker_scope) 65 : service_worker_id_(new ServiceWorkerIdentifier(service_worker_id)),
47 : storage_partition_path_(new base::FilePath(storage_partition_path)),
48 service_worker_scope_(new GURL(service_worker_scope)),
49 state_(WORKER_UNINSPECTED), 66 state_(WORKER_UNINSPECTED),
50 agent_host_(NULL) { 67 agent_host_(NULL) {
51 } 68 }
52 69
53 bool EmbeddedWorkerDevToolsManager::WorkerInfo::Matches( 70 bool EmbeddedWorkerDevToolsManager::WorkerInfo::Matches(
54 const SharedWorkerInstance& other) { 71 const SharedWorkerInstance& other) {
55 if (!shared_worker_instance_) 72 if (!shared_worker_instance_)
56 return false; 73 return false;
57 return shared_worker_instance_->Matches(other); 74 return shared_worker_instance_->Matches(other);
58 } 75 }
59 76
60 bool EmbeddedWorkerDevToolsManager::WorkerInfo::Matches( 77 bool EmbeddedWorkerDevToolsManager::WorkerInfo::Matches(
61 const base::FilePath& other_storage_partition_path, 78 const ServiceWorkerIdentifier& other) {
62 const GURL& other_service_worker_scope) { 79 if (!service_worker_id_)
63 if (!storage_partition_path_ || !service_worker_scope_)
64 return false; 80 return false;
65 return *storage_partition_path_ == other_storage_partition_path && 81 return service_worker_id_->Matches(other);
66 *service_worker_scope_ == other_service_worker_scope;
67 } 82 }
68 83
69 EmbeddedWorkerDevToolsManager::WorkerInfo::~WorkerInfo() { 84 EmbeddedWorkerDevToolsManager::WorkerInfo::~WorkerInfo() {
70 } 85 }
71 86
72 class EmbeddedWorkerDevToolsManager::EmbeddedWorkerDevToolsAgentHost 87 class EmbeddedWorkerDevToolsManager::EmbeddedWorkerDevToolsAgentHost
73 : public IPCDevToolsAgentHost, 88 : public IPCDevToolsAgentHost,
74 public IPC::Listener { 89 public IPC::Listener {
75 public: 90 public:
76 explicit EmbeddedWorkerDevToolsAgentHost(WorkerId worker_id) 91 explicit EmbeddedWorkerDevToolsAgentHost(WorkerId worker_id)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 183
169 EmbeddedWorkerDevToolsAgentHost* agent_host = 184 EmbeddedWorkerDevToolsAgentHost* agent_host =
170 new EmbeddedWorkerDevToolsAgentHost(id); 185 new EmbeddedWorkerDevToolsAgentHost(id);
171 info->set_agent_host(agent_host); 186 info->set_agent_host(agent_host);
172 info->set_state(WORKER_INSPECTED); 187 info->set_state(WORKER_INSPECTED);
173 return agent_host; 188 return agent_host;
174 } 189 }
175 190
176 DevToolsAgentHost* 191 DevToolsAgentHost*
177 EmbeddedWorkerDevToolsManager::GetDevToolsAgentHostForServiceWorker( 192 EmbeddedWorkerDevToolsManager::GetDevToolsAgentHostForServiceWorker(
178 const base::FilePath& storage_partition_path, 193 const ServiceWorkerIdentifier& service_worker_id) {
179 const GURL& service_worker_scope) { 194 WorkerInfoMap::iterator it = FindExistingServiceWorkerInfo(service_worker_id);
180 WorkerInfoMap::iterator it = FindExistingServiceWorkerInfo(
181 storage_partition_path, service_worker_scope);
182 if (it == workers_.end()) 195 if (it == workers_.end())
183 return NULL; 196 return NULL;
184 return GetDevToolsAgentHostForWorker(it->first.first, it->first.second); 197 return GetDevToolsAgentHostForWorker(it->first.first, it->first.second);
185 } 198 }
186 199
187 EmbeddedWorkerDevToolsManager::EmbeddedWorkerDevToolsManager() { 200 EmbeddedWorkerDevToolsManager::EmbeddedWorkerDevToolsManager() {
188 } 201 }
189 202
190 EmbeddedWorkerDevToolsManager::~EmbeddedWorkerDevToolsManager() { 203 EmbeddedWorkerDevToolsManager::~EmbeddedWorkerDevToolsManager() {
191 } 204 }
(...skipping 10 matching lines...) Expand all
202 workers_.set(id, info.Pass()); 215 workers_.set(id, info.Pass());
203 return false; 216 return false;
204 } 217 }
205 MoveToPausedState(id, it); 218 MoveToPausedState(id, it);
206 return true; 219 return true;
207 } 220 }
208 221
209 bool EmbeddedWorkerDevToolsManager::ServiceWorkerCreated( 222 bool EmbeddedWorkerDevToolsManager::ServiceWorkerCreated(
210 int worker_process_id, 223 int worker_process_id,
211 int worker_route_id, 224 int worker_route_id,
212 const base::FilePath& storage_partition_path, 225 const ServiceWorkerIdentifier& service_worker_id) {
213 const GURL& service_worker_scope) {
214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 226 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
215 const WorkerId id(worker_process_id, worker_route_id); 227 const WorkerId id(worker_process_id, worker_route_id);
216 WorkerInfoMap::iterator it = FindExistingServiceWorkerInfo( 228 WorkerInfoMap::iterator it = FindExistingServiceWorkerInfo(service_worker_id);
217 storage_partition_path, service_worker_scope);
218 if (it == workers_.end()) { 229 if (it == workers_.end()) {
219 scoped_ptr<WorkerInfo> info( 230 scoped_ptr<WorkerInfo> info(new WorkerInfo(service_worker_id));
220 new WorkerInfo(storage_partition_path, service_worker_scope));
221 workers_.set(id, info.Pass()); 231 workers_.set(id, info.Pass());
222 return false; 232 return false;
223 } 233 }
224 MoveToPausedState(id, it); 234 MoveToPausedState(id, it);
225 return true; 235 return true;
226 } 236 }
227 237
228 void EmbeddedWorkerDevToolsManager::WorkerDestroyed(int worker_process_id, 238 void EmbeddedWorkerDevToolsManager::WorkerDestroyed(int worker_process_id,
229 int worker_route_id) { 239 int worker_route_id) {
230 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 WorkerInfoMap::iterator it = workers_.begin(); 319 WorkerInfoMap::iterator it = workers_.begin();
310 for (; it != workers_.end(); ++it) { 320 for (; it != workers_.end(); ++it) {
311 if (it->second->Matches(instance)) 321 if (it->second->Matches(instance))
312 break; 322 break;
313 } 323 }
314 return it; 324 return it;
315 } 325 }
316 326
317 EmbeddedWorkerDevToolsManager::WorkerInfoMap::iterator 327 EmbeddedWorkerDevToolsManager::WorkerInfoMap::iterator
318 EmbeddedWorkerDevToolsManager::FindExistingServiceWorkerInfo( 328 EmbeddedWorkerDevToolsManager::FindExistingServiceWorkerInfo(
319 const base::FilePath& storage_partition_path, 329 const ServiceWorkerIdentifier& service_worker_id) {
320 const GURL& service_worker_scope) {
321 WorkerInfoMap::iterator it = workers_.begin(); 330 WorkerInfoMap::iterator it = workers_.begin();
322 for (; it != workers_.end(); ++it) { 331 for (; it != workers_.end(); ++it) {
323 if (it->second->Matches(storage_partition_path, service_worker_scope)) 332 if (it->second->Matches(service_worker_id))
324 break; 333 break;
325 } 334 }
326 return it; 335 return it;
327 } 336 }
328 337
329 void EmbeddedWorkerDevToolsManager::MoveToPausedState( 338 void EmbeddedWorkerDevToolsManager::MoveToPausedState(
330 const WorkerId& id, 339 const WorkerId& id,
331 const WorkerInfoMap::iterator& it) { 340 const WorkerInfoMap::iterator& it) {
332 DCHECK_EQ(WORKER_TERMINATED, it->second->state()); 341 DCHECK_EQ(WORKER_TERMINATED, it->second->state());
333 scoped_ptr<WorkerInfo> info = workers_.take_and_erase(it); 342 scoped_ptr<WorkerInfo> info = workers_.take_and_erase(it);
334 info->set_state(WORKER_PAUSED); 343 info->set_state(WORKER_PAUSED);
335 workers_.set(id, info.Pass()); 344 workers_.set(id, info.Pass());
336 } 345 }
337 346
338 void EmbeddedWorkerDevToolsManager::ResetForTesting() { 347 void EmbeddedWorkerDevToolsManager::ResetForTesting() {
339 workers_.clear(); 348 workers_.clear();
340 } 349 }
341 350
342 } // namespace content 351 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/embedded_worker_devtools_manager.h ('k') | content/browser/service_worker/embedded_worker_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698