Index: content/browser/service_worker/service_worker_mojo_event_dispatcher.h |
diff --git a/content/browser/service_worker/service_worker_mojo_event_dispatcher.h b/content/browser/service_worker/service_worker_mojo_event_dispatcher.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..14e9ce38f5ff7327edbe7b4a8be60fba2eca7e75 |
--- /dev/null |
+++ b/content/browser/service_worker/service_worker_mojo_event_dispatcher.h |
@@ -0,0 +1,51 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_MOJO_EVENT_DISPATCHER_H_ |
+#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_MOJO_EVENT_DISPATCHER_H_ |
+ |
+#include "content/browser/service_worker/service_worker_version.h" |
+#include "content/common/background_sync_service.mojom.h" |
+#include "content/common/service_worker/service_worker_status_code.h" |
+ |
+namespace content { |
+ |
+// This class is used by ServiceWorkerVersion to fire events in the service |
+// worker using mojo IPC. It owns an InterfacePtr to each service, which it will |
+// construct as necessary. |
+// |
+// This class should only be called on the IO thread. |
+class ServiceWorkerMojoEventDispatcher { |
+ public: |
+ ServiceWorkerMojoEventDispatcher(); |
+ ~ServiceWorkerMojoEventDispatcher(); |
+ |
+ // Dispatches the event, establishing a connection to the mojo service if |
+ // necessary, and then runs |callback| with the result. |
+ void DispatchSyncEvent(int render_process_id, |
+ int thread_id, |
+ const ServiceWorkerVersion::StatusCallback& callback); |
+ |
+ private: |
+ void BindChannelAndDispatchSyncEvent( |
+ int thread_id, |
+ const ServiceWorkerVersion::StatusCallback& callback, |
+ mojo::InterfacePtrInfo<BackgroundSyncServiceClient> ptri); |
+ void DispatchSyncEventInternal( |
+ int thread_id, |
+ const ServiceWorkerVersion::StatusCallback& callback); |
+ |
+ void OnEventFinished(const ServiceWorkerVersion::StatusCallback& callback, |
+ ServiceWorkerEventStatus result); |
+ |
+ BackgroundSyncServiceClientPtr background_sync_client_; |
+ |
+ base::WeakPtrFactory<ServiceWorkerMojoEventDispatcher> weak_ptr_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ServiceWorkerMojoEventDispatcher); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_MOJO_EVENT_DISPATCHER_H_ |