Chromium Code Reviews| 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 69ae4ae9cea285a1e83639fa479ab92e7a9e0d0b..33fb8b1a8aa175b9ec94d0b3cfcb85aa231d9487 100644 |
| --- a/content/child/service_worker/service_worker_dispatcher.cc |
| +++ b/content/child/service_worker/service_worker_dispatcher.cc |
| @@ -68,6 +68,7 @@ void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) { |
| IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DisassociateRegistration, |
| OnDisassociateRegistration) |
| IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerRegistered, OnRegistered) |
| + IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerUpdated, OnUpdated) |
| IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerUnregistered, |
| OnUnregistered) |
| IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetRegistration, |
| @@ -78,6 +79,8 @@ void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) { |
| OnDidGetRegistrationForReady) |
| IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerRegistrationError, |
| OnRegistrationError) |
| + IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerUpdateError, |
| + OnUpdateError) |
| IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerUnregistrationError, |
| OnUnregistrationError) |
| IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerGetRegistrationError, |
| @@ -133,10 +136,14 @@ void ServiceWorkerDispatcher::RegisterServiceWorker( |
| CurrentWorkerId(), request_id, provider_id, pattern, script_url)); |
| } |
| -void ServiceWorkerDispatcher::UpdateServiceWorker(int provider_id, |
| - int64 registration_id) { |
| +void ServiceWorkerDispatcher::UpdateServiceWorker( |
| + int provider_id, |
| + int64 registration_id, |
| + WebServiceWorkerUpdateCallbacks* callbacks) { |
| + DCHECK(callbacks); |
| + int request_id = pending_update_callbacks_.Add(callbacks); |
| thread_safe_sender_->Send(new ServiceWorkerHostMsg_UpdateServiceWorker( |
| - provider_id, registration_id)); |
| + CurrentWorkerId(), request_id, provider_id, registration_id)); |
| } |
| void ServiceWorkerDispatcher::UnregisterServiceWorker( |
| @@ -383,6 +390,23 @@ void ServiceWorkerDispatcher::OnRegistered( |
| pending_registration_callbacks_.Remove(request_id); |
| } |
| +void ServiceWorkerDispatcher::OnUpdated(int thread_id, int request_id) { |
| + TRACE_EVENT_ASYNC_STEP_INTO0("ServiceWorker", |
| + "ServiceWorkerDispatcher::UpdateServiceWorker", |
| + request_id, "OnUpdated"); |
| + TRACE_EVENT_ASYNC_END0("ServiceWorker", |
| + "ServiceWorkerDispatcher::UpdateServiceWorker", |
| + request_id); |
| + WebServiceWorkerUpdateCallbacks* callbacks = |
| + pending_update_callbacks_.Lookup(request_id); |
| + DCHECK(callbacks); |
| + if (!callbacks) |
| + return; |
| + |
| + callbacks->onSuccess(); |
| + pending_update_callbacks_.Remove(request_id); |
| +} |
| + |
| void ServiceWorkerDispatcher::OnUnregistered(int thread_id, |
| int request_id, |
| bool is_success) { |
| @@ -516,6 +540,29 @@ void ServiceWorkerDispatcher::OnRegistrationError( |
| pending_registration_callbacks_.Remove(request_id); |
| } |
| +void ServiceWorkerDispatcher::OnUpdateError( |
| + int thread_id, |
| + int request_id, |
| + WebServiceWorkerError::ErrorType error_type, |
| + const base::string16& message) { |
| + TRACE_EVENT_ASYNC_STEP_INTO0("ServiceWorker", |
| + "ServiceWorkerDispatcher::UpdateServiceWorker", |
| + request_id, "OnUpdateError"); |
| + TRACE_EVENT_ASYNC_END0("ServiceWorker", |
| + "ServiceWorkerDispatcher::UpdateServiceWorker", |
| + request_id); |
| + WebServiceWorkerUpdateCallbacks* callbacks = |
| + pending_update_callbacks_.Lookup(request_id); |
| + DCHECK(callbacks); |
| + if (!callbacks) |
| + return; |
| + |
| + scoped_ptr<WebServiceWorkerError> error( |
| + new WebServiceWorkerError(error_type, message)); |
| + callbacks->onError(error.release()); |
|
nhiroki
2015/07/31 06:49:11
nit: We can directly pass "new WebSWError" w/o sco
jungkees
2015/07/31 07:09:58
Addressed. Thanks.
|
| + pending_update_callbacks_.Remove(request_id); |
| +} |
| + |
| void ServiceWorkerDispatcher::OnUnregistrationError( |
| int thread_id, |
| int request_id, |