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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_context_wrapper.cc
diff --git a/content/browser/service_worker/service_worker_context_wrapper.cc b/content/browser/service_worker/service_worker_context_wrapper.cc
index aaa375848dd8565094dce92a1fd6447833f22803..6095aab94d72a64e0eb27fe4420d89e1b0cd232c 100644
--- a/content/browser/service_worker/service_worker_context_wrapper.cc
+++ b/content/browser/service_worker/service_worker_context_wrapper.cc
@@ -332,6 +332,13 @@ void ServiceWorkerContextWrapper::DidGetAllRegistrationsForGetAllOrigins(
callback.Run(usage_infos);
}
+void ServiceWorkerContextWrapper::DidGetRegistrationsForForceUpdateForOrigin(
+ const std::vector<scoped_refptr<ServiceWorkerRegistration>>&
+ registrations) {
+ for (const auto& registration : registrations)
+ registration->set_force_update_on_page_load(true);
+}
+
void ServiceWorkerContextWrapper::DidCheckHasServiceWorker(
const CheckHasServiceWorkerCallback& callback,
bool has_service_worker) {
@@ -411,6 +418,27 @@ void ServiceWorkerContextWrapper::DeleteForOrigin(
origin.GetOrigin(), base::Bind(&StatusCodeToBoolCallbackAdapter, result));
}
+void ServiceWorkerContextWrapper::SetForceUpdateOnPageLoadForOrigin(
+ const GURL& origin) {
+ if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(
+ &ServiceWorkerContextWrapper::SetForceUpdateOnPageLoadForOrigin,
+ this, origin));
+ return;
+ }
+
+ if (!context_core_)
+ return;
+
+ context_core_->storage()->GetRegistrationsForOrigin(
+ origin.GetOrigin(),
+ base::Bind(&ServiceWorkerContextWrapper::
+ DidGetRegistrationsForForceUpdateForOrigin,
+ this));
+}
+
void ServiceWorkerContextWrapper::CheckHasServiceWorker(
const GURL& url,
const GURL& other_url,

Powered by Google App Engine
This is Rietveld 408576698