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

Side by Side 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: Move ServiceWorkerMojoEventDispatcher to ServiceWorkerDispatcherHost 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 unified diff | Download patch
OLDNEW
(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 "base/memory/weak_ptr.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 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode)>;
22
23 ServiceWorkerMojoEventDispatcher(int render_process_id);
24 ~ServiceWorkerMojoEventDispatcher();
25
26 // Dispatches the event, establishing a connection to the mojo service if
27 // necessary, and then runs |callback| with the result.
28 void DispatchSyncEvent(int thread_id, const StatusCallback& callback);
29
30 int render_process_id() { return render_process_id_; }
31
32 private:
33 void BindChannelAndDispatchSyncEvent(
34 int thread_id,
35 const StatusCallback& callback,
36 mojo::InterfacePtrInfo<BackgroundSyncServiceClient> ptri);
37 void DispatchSyncEventInternal(int thread_id, const StatusCallback& callback);
38
39 void OnEventFinished(const StatusCallback& callback,
40 ServiceWorkerEventStatus result);
41
42 int render_process_id_;
43 BackgroundSyncServiceClientPtr background_sync_client_;
44
45 base::WeakPtrFactory<ServiceWorkerMojoEventDispatcher> weak_factory_;
46
47 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerMojoEventDispatcher);
48 };
49
50 } // namespace content
51
52 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_MOJO_EVENT_DISPATCHER_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698