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..eb05799c13285b6c1133cbf457250f20b6f17d4e 100644 |
--- a/content/child/service_worker/service_worker_dispatcher.cc |
+++ b/content/child/service_worker/service_worker_dispatcher.cc |
@@ -56,6 +56,8 @@ 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_ServiceWorkerStateChanged, |
@@ -119,6 +121,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_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); |
@@ -271,6 +293,28 @@ void ServiceWorkerDispatcher::OnUnregistered( |
pending_callbacks_.Remove(request_id); |
} |
+void ServiceWorkerDispatcher::OnDidGetRegistration( |
+ int thread_id, |
+ int request_id, |
+ const ServiceWorkerRegistrationObjectInfo& info, |
+ const ServiceWorkerVersionAttributes& attrs) { |
+ WebServiceWorkerRegistrationCallbacks* callbacks = |
+ pending_callbacks_.Lookup(request_id); |
+ DCHECK(callbacks); |
+ if (!callbacks) |
+ return; |
+ |
+ WebServiceWorkerRegistrationImpl* registration = |
+ GetServiceWorkerRegistration(info, true); |
+ if (registration) { |
+ registration->SetInstalling(GetServiceWorker(attrs.installing, true)); |
+ registration->SetWaiting(GetServiceWorker(attrs.waiting, true)); |
+ registration->SetActive(GetServiceWorker(attrs.active, true)); |
+ } |
+ callbacks->onSuccess(registration); |
nhiroki
2014/09/05 04:55:09
I guess this could be resolved with 'null' if a re
Kunihiko Sakamoto
2014/09/09 07:28:10
Done (in Blink side).
|
+ pending_callbacks_.Remove(request_id); |
+} |
+ |
void ServiceWorkerDispatcher::OnRegistrationError( |
int thread_id, |
int request_id, |