Index: content/browser/service_worker/service_worker_dispatcher_host.cc |
diff --git a/content/browser/service_worker/service_worker_dispatcher_host.cc b/content/browser/service_worker/service_worker_dispatcher_host.cc |
index 44d5b796cc17791de8f48d6c013f442d26eb09ab..60c05b59a7704f29de05129fda163fab1164b691 100644 |
--- a/content/browser/service_worker/service_worker_dispatcher_host.cc |
+++ b/content/browser/service_worker/service_worker_dispatcher_host.cc |
@@ -110,6 +110,8 @@ bool ServiceWorkerDispatcherHost::OnMessageReceived( |
OnRegisterServiceWorker) |
IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_UnregisterServiceWorker, |
OnUnregisterServiceWorker) |
+ IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetRegistration, |
+ OnGetRegistration) |
IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ProviderCreated, |
OnProviderCreated) |
IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ProviderDestroyed, |
@@ -267,6 +269,44 @@ void ServiceWorkerDispatcherHost::OnUnregisterServiceWorker( |
request_id)); |
} |
+void ServiceWorkerDispatcherHost::OnGetRegistration( |
+ int thread_id, |
+ int request_id, |
+ int provider_id, |
+ const GURL& document_url) { |
+ if (!GetContext()) { |
+ Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
+ thread_id, |
+ request_id, |
+ blink::WebServiceWorkerError::ErrorTypeAbort, |
+ base::ASCIIToUTF16(kShutdownErrorMessage))); |
+ return; |
+ } |
+ |
+ ServiceWorkerProviderHost* provider_host = GetContext()->GetProviderHost( |
+ render_process_id_, provider_id); |
+ if (!provider_host) { |
+ BadMessageReceived(); |
+ return; |
+ } |
+ if (!provider_host->IsContextAlive()) { |
+ Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
+ thread_id, |
+ request_id, |
+ blink::WebServiceWorkerError::ErrorTypeAbort, |
+ base::ASCIIToUTF16(kShutdownErrorMessage))); |
+ return; |
+ } |
+ |
+ GetContext()->GetRegistration( |
+ document_url, |
+ base::Bind(&ServiceWorkerDispatcherHost::GetRegistrationComplete, |
+ this, |
+ thread_id, |
+ provider_id, |
+ request_id)); |
+} |
+ |
void ServiceWorkerDispatcherHost::OnPostMessageToWorker( |
int handle_id, |
const base::string16& message, |
@@ -542,6 +582,54 @@ void ServiceWorkerDispatcherHost::UnregistrationComplete( |
Send(new ServiceWorkerMsg_ServiceWorkerUnregistered(thread_id, request_id)); |
} |
+void ServiceWorkerDispatcherHost::GetRegistrationComplete( |
+ int thread_id, |
+ int provider_id, |
+ int request_id, |
+ ServiceWorkerStatusCode status, |
+ int64 registration_id) { |
+ if (!GetContext()) |
+ return; |
+ |
+ if (status != SERVICE_WORKER_OK) { |
+ SendRegistrationError(thread_id, request_id, status); |
+ return; |
+ } |
+ |
+ ServiceWorkerRegistrationObjectInfo info; |
+ ServiceWorkerVersionAttributes attrs; |
+ |
+ if (registration_id != kInvalidServiceWorkerRegistrationId) { |
+ ServiceWorkerRegistration* registration = |
+ GetContext()->GetLiveRegistration(registration_id); |
+ DCHECK(registration); |
+ |
+ ServiceWorkerRegistrationHandle* handle = |
+ FindRegistrationHandle(provider_id, registration_id); |
+ if (handle) { |
+ handle->IncrementRefCount(); |
+ info = handle->GetObjectInfo(); |
+ } else { |
+ scoped_ptr<ServiceWorkerRegistrationHandle> new_handle( |
+ new ServiceWorkerRegistrationHandle( |
+ GetContext()->AsWeakPtr(), this, provider_id, registration)); |
+ info = new_handle->GetObjectInfo(); |
+ handle = new_handle.get(); |
+ RegisterServiceWorkerRegistrationHandle(new_handle.Pass()); |
+ } |
+ |
+ attrs.installing = handle->CreateServiceWorkerHandleAndPass( |
+ registration->installing_version()); |
+ attrs.waiting = handle->CreateServiceWorkerHandleAndPass( |
+ registration->waiting_version()); |
+ attrs.active = handle->CreateServiceWorkerHandleAndPass( |
+ registration->active_version()); |
nhiroki
2014/09/05 04:55:09
Since RegistrationComplete does the same thing, ca
Kunihiko Sakamoto
2014/09/09 07:28:10
Done.
|
+ } |
+ |
+ Send(new ServiceWorkerMsg_DidGetRegistration( |
+ thread_id, request_id, info, attrs)); |
+} |
+ |
void ServiceWorkerDispatcherHost::SendRegistrationError( |
int thread_id, |
int request_id, |