OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_MOJO_EVENT_DISPATCHER_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_MOJO_EVENT_DISPATCHER_H_ |
| 7 |
| 8 #include "content/browser/service_worker/service_worker_version.h" |
| 9 #include "content/common/background_sync_service.mojom.h" |
| 10 #include "content/common/service_worker/service_worker_status_code.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 // This class is used by ServiceWorkerVersion to fire events in the service |
| 15 // worker using mojo IPC. It owns an InterfacePtr to each service, which it will |
| 16 // construct as necessary. |
| 17 // |
| 18 // This class should only be called on the IO thread. |
| 19 class ServiceWorkerMojoEventDispatcher { |
| 20 public: |
| 21 ServiceWorkerMojoEventDispatcher(); |
| 22 ~ServiceWorkerMojoEventDispatcher(); |
| 23 |
| 24 // Dispatches the event, establishing a connection to the mojo service if |
| 25 // necessary, and then runs |callback| with the result. |
| 26 void DispatchSyncEvent(int render_process_id, |
| 27 int thread_id, |
| 28 const ServiceWorkerVersion::StatusCallback& callback); |
| 29 |
| 30 private: |
| 31 void BindChannelAndDispatchSyncEvent( |
| 32 int thread_id, |
| 33 const ServiceWorkerVersion::StatusCallback& callback, |
| 34 mojo::InterfacePtrInfo<BackgroundSyncServiceClient> ptri); |
| 35 void DispatchSyncEventInternal( |
| 36 int thread_id, |
| 37 const ServiceWorkerVersion::StatusCallback& callback); |
| 38 |
| 39 void OnEventFinished(const ServiceWorkerVersion::StatusCallback& callback, |
| 40 ServiceWorkerEventStatus result); |
| 41 |
| 42 BackgroundSyncServiceClientPtr background_sync_client_; |
| 43 |
| 44 base::WeakPtrFactory<ServiceWorkerMojoEventDispatcher> weak_ptr_factory_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerMojoEventDispatcher); |
| 47 }; |
| 48 |
| 49 } // namespace content |
| 50 |
| 51 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_MOJO_EVENT_DISPATCHER_H
_ |
OLD | NEW |