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

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: Remove Chromium IPC for Sync from unit tests' Created 5 years, 5 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 mojo {
13
14 template <>
15 struct CONTENT_EXPORT TypeConverter<content::ServiceWorkerStatusCode,
16 content::ServiceWorkerEventStatus> {
17 static content::ServiceWorkerStatusCode Convert(
18 content::ServiceWorkerEventStatus status);
19 };
20
21 } // namespace
22
23 namespace content {
24
25 // This class is used by ServiceWorkerVersion to fire events in the service
26 // worker using mojo IPC. It owns an InterfacePtr to each service, which it will
27 // construct as necessary.
28 //
29 // This class should only be called on the IO thread.
30 class ServiceWorkerMojoEventDispatcher {
31 public:
32 using StatusCallback = base::Callback<void(ServiceWorkerStatusCode)>;
33
34 ServiceWorkerMojoEventDispatcher(int render_process_id);
35 ~ServiceWorkerMojoEventDispatcher();
36
37 // Dispatches the event, establishing a connection to the mojo service if
38 // necessary, and then runs |callback| with the result.
39 void DispatchSyncEvent(int thread_id, const StatusCallback& callback);
40
41 int render_process_id() { return render_process_id_; }
42
43 private:
44 void OnEventFinished(const StatusCallback& callback,
45 ServiceWorkerEventStatus result);
46
47 int render_process_id_;
48 BackgroundSyncServiceClientPtr background_sync_client_;
49
50 base::WeakPtrFactory<ServiceWorkerMojoEventDispatcher> weak_factory_;
51
52 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerMojoEventDispatcher);
53 };
54
55 } // namespace content
56
57 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_MOJO_EVENT_DISPATCHER_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698