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

Unified Diff: content/browser/service_worker/service_worker_context_wrapper.cc

Issue 1951853004: DevTools: allow devtools to skipWaiting service workers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 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 c326aa5d89586e431b918e4e394c031b4297a53f..1a37f2002fa7197adae6f394eb5f105cc6b4c1c5 100644
--- a/content/browser/service_worker/service_worker_context_wrapper.cc
+++ b/content/browser/service_worker/service_worker_context_wrapper.cc
@@ -70,6 +70,17 @@ void StartActiveWorkerOnIO(
base::Bind(callback, SERVICE_WORKER_ERROR_NOT_FOUND));
}
+void SkipWaitingWorkerOnIO(
+ ServiceWorkerStatusCode status,
+ const scoped_refptr<ServiceWorkerRegistration>& registration) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (status != SERVICE_WORKER_OK || !registration->waiting_version())
+ return;
+
+ registration->waiting_version()->set_skip_waiting(true);
+ registration->ActivateWaitingVersionWhenReady();
+}
+
} // namespace
void ServiceWorkerContext::AddExcludedHeadersForFetchEvent(
@@ -291,6 +302,20 @@ void ServiceWorkerContextWrapper::StartServiceWorker(
base::Bind(&StartActiveWorkerOnIO, callback));
}
+void ServiceWorkerContextWrapper::SkipWaitingWorker(const GURL& pattern) {
+ if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&ServiceWorkerContextWrapper::SkipWaitingWorker, this,
+ pattern));
+ return;
+ }
+ if (!context_core_)
+ return;
+ context_core_->storage()->FindRegistrationForPattern(
+ net::SimplifyUrlForRequest(pattern), base::Bind(&SkipWaitingWorkerOnIO));
+}
+
void ServiceWorkerContextWrapper::SetForceUpdateOnPageLoad(
bool force_update_on_page_load) {
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {

Powered by Google App Engine
This is Rietveld 408576698