| 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..a735a64f5fd8387d29db80c25854061d400ed879 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,30 @@ 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);
|
| + TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker",
|
| + "ServiceWorkerDispatcher::GetRegistration",
|
| + request_id,
|
| + "Document URL", document_url.spec());
|
| + 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 +326,36 @@ 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);
|
| + TRACE_EVENT_ASYNC_STEP_INTO0(
|
| + "ServiceWorker",
|
| + "ServiceWorkerDispatcher::GetRegistration",
|
| + request_id,
|
| + "OnDidGetRegistration");
|
| + 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);
|
| + pending_get_registration_callbacks_.Remove(request_id);
|
| + TRACE_EVENT_ASYNC_END0("ServiceWorker",
|
| + "ServiceWorkerDispatcher::GetRegistration",
|
| + request_id);
|
| +}
|
| +
|
| void ServiceWorkerDispatcher::OnRegistrationError(
|
| int thread_id,
|
| int request_id,
|
| @@ -347,6 +405,31 @@ void ServiceWorkerDispatcher::OnUnregistrationError(
|
| request_id);
|
| }
|
|
|
| +void ServiceWorkerDispatcher::OnGetRegistrationError(
|
| + int thread_id,
|
| + int request_id,
|
| + WebServiceWorkerError::ErrorType error_type,
|
| + const base::string16& message) {
|
| + TRACE_EVENT_ASYNC_STEP_INTO0(
|
| + "ServiceWorker",
|
| + "ServiceWorkerDispatcher::GetRegistration",
|
| + request_id,
|
| + "OnGetRegistrationError");
|
| + 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);
|
| + TRACE_EVENT_ASYNC_END0("ServiceWorker",
|
| + "ServiceWorkerDispatcher::GetRegistration",
|
| + request_id);
|
| +}
|
| +
|
| void ServiceWorkerDispatcher::OnServiceWorkerStateChanged(
|
| int thread_id,
|
| int handle_id,
|
|
|