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

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: Add OWNERS and PRESUBMIT.py 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();
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 render_process_id,
29 int thread_id,
30 const StatusCallback& callback);
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 BackgroundSyncServiceClientPtr background_sync_client_;
43
44 base::WeakPtrFactory<ServiceWorkerMojoEventDispatcher> weak_ptr_factory_;
michaeln 2015/06/24 00:12:01 The name 'weak_factory_' is used consistently for
iclelland 2015/06/24 14:29:30 Done.
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 _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698