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

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

Issue 1841863003: DevTools: move the force update SW on reload checkbox to the Resources / Service Workers view. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 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 "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 127
128 scoped_refptr<ServiceWorkerRegistration> CreateRegistrationDictionaryValue( 128 scoped_refptr<ServiceWorkerRegistration> CreateRegistrationDictionaryValue(
129 const ServiceWorkerRegistrationInfo& registration_info) { 129 const ServiceWorkerRegistrationInfo& registration_info) {
130 scoped_refptr<ServiceWorkerRegistration> registration( 130 scoped_refptr<ServiceWorkerRegistration> registration(
131 ServiceWorkerRegistration::Create() 131 ServiceWorkerRegistration::Create()
132 ->set_registration_id( 132 ->set_registration_id(
133 base::Int64ToString(registration_info.registration_id)) 133 base::Int64ToString(registration_info.registration_id))
134 ->set_scope_url(registration_info.pattern.spec()) 134 ->set_scope_url(registration_info.pattern.spec())
135 ->set_is_deleted(registration_info.delete_flag == 135 ->set_is_deleted(registration_info.delete_flag ==
136 ServiceWorkerRegistrationInfo::IS_DELETED) 136 ServiceWorkerRegistrationInfo::IS_DELETED));
137 ->set_force_update_on_page_load(
138 registration_info.force_update_on_page_load ==
139 ServiceWorkerRegistrationInfo::IS_FORCED));
140 return registration; 137 return registration;
141 } 138 }
142 139
143 scoped_refptr<ServiceWorkerDevToolsAgentHost> GetMatchingServiceWorker( 140 scoped_refptr<ServiceWorkerDevToolsAgentHost> GetMatchingServiceWorker(
144 const ServiceWorkerDevToolsAgentHost::List& agent_hosts, 141 const ServiceWorkerDevToolsAgentHost::List& agent_hosts,
145 const GURL& url) { 142 const GURL& url) {
146 scoped_refptr<ServiceWorkerDevToolsAgentHost> best_host; 143 scoped_refptr<ServiceWorkerDevToolsAgentHost> best_host;
147 bool best_host_scope_matched = false; 144 bool best_host_scope_matched = false;
148 int best_host_scope_length = 0; 145 int best_host_scope_length = 0;
149 146
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 return Response::OK(); 419 return Response::OK();
423 } 420 }
424 421
425 Response ServiceWorkerHandler::SetDebugOnStart(bool debug_on_start) { 422 Response ServiceWorkerHandler::SetDebugOnStart(bool debug_on_start) {
426 ServiceWorkerDevToolsManager::GetInstance() 423 ServiceWorkerDevToolsManager::GetInstance()
427 ->set_debug_service_worker_on_start(debug_on_start); 424 ->set_debug_service_worker_on_start(debug_on_start);
428 return Response::OK(); 425 return Response::OK();
429 } 426 }
430 427
431 Response ServiceWorkerHandler::SetForceUpdateOnPageLoad( 428 Response ServiceWorkerHandler::SetForceUpdateOnPageLoad(
432 const std::string& registration_id,
433 bool force_update_on_page_load) { 429 bool force_update_on_page_load) {
434 if (!context_) 430 if (!context_)
435 return CreateContextErrorResponse(); 431 return CreateContextErrorResponse();
436 int64_t id = kInvalidServiceWorkerRegistrationId; 432 context_->SetForceUpdateOnPageLoad(force_update_on_page_load);
437 if (!base::StringToInt64(registration_id, &id))
438 return CreateInvalidVersionIdErrorResponse();
439 if (force_update_on_page_load)
440 force_update_enabled_registrations_.insert(id);
441 else
442 force_update_enabled_registrations_.erase(id);
443 context_->SetForceUpdateOnPageLoad(id, force_update_on_page_load);
444 return Response::OK(); 433 return Response::OK();
445 } 434 }
446 435
447 Response ServiceWorkerHandler::DeliverPushMessage( 436 Response ServiceWorkerHandler::DeliverPushMessage(
448 const std::string& origin, 437 const std::string& origin,
449 const std::string& registration_id, 438 const std::string& registration_id,
450 const std::string& data) { 439 const std::string& data) {
451 if (!enabled_) 440 if (!enabled_)
452 return Response::OK(); 441 return Response::OK();
453 if (!render_frame_host_) 442 if (!render_frame_host_)
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 auto it = attached_hosts_.find(host->GetId()); 598 auto it = attached_hosts_.find(host->GetId());
610 if (it == attached_hosts_.end()) 599 if (it == attached_hosts_.end())
611 return; 600 return;
612 host->DetachClient(); 601 host->DetachClient();
613 client_->WorkerTerminated(WorkerTerminatedParams::Create()-> 602 client_->WorkerTerminated(WorkerTerminatedParams::Create()->
614 set_worker_id(host->GetId())); 603 set_worker_id(host->GetId()));
615 attached_hosts_.erase(it); 604 attached_hosts_.erase(it);
616 } 605 }
617 606
618 void ServiceWorkerHandler::ClearForceUpdate() { 607 void ServiceWorkerHandler::ClearForceUpdate() {
619 if (context_) { 608 if (context_)
620 for (const auto registration_id : force_update_enabled_registrations_) 609 context_->SetForceUpdateOnPageLoad(false);
621 context_->SetForceUpdateOnPageLoad(registration_id, false);
622 }
623 force_update_enabled_registrations_.clear();
624 } 610 }
625 611
626 } // namespace service_worker 612 } // namespace service_worker
627 } // namespace devtools 613 } // namespace devtools
628 } // namespace content 614 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698