| 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 dfbcfc18f6c06fb4e2e20fd6796f1fa9e81b3b64..f2a25da5d3e39f6e4d6f7ae2b7591b0dcd893c51 100644
|
| --- a/content/child/service_worker/service_worker_dispatcher.cc
|
| +++ b/content/child/service_worker/service_worker_dispatcher.cc
|
| @@ -68,6 +68,8 @@ void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) {
|
| OnUnregistered)
|
| IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetRegistration,
|
| OnDidGetRegistration)
|
| + IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetRegistrations,
|
| + OnDidGetRegistrations)
|
| IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetRegistrationForReady,
|
| OnDidGetRegistrationForReady)
|
| IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerRegistrationError,
|
| @@ -76,6 +78,8 @@ void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) {
|
| OnUnregistrationError)
|
| IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerGetRegistrationError,
|
| OnGetRegistrationError)
|
| + IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerGetRegistrationsError,
|
| + OnGetRegistrationsError)
|
| IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerStateChanged,
|
| OnServiceWorkerStateChanged)
|
| IPC_MESSAGE_HANDLER(ServiceWorkerMsg_SetVersionAttributes,
|
| @@ -179,6 +183,19 @@ void ServiceWorkerDispatcher::GetRegistration(
|
| CurrentWorkerId(), request_id, provider_id, document_url));
|
| }
|
|
|
| +void ServiceWorkerDispatcher::GetRegistrations(
|
| + int provider_id,
|
| + WebServiceWorkerGetRegistrationsCallbacks* callbacks) {
|
| + DCHECK(callbacks);
|
| +
|
| + int request_id = pending_get_registrations_callbacks_.Add(callbacks);
|
| + TRACE_EVENT_ASYNC_BEGIN0("ServiceWorker",
|
| + "ServiceWorkerDispatcher::GetRegistrations",
|
| + request_id);
|
| + thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistrations(
|
| + CurrentWorkerId(), request_id, provider_id));
|
| +}
|
| +
|
| void ServiceWorkerDispatcher::GetRegistrationForReady(
|
| int provider_id,
|
| WebServiceWorkerGetRegistrationForReadyCallbacks* callbacks) {
|
| @@ -416,6 +433,42 @@ void ServiceWorkerDispatcher::OnDidGetRegistration(
|
| pending_get_registration_callbacks_.Remove(request_id);
|
| }
|
|
|
| +void ServiceWorkerDispatcher::OnDidGetRegistrations(
|
| + int thread_id,
|
| + int request_id,
|
| + const std::vector<ServiceWorkerRegistrationObjectInfo>& infos,
|
| + const std::vector<ServiceWorkerVersionAttributes>& attrs) {
|
| + TRACE_EVENT_ASYNC_STEP_INTO0(
|
| + "ServiceWorker",
|
| + "ServiceWorkerDispatcher::GetRegistrations",
|
| + request_id,
|
| + "OnDidGetRegistrations");
|
| + TRACE_EVENT_ASYNC_END0("ServiceWorker",
|
| + "ServiceWorkerDispatcher::GetRegistrations",
|
| + request_id);
|
| +
|
| + WebServiceWorkerGetRegistrationsCallbacks* callbacks =
|
| + pending_get_registrations_callbacks_.Lookup(request_id);
|
| + DCHECK(callbacks);
|
| + if (!callbacks)
|
| + return;
|
| +
|
| + typedef blink::WebVector<blink::WebServiceWorkerRegistration*>
|
| + WebServiceWorkerRegistrationArray;
|
| + scoped_ptr<WebServiceWorkerRegistrationArray>
|
| + registrations(new WebServiceWorkerRegistrationArray(infos.size()));
|
| + for (size_t i = 0; i < infos.size(); ++i) {
|
| + if (infos[i].handle_id != kInvalidServiceWorkerHandleId) {
|
| + ServiceWorkerRegistrationObjectInfo info(infos[i]);
|
| + ServiceWorkerVersionAttributes attr(attrs[i]);
|
| + (*registrations)[i] = FindOrCreateRegistration(info, attr);
|
| + }
|
| + }
|
| +
|
| + callbacks->onSuccess(registrations.release());
|
| + pending_get_registrations_callbacks_.Remove(request_id);
|
| +}
|
| +
|
| void ServiceWorkerDispatcher::OnDidGetRegistrationForReady(
|
| int thread_id,
|
| int request_id,
|
| @@ -516,6 +569,31 @@ void ServiceWorkerDispatcher::OnGetRegistrationError(
|
| pending_get_registration_callbacks_.Remove(request_id);
|
| }
|
|
|
| +void ServiceWorkerDispatcher::OnGetRegistrationsError(
|
| + int thread_id,
|
| + int request_id,
|
| + WebServiceWorkerError::ErrorType error_type,
|
| + const base::string16& message) {
|
| + TRACE_EVENT_ASYNC_STEP_INTO0(
|
| + "ServiceWorker",
|
| + "ServiceWorkerDispatcher::GetRegistrations",
|
| + request_id,
|
| + "OnGetRegistrationsError");
|
| + TRACE_EVENT_ASYNC_END0("ServiceWorker",
|
| + "ServiceWorkerDispatcher::GetRegistrations",
|
| + request_id);
|
| + WebServiceWorkerGetRegistrationsCallbacks* callbacks =
|
| + pending_get_registrations_callbacks_.Lookup(request_id);
|
| + DCHECK(callbacks);
|
| + if (!callbacks)
|
| + return;
|
| +
|
| + scoped_ptr<WebServiceWorkerError> error(
|
| + new WebServiceWorkerError(error_type, message));
|
| + callbacks->onError(error.release());
|
| + pending_get_registrations_callbacks_.Remove(request_id);
|
| +}
|
| +
|
| void ServiceWorkerDispatcher::OnServiceWorkerStateChanged(
|
| int thread_id,
|
| int handle_id,
|
|
|