Chromium Code Reviews| Index: content/browser/service_worker/service_worker_version.cc |
| diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc |
| index f225a9bd3fa2921176b0c662049f3f1da8796bd7..d586d7426ebb0b25aff200f1a99f3ce826d114da 100644 |
| --- a/content/browser/service_worker/service_worker_version.cc |
| +++ b/content/browser/service_worker/service_worker_version.cc |
| @@ -31,6 +31,7 @@ |
| #include "content/browser/service_worker/stashed_port_manager.h" |
| #include "content/browser/storage_partition_impl.h" |
| #include "content/common/service_worker/service_worker_messages.h" |
| +#include "content/common/service_worker/service_worker_type_converters.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/content_browser_client.h" |
| #include "content/public/browser/page_navigator.h" |
| @@ -42,6 +43,7 @@ |
| #include "content/public/common/content_client.h" |
| #include "content/public/common/content_switches.h" |
| #include "content/public/common/result_codes.h" |
| +#include "content/public/common/service_registry.h" |
| #include "net/http/http_response_headers.h" |
| #include "net/http/http_response_info.h" |
| @@ -800,12 +802,21 @@ void ServiceWorkerVersion::DispatchSyncEvent(const StatusCallback& callback) { |
| } |
| int request_id = AddRequest(callback, &sync_requests_, REQUEST_SYNC); |
| - ServiceWorkerStatusCode status = embedded_worker_->SendMessage( |
| - ServiceWorkerMsg_SyncEvent(request_id)); |
| - if (status != SERVICE_WORKER_OK) { |
| - sync_requests_.Remove(request_id); |
| - RunSoon(base::Bind(callback, status)); |
| + if (!background_sync_dispatcher_) { |
| + embedded_worker_->GetServiceRegistry()->ConnectToRemoteService( |
| + mojo::GetProxy(&background_sync_dispatcher_)); |
| + // TODO(iclelland): Register an appropriate mojo error handler with |
| + // set_connection_error_handler. This will be straightforward once |
| + // https://codereview.chromium.org/1210643002 lands. |
|
Marijn Kruisselbrink
2015/07/17 17:12:15
In the last version of that CL I actually got rid
iclelland
2015/07/20 16:06:16
Cool, thanks for the heads-up. I've updated this t
|
| } |
| + |
| + // TODO(iclelland): Replace this with the real event registration details |
| + // crbug.com/482066 |
| + content::SyncRegistrationPtr null_event(content::SyncRegistration::New()); |
| + |
| + background_sync_dispatcher_->Sync( |
| + null_event.Pass(), base::Bind(&self::OnSyncEventFinished, |
| + weak_factory_.GetWeakPtr(), request_id)); |
| } |
| void ServiceWorkerVersion::DispatchNotificationClickEvent( |
| @@ -1195,8 +1206,6 @@ bool ServiceWorkerVersion::OnMessageReceived(const IPC::Message& message) { |
| OnInstallEventFinished) |
| IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_FetchEventFinished, |
| OnFetchEventFinished) |
| - IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SyncEventFinished, |
| - OnSyncEventFinished) |
| IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_NotificationClickEventFinished, |
| OnNotificationClickEventFinished) |
| IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PushEventFinished, |
| @@ -1382,7 +1391,7 @@ void ServiceWorkerVersion::OnFetchEventFinished( |
| void ServiceWorkerVersion::OnSyncEventFinished( |
| int request_id, |
| - blink::WebServiceWorkerEventResult result) { |
| + ServiceWorkerEventStatus status) { |
| TRACE_EVENT1("ServiceWorker", |
| "ServiceWorkerVersion::OnSyncEventFinished", |
| "Request id", request_id); |
| @@ -1392,13 +1401,8 @@ void ServiceWorkerVersion::OnSyncEventFinished( |
| return; |
| } |
| - ServiceWorkerStatusCode status = SERVICE_WORKER_OK; |
| - if (result == blink::WebServiceWorkerEventResultRejected) { |
| - status = SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED; |
| - } |
| - |
| scoped_refptr<ServiceWorkerVersion> protect(this); |
| - request->callback.Run(status); |
| + request->callback.Run(mojo::ConvertTo<ServiceWorkerStatusCode>(status)); |
| RemoveCallbackAndStopIfRedundant(&sync_requests_, request_id); |
| } |