Chromium Code Reviews| Index: content/browser/service_worker/service_worker_event_dispatcher.h |
| diff --git a/content/browser/service_worker/service_worker_event_dispatcher.h b/content/browser/service_worker/service_worker_event_dispatcher.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3481512db5b7e719edc3ee76fb80ff87b4a2bb5e |
| --- /dev/null |
| +++ b/content/browser/service_worker/service_worker_event_dispatcher.h |
| @@ -0,0 +1,52 @@ |
| +// 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_EVENT_DISPATCHER_H_ |
| +#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_EVENT_DISPATCHER_H_ |
| + |
| +#include "base/memory/ref_counted.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" |
| +#include "content/public/browser/browser_thread.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. |
| +// |
| +// All public methods must be called on UI thread. Can be constructed, owned, |
|
jkarlin
2015/06/12 21:08:14
s/Can be constructed/This class can be constructed
|
| +// and destructed on a separate thread. |
| +class ServiceWorkerEventDispatcher |
| + : public base::RefCountedThreadSafe<ServiceWorkerEventDispatcher, |
| + BrowserThread::DeleteOnUIThread> { |
| + public: |
| + ServiceWorkerEventDispatcher(); |
| + |
| + // Dispatches the event and then runs |callback| on |task_runner| with the |
| + // result. |
| + void DispatchSyncEvent(int render_process_id, |
| + int thread_id, |
| + const ServiceWorkerVersion::StatusCallback& callback, |
| + const scoped_refptr<base::TaskRunner>& task_runner); |
| + |
| + private: |
| + friend class base::RefCountedThreadSafe<ServiceWorkerEventDispatcher, |
| + BrowserThread::DeleteOnUIThread>; |
| + friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
| + friend class base::DeleteHelper<ServiceWorkerEventDispatcher>; |
| + |
| + ~ServiceWorkerEventDispatcher(); |
| + |
| + void OnEventFinished(const ServiceWorkerVersion::StatusCallback& callback, |
| + const scoped_refptr<base::TaskRunner>& task_runner, |
| + ServiceWorkerEventStatus result); |
| + |
| + BackgroundSyncServiceClientPtr background_sync_client_; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_EVENT_DISPATCHER_H_ |