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

Side by Side Diff: content/browser/devtools/protocol/service_worker_handler.cc

Issue 1024543003: DevTools: hand over SW inspection to chrome://inspect upon request. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/protocol/service_worker_handler.h" 5 #include "content/browser/devtools/protocol/service_worker_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/containers/scoped_ptr_hash_map.h" 8 #include "base/containers/scoped_ptr_hash_map.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "content/browser/devtools/service_worker_devtools_agent_host.h" 10 #include "content/browser/devtools/service_worker_devtools_agent_host.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 if (render_frame_host_) { 185 if (render_frame_host_) {
186 render_frame_host_->frame_tree_node()->frame_tree()->ForEach( 186 render_frame_host_->frame_tree_node()->frame_tree()->ForEach(
187 base::Bind(&CollectURLs, &urls_)); 187 base::Bind(&CollectURLs, &urls_));
188 } 188 }
189 189
190 ServiceWorkerDevToolsAgentHost::Map old_hosts = attached_hosts_; 190 ServiceWorkerDevToolsAgentHost::Map old_hosts = attached_hosts_;
191 ServiceWorkerDevToolsAgentHost::Map new_hosts = 191 ServiceWorkerDevToolsAgentHost::Map new_hosts =
192 GetMatchingServiceWorkers(urls_); 192 GetMatchingServiceWorkers(urls_);
193 193
194 for (auto pair : old_hosts) { 194 for (auto pair : old_hosts) {
195 if (new_hosts.find(pair.first) == new_hosts.end()) 195 if (new_hosts.find(pair.first) == new_hosts.end()) {
196 pair.second->DetachClient();
196 ReportWorkerTerminated(pair.second.get()); 197 ReportWorkerTerminated(pair.second.get());
198 }
197 } 199 }
198 200
199 for (auto pair : new_hosts) { 201 for (auto pair : new_hosts) {
200 if (old_hosts.find(pair.first) == old_hosts.end()) 202 if (old_hosts.find(pair.first) == old_hosts.end())
201 ReportWorkerCreated(pair.second.get()); 203 ReportWorkerCreated(pair.second.get());
202 } 204 }
203 } 205 }
204 206
205 void ServiceWorkerHandler::Detached() { 207 void ServiceWorkerHandler::Detached() {
206 Disable(); 208 Disable();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 294
293 client_->DispatchMessage( 295 client_->DispatchMessage(
294 DispatchMessageParams::Create()-> 296 DispatchMessageParams::Create()->
295 set_worker_id(host->GetId())-> 297 set_worker_id(host->GetId())->
296 set_message(message)); 298 set_message(message));
297 } 299 }
298 300
299 void ServiceWorkerHandler::AgentHostClosed( 301 void ServiceWorkerHandler::AgentHostClosed(
300 DevToolsAgentHost* host, 302 DevToolsAgentHost* host,
301 bool replaced_with_another_client) { 303 bool replaced_with_another_client) {
302 WorkerDestroyed(static_cast<ServiceWorkerDevToolsAgentHost*>(host)); 304 ReportWorkerTerminated(static_cast<ServiceWorkerDevToolsAgentHost*>(host));
dgozman 2015/03/20 09:42:44 Let's remove host from |attached_hosts_| right her
pfeldman 2015/03/20 10:05:25 What you are suggesting is worse since we should o
303 } 305 }
304 306
305 void ServiceWorkerHandler::WorkerCreated( 307 void ServiceWorkerHandler::WorkerCreated(
306 ServiceWorkerDevToolsAgentHost* host) { 308 ServiceWorkerDevToolsAgentHost* host) {
307 auto hosts = GetMatchingServiceWorkers(urls_); 309 auto hosts = GetMatchingServiceWorkers(urls_);
308 if (hosts.find(host->GetId()) != hosts.end()) 310 if (hosts.find(host->GetId()) != hosts.end() && !host->IsAttached())
309 host->PauseForDebugOnStart(); 311 host->PauseForDebugOnStart();
310 } 312 }
311 313
312 void ServiceWorkerHandler::WorkerReadyForInspection( 314 void ServiceWorkerHandler::WorkerReadyForInspection(
313 ServiceWorkerDevToolsAgentHost* host) { 315 ServiceWorkerDevToolsAgentHost* host) {
314 UpdateHosts(); 316 UpdateHosts();
315 } 317 }
316 318
317 void ServiceWorkerHandler::WorkerDestroyed( 319 void ServiceWorkerHandler::WorkerDestroyed(
318 ServiceWorkerDevToolsAgentHost* host) { 320 ServiceWorkerDevToolsAgentHost* host) {
319 UpdateHosts(); 321 UpdateHosts();
320 } 322 }
321 323
322 void ServiceWorkerHandler::ReportWorkerCreated( 324 void ServiceWorkerHandler::ReportWorkerCreated(
323 ServiceWorkerDevToolsAgentHost* host) { 325 ServiceWorkerDevToolsAgentHost* host) {
324 if (host->IsAttached()) 326 if (host->IsAttached())
325 return; 327 return;
326 attached_hosts_[host->GetId()] = host; 328 attached_hosts_[host->GetId()] = host;
327 host->AttachClient(this); 329 host->AttachClient(this);
328 client_->WorkerCreated(WorkerCreatedParams::Create()-> 330 client_->WorkerCreated(WorkerCreatedParams::Create()->
329 set_worker_id(host->GetId())-> 331 set_worker_id(host->GetId())->
330 set_url(host->GetURL().spec())); 332 set_url(host->GetURL().spec()));
331 } 333 }
332 334
333 void ServiceWorkerHandler::ReportWorkerTerminated( 335 void ServiceWorkerHandler::ReportWorkerTerminated(
334 ServiceWorkerDevToolsAgentHost* host) { 336 ServiceWorkerDevToolsAgentHost* host) {
335 auto it = attached_hosts_.find(host->GetId()); 337 auto it = attached_hosts_.find(host->GetId());
336 if (it == attached_hosts_.end()) 338 if (it == attached_hosts_.end())
337 return; 339 return;
338 it->second->DetachClient();
339 client_->WorkerTerminated(WorkerTerminatedParams::Create()-> 340 client_->WorkerTerminated(WorkerTerminatedParams::Create()->
340 set_worker_id(host->GetId())); 341 set_worker_id(host->GetId()));
341 attached_hosts_.erase(it); 342 attached_hosts_.erase(it);
342 } 343 }
343 344
344 } // namespace service_worker 345 } // namespace service_worker
345 } // namespace devtools 346 } // namespace devtools
346 } // namespace content 347 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698