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

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

Issue 1270513002: Service Worker: Make ServiceWorkerRegistration.update() return a promise. (Chromium 2/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass a raw ptr to callback's onError instead of a scoped_ptr. Created 5 years, 5 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_core.cc
diff --git a/content/browser/service_worker/service_worker_context_core.cc b/content/browser/service_worker/service_worker_context_core.cc
index 0416733b35fd9fec878fa3d7a7e3d8c08f54f817..910fe81e224e78c4a6ccb86362db23b5b383c4f8 100644
--- a/content/browser/service_worker/service_worker_context_core.cc
+++ b/content/browser/service_worker/service_worker_context_core.cc
@@ -271,6 +271,33 @@ void ServiceWorkerContextCore::RegisterServiceWorker(
callback));
}
+void ServiceWorkerContextCore::UpdateServiceWorker(
+ ServiceWorkerRegistration* registration,
+ bool force_bypass_cache) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (storage()->IsDisabled())
+ return;
+
+ job_coordinator_->Update(registration, force_bypass_cache);
+}
+
+void ServiceWorkerContextCore::UpdateServiceWorker(
+ ServiceWorkerRegistration* registration,
+ bool force_bypass_cache,
+ ServiceWorkerProviderHost* provider_host,
+ const UpdateCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (storage()->IsDisabled()) {
+ callback.Run(SERVICE_WORKER_ERROR_ABORT, std::string(),
+ kInvalidServiceWorkerRegistrationId);
+ return;
+ }
+
+ job_coordinator_->Update(registration, force_bypass_cache, provider_host,
+ base::Bind(&ServiceWorkerContextCore::UpdateComplete,
+ AsWeakPtr(), callback));
+}
+
void ServiceWorkerContextCore::UnregisterServiceWorker(
const GURL& pattern,
const UnregistrationCallback& callback) {
@@ -325,15 +352,6 @@ void ServiceWorkerContextCore::DidGetAllRegistrationsForUnregisterForOrigin(
}
}
-void ServiceWorkerContextCore::UpdateServiceWorker(
- ServiceWorkerRegistration* registration,
- bool force_bypass_cache) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- if (storage()->IsDisabled())
- return;
- job_coordinator_->Update(registration, force_bypass_cache);
-}
-
void ServiceWorkerContextCore::RegistrationComplete(
const GURL& pattern,
const ServiceWorkerContextCore::RegistrationCallback& callback,
@@ -358,6 +376,21 @@ void ServiceWorkerContextCore::RegistrationComplete(
}
}
+void ServiceWorkerContextCore::UpdateComplete(
+ const ServiceWorkerContextCore::UpdateCallback& callback,
+ ServiceWorkerStatusCode status,
+ const std::string& status_message,
+ ServiceWorkerRegistration* registration) {
+ if (status != SERVICE_WORKER_OK) {
+ DCHECK(!registration);
+ callback.Run(status, status_message, kInvalidServiceWorkerRegistrationId);
+ return;
+ }
+
+ DCHECK(registration);
+ callback.Run(status, status_message, registration->id());
+}
+
void ServiceWorkerContextCore::UnregistrationComplete(
const GURL& pattern,
const ServiceWorkerContextCore::UnregistrationCallback& callback,

Powered by Google App Engine
This is Rietveld 408576698