Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Unified Diff: content/browser/service_worker/service_worker_mojo_event_dispatcher.h

Issue 1171173002: [Background Sync] Use Mojo IPC to fire background sync events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reduce thread hopping with a better ServiceWorkerMojoEventDispatcher Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..9327eb94a8bb3f3f6c2e9919d12f0ab041f59cc4
--- /dev/null
+++ b/content/browser/service_worker/service_worker_mojo_event_dispatcher.h
@@ -0,0 +1,63 @@
+// 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 "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 IO thread, and callbacks will be
+// executed on that thread. Can be constructed, owned and destructed on a
+// separate thread.
jkarlin 2015/06/16 19:00:00 The above paragraph is out of date. Just mention t
iclelland 2015/06/17 12:39:26 Done.
+class ServiceWorkerMojoEventDispatcher
+ : public base::RefCountedThreadSafe<ServiceWorkerMojoEventDispatcher,
jkarlin 2015/06/16 19:00:00 This doesn't need to be RefCounted any longer. Ins
iclelland 2015/06/17 12:39:24 Done.
+ BrowserThread::DeleteOnIOThread> {
+ public:
+ 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:
+ template <typename MojoServicePtrType>
jkarlin 2015/06/16 19:00:00 The typename differs between here and source file.
iclelland 2015/06/17 12:39:27 Thanks -- I didn't catch that. Should be MojoServi
+ void Connect(int render_process_id,
+ const base::Callback<
+ void(mojo::InterfacePtrInfo<MojoServicePtrType>)>& callback);
+ void BindChannelAndDispatchSyncEvent(
+ int thread_id,
+ const ServiceWorkerVersion::StatusCallback& callback,
+ mojo::InterfacePtrInfo<BackgroundSyncServiceClient> ptri);
+ void DispatchSyncEventInternal(
+ int thread_id,
+ const ServiceWorkerVersion::StatusCallback& callback);
+
+ friend class base::RefCountedThreadSafe<ServiceWorkerMojoEventDispatcher,
+ BrowserThread::DeleteOnIOThread>;
+ friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>;
+ friend class base::DeleteHelper<ServiceWorkerMojoEventDispatcher>;
jkarlin 2015/06/16 19:00:00 delete the above friends
iclelland 2015/06/17 12:39:27 Done.
+
+ ~ServiceWorkerMojoEventDispatcher();
+
+ void OnEventFinished(const ServiceWorkerVersion::StatusCallback& callback,
+ ServiceWorkerEventStatus result);
+
+ BackgroundSyncServiceClientPtr background_sync_client_;
jkarlin 2015/06/16 19:00:00 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerMojoEventDis
iclelland 2015/06/17 12:39:26 Done.
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_MOJO_EVENT_DISPATCHER_H_

Powered by Google App Engine
This is Rietveld 408576698