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 832a171977886761d80378646c7a23bcfd959483..1bf6c1770cd9a9d649418620bf8ce86c8341d346 100644 |
--- a/content/child/service_worker/service_worker_dispatcher.cc |
+++ b/content/child/service_worker/service_worker_dispatcher.cc |
@@ -57,10 +57,14 @@ void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) { |
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerRegistered, OnRegistered) |
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerUnregistered, |
OnUnregistered) |
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetRegistration, |
+ OnDidGetRegistration) |
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerRegistrationError, |
OnRegistrationError) |
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerUnregistrationError, |
OnUnregistrationError) |
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerGetRegistrationError, |
+ OnGetRegistrationError) |
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerStateChanged, |
OnServiceWorkerStateChanged) |
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetVersionAttributes, |
@@ -131,6 +135,26 @@ void ServiceWorkerDispatcher::UnregisterServiceWorker( |
CurrentWorkerId(), request_id, provider_id, pattern)); |
} |
+void ServiceWorkerDispatcher::GetRegistration( |
+ int provider_id, |
+ const GURL& document_url, |
+ WebServiceWorkerRegistrationCallbacks* callbacks) { |
+ DCHECK(callbacks); |
+ |
+ if (document_url.possibly_invalid_spec().size() > GetMaxURLChars()) { |
+ scoped_ptr<WebServiceWorkerRegistrationCallbacks> |
+ owned_callbacks(callbacks); |
+ scoped_ptr<WebServiceWorkerError> error(new WebServiceWorkerError( |
+ WebServiceWorkerError::ErrorTypeSecurity, "URL too long")); |
+ callbacks->onError(error.release()); |
+ return; |
+ } |
+ |
+ int request_id = pending_get_registration_callbacks_.Add(callbacks); |
+ thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistration( |
+ CurrentWorkerId(), request_id, provider_id, document_url)); |
+} |
+ |
void ServiceWorkerDispatcher::AddProviderContext( |
ServiceWorkerProviderContext* provider_context) { |
DCHECK(provider_context); |
@@ -298,6 +322,28 @@ void ServiceWorkerDispatcher::OnUnregistered( |
request_id); |
} |
+void ServiceWorkerDispatcher::OnDidGetRegistration( |
+ int thread_id, |
+ int request_id, |
+ const ServiceWorkerRegistrationObjectInfo& info, |
+ const ServiceWorkerVersionAttributes& attrs) { |
+ WebServiceWorkerRegistrationCallbacks* callbacks = |
+ pending_get_registration_callbacks_.Lookup(request_id); |
+ DCHECK(callbacks); |
+ if (!callbacks) |
+ return; |
+ |
+ WebServiceWorkerRegistrationImpl* registration = |
+ GetServiceWorkerRegistration(info, true); |
nhiroki
2014/09/10 04:07:22
FYI: I guess you copied these registration handlin
Kunihiko Sakamoto
2014/09/10 08:22:44
Acknowledged.
|
+ if (registration) { |
+ registration->SetInstalling(GetServiceWorker(attrs.installing, true)); |
+ registration->SetWaiting(GetServiceWorker(attrs.waiting, true)); |
+ registration->SetActive(GetServiceWorker(attrs.active, true)); |
+ } |
+ callbacks->onSuccess(registration); |
+ pending_get_registration_callbacks_.Remove(request_id); |
+} |
+ |
void ServiceWorkerDispatcher::OnRegistrationError( |
int thread_id, |
int request_id, |
@@ -347,6 +393,23 @@ void ServiceWorkerDispatcher::OnUnregistrationError( |
request_id); |
} |
+void ServiceWorkerDispatcher::OnGetRegistrationError( |
+ int thread_id, |
+ int request_id, |
+ WebServiceWorkerError::ErrorType error_type, |
+ const base::string16& message) { |
nhiroki
2014/09/10 04:07:22
Can you add TRACE_EVENTs like OnRegistrationError?
Kunihiko Sakamoto
2014/09/10 08:22:44
Done.
|
+ WebServiceWorkerGetRegistrationCallbacks* callbacks = |
+ pending_get_registration_callbacks_.Lookup(request_id); |
+ DCHECK(callbacks); |
+ if (!callbacks) |
+ return; |
+ |
+ scoped_ptr<WebServiceWorkerError> error( |
+ new WebServiceWorkerError(error_type, message)); |
+ callbacks->onError(error.release()); |
+ pending_get_registration_callbacks_.Remove(request_id); |
+} |
+ |
void ServiceWorkerDispatcher::OnServiceWorkerStateChanged( |
int thread_id, |
int handle_id, |