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

Unified Diff: content/child/service_worker/service_worker_dispatcher.cc

Issue 516823003: ServiceWorker: Change the return value of ServiceWorkerRegistration::unregister to boolean (2/4) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 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/child/service_worker/service_worker_dispatcher.cc
diff --git a/content/child/service_worker/service_worker_dispatcher.cc b/content/child/service_worker/service_worker_dispatcher.cc
index 032dfa2921d3ae5f4d6e83c25e0ee6bc49733a5d..9bc8c7e8a47591c67a057d6576e9e6b4914a3c4f 100644
--- a/content/child/service_worker/service_worker_dispatcher.cc
+++ b/content/child/service_worker/service_worker_dispatcher.cc
@@ -58,6 +58,8 @@ void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) {
OnUnregistered)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerRegistrationError,
OnRegistrationError)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerUnregistrationError,
+ OnUnregistrationError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerStateChanged,
OnServiceWorkerStateChanged)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetVersionAttributes,
@@ -94,7 +96,7 @@ void ServiceWorkerDispatcher::RegisterServiceWorker(
return;
}
- int request_id = pending_callbacks_.Add(callbacks);
+ int request_id = pending_registration_callbacks_.Add(callbacks);
thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker(
CurrentWorkerId(), request_id, provider_id, pattern, script_url));
}
@@ -102,11 +104,11 @@ void ServiceWorkerDispatcher::RegisterServiceWorker(
void ServiceWorkerDispatcher::UnregisterServiceWorker(
int provider_id,
const GURL& pattern,
- WebServiceWorkerRegistrationCallbacks* callbacks) {
+ WebServiceWorkerUnregistrationCallbacks* callbacks) {
DCHECK(callbacks);
if (pattern.possibly_invalid_spec().size() > GetMaxURLChars()) {
- scoped_ptr<WebServiceWorkerRegistrationCallbacks>
+ scoped_ptr<WebServiceWorkerUnregistrationCallbacks>
owned_callbacks(callbacks);
scoped_ptr<WebServiceWorkerError> error(new WebServiceWorkerError(
WebServiceWorkerError::ErrorTypeSecurity, "URL too long"));
@@ -114,7 +116,7 @@ void ServiceWorkerDispatcher::UnregisterServiceWorker(
return;
}
- int request_id = pending_callbacks_.Add(callbacks);
+ int request_id = pending_unregistration_callbacks_.Add(callbacks);
thread_safe_sender_->Send(new ServiceWorkerHostMsg_UnregisterServiceWorker(
CurrentWorkerId(), request_id, provider_id, pattern));
}
@@ -243,7 +245,7 @@ void ServiceWorkerDispatcher::OnRegistered(
const ServiceWorkerRegistrationObjectInfo& info,
const ServiceWorkerVersionAttributes& attrs) {
WebServiceWorkerRegistrationCallbacks* callbacks =
- pending_callbacks_.Lookup(request_id);
+ pending_registration_callbacks_.Lookup(request_id);
DCHECK(callbacks);
if (!callbacks)
return;
@@ -255,20 +257,24 @@ void ServiceWorkerDispatcher::OnRegistered(
registration->SetActive(GetServiceWorker(attrs.active, true));
callbacks->onSuccess(registration);
- pending_callbacks_.Remove(request_id);
+ pending_registration_callbacks_.Remove(request_id);
}
void ServiceWorkerDispatcher::OnUnregistered(
int thread_id,
int request_id) {
- WebServiceWorkerRegistrationCallbacks* callbacks =
- pending_callbacks_.Lookup(request_id);
+ WebServiceWorkerUnregistrationCallbacks* callbacks =
+ pending_unregistration_callbacks_.Lookup(request_id);
DCHECK(callbacks);
if (!callbacks)
return;
-
+#ifdef DISABLE_SERVICEWORKER_UNREGISTER_RESOLVE_TO_BOOLEAN
callbacks->onSuccess(NULL);
- pending_callbacks_.Remove(request_id);
+#else
+ bool is_success = true;
+ callbacks->onSuccess(&is_success);
+#endif
+ pending_unregistration_callbacks_.Remove(request_id);
}
void ServiceWorkerDispatcher::OnRegistrationError(
@@ -277,7 +283,24 @@ void ServiceWorkerDispatcher::OnRegistrationError(
WebServiceWorkerError::ErrorType error_type,
const base::string16& message) {
WebServiceWorkerRegistrationCallbacks* callbacks =
- pending_callbacks_.Lookup(request_id);
+ pending_registration_callbacks_.Lookup(request_id);
+ DCHECK(callbacks);
+ if (!callbacks)
+ return;
+
+ scoped_ptr<WebServiceWorkerError> error(
+ new WebServiceWorkerError(error_type, message));
+ callbacks->onError(error.release());
+ pending_registration_callbacks_.Remove(request_id);
+}
+
+void ServiceWorkerDispatcher::OnUnregistrationError(
+ int thread_id,
+ int request_id,
+ WebServiceWorkerError::ErrorType error_type,
+ const base::string16& message) {
+ WebServiceWorkerUnregistrationCallbacks* callbacks =
+ pending_unregistration_callbacks_.Lookup(request_id);
DCHECK(callbacks);
if (!callbacks)
return;
@@ -285,7 +308,7 @@ void ServiceWorkerDispatcher::OnRegistrationError(
scoped_ptr<WebServiceWorkerError> error(
new WebServiceWorkerError(error_type, message));
callbacks->onError(error.release());
- pending_callbacks_.Remove(request_id);
+ pending_unregistration_callbacks_.Remove(request_id);
}
void ServiceWorkerDispatcher::OnServiceWorkerStateChanged(

Powered by Google App Engine
This is Rietveld 408576698