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

Side by Side Diff: content/browser/service_worker/service_worker_context_wrapper.cc

Issue 1432823003: Add a test to cover service worker update codepath when extension is updated (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use set_force_update_on_page_load() + git cl format Created 5 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/service_worker/service_worker_context_wrapper.h" 5 #include "content/browser/service_worker/service_worker_context_wrapper.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 usage_info.scopes.push_back(registration_info.pattern); 325 usage_info.scopes.push_back(registration_info.pattern);
326 usage_info.total_size_bytes += registration_info.stored_version_size_bytes; 326 usage_info.total_size_bytes += registration_info.stored_version_size_bytes;
327 } 327 }
328 328
329 for (const auto& origin_info_pair : origins) { 329 for (const auto& origin_info_pair : origins) {
330 usage_infos.push_back(origin_info_pair.second); 330 usage_infos.push_back(origin_info_pair.second);
331 } 331 }
332 callback.Run(usage_infos); 332 callback.Run(usage_infos);
333 } 333 }
334 334
335 void ServiceWorkerContextWrapper::DidGetRegistrationsForForceUpdateForOrigin(
336 const std::vector<scoped_refptr<ServiceWorkerRegistration>>&
337 registrations) {
338 for (const auto& registration : registrations)
339 registration->set_force_update_on_page_load(true);
340 }
341
335 void ServiceWorkerContextWrapper::DidCheckHasServiceWorker( 342 void ServiceWorkerContextWrapper::DidCheckHasServiceWorker(
336 const CheckHasServiceWorkerCallback& callback, 343 const CheckHasServiceWorkerCallback& callback,
337 bool has_service_worker) { 344 bool has_service_worker) {
338 DCHECK_CURRENTLY_ON(BrowserThread::IO); 345 DCHECK_CURRENTLY_ON(BrowserThread::IO);
339 346
340 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 347 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
341 base::Bind(callback, has_service_worker)); 348 base::Bind(callback, has_service_worker));
342 } 349 }
343 350
344 void ServiceWorkerContextWrapper::StopAllServiceWorkersForOrigin( 351 void ServiceWorkerContextWrapper::StopAllServiceWorkersForOrigin(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 BrowserThread::PostTask( 411 BrowserThread::PostTask(
405 BrowserThread::IO, 412 BrowserThread::IO,
406 FROM_HERE, 413 FROM_HERE,
407 base::Bind(result, false)); 414 base::Bind(result, false));
408 return; 415 return;
409 } 416 }
410 context()->UnregisterServiceWorkers( 417 context()->UnregisterServiceWorkers(
411 origin.GetOrigin(), base::Bind(&StatusCodeToBoolCallbackAdapter, result)); 418 origin.GetOrigin(), base::Bind(&StatusCodeToBoolCallbackAdapter, result));
412 } 419 }
413 420
421 void ServiceWorkerContextWrapper::SetForceUpdateOnPageLoadForOrigin(
422 const GURL& origin) {
423 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
424 BrowserThread::PostTask(
425 BrowserThread::IO, FROM_HERE,
426 base::Bind(
427 &ServiceWorkerContextWrapper::SetForceUpdateOnPageLoadForOrigin,
428 this, origin));
429 return;
430 }
431
432 if (!context_core_)
433 return;
434
435 context_core_->storage()->GetRegistrationsForOrigin(
436 origin.GetOrigin(),
437 base::Bind(&ServiceWorkerContextWrapper::
438 DidGetRegistrationsForForceUpdateForOrigin,
439 this));
440 }
441
414 void ServiceWorkerContextWrapper::CheckHasServiceWorker( 442 void ServiceWorkerContextWrapper::CheckHasServiceWorker(
415 const GURL& url, 443 const GURL& url,
416 const GURL& other_url, 444 const GURL& other_url,
417 const CheckHasServiceWorkerCallback& callback) { 445 const CheckHasServiceWorkerCallback& callback) {
418 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 446 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
419 BrowserThread::PostTask( 447 BrowserThread::PostTask(
420 BrowserThread::IO, FROM_HERE, 448 BrowserThread::IO, FROM_HERE,
421 base::Bind(&ServiceWorkerContextWrapper::CheckHasServiceWorker, this, 449 base::Bind(&ServiceWorkerContextWrapper::CheckHasServiceWorker, this,
422 url, other_url, callback)); 450 url, other_url, callback));
423 return; 451 return;
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 observer_list_->Notify(FROM_HERE, 720 observer_list_->Notify(FROM_HERE,
693 &ServiceWorkerContextObserver::OnStorageWiped); 721 &ServiceWorkerContextObserver::OnStorageWiped);
694 } 722 }
695 723
696 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { 724 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() {
697 DCHECK_CURRENTLY_ON(BrowserThread::IO); 725 DCHECK_CURRENTLY_ON(BrowserThread::IO);
698 return context_core_.get(); 726 return context_core_.get();
699 } 727 }
700 728
701 } // namespace content 729 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698