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

Side by Side Diff: content/child/background_sync/background_sync_provider.h

Issue 1104283002: [Background Sync] Add renderer code to interface between JS API and back-end service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bgsync-mojo
Patch Set: Add comment re: BackgroundSyncProvider lifetime Created 5 years, 7 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_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_H_
6 #define CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_H_
7
8 #include <string>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "content/child/worker_task_runner.h"
12 #include "content/common/background_sync_service.mojom.h"
13 #include "third_party/WebKit/public/platform/modules/background_sync/WebSyncProv ider.h"
14
15 namespace content {
16
17 class ServiceRegistry;
18
19 // The BackgroundSyncProvider is called by the SyncManager and SyncRegistration
20 // objects (and their Periodic counterparts) and communicates with the
21 // BackgroundSyncManager object in the browser process. This class is
22 // instantiated on the main thread by BlinkPlatformImpl, and its methods can be
23 // called directly from the main thread.
24 //
25 // When being called from a worker thread, this class is called through a
26 // BackgroundSyncProviderThreadProxy, which will call the *ForWorker methods,
27 // passing a worker thread id.
28 class BackgroundSyncProvider : public blink::WebSyncProvider {
29 public:
30 explicit BackgroundSyncProvider(ServiceRegistry* service_registry);
31
32 ~BackgroundSyncProvider() override;
33
34 // blink::WebSyncProvider implementation
35 void registerBackgroundSync(
36 const blink::WebSyncRegistration* options,
37 blink::WebServiceWorkerRegistration* service_worker_registration,
38 blink::WebSyncRegistrationCallbacks* callbacks);
39 void unregisterBackgroundSync(
40 blink::WebSyncRegistration::Periodicity periodicity,
41 int64_t id, const blink::WebString& tag,
42 blink::WebServiceWorkerRegistration* service_worker_registration,
43 blink::WebSyncUnregistrationCallbacks* callbacks);
44 void getRegistration(
45 blink::WebSyncRegistration::Periodicity,
46 const blink::WebString& tag,
47 blink::WebServiceWorkerRegistration* service_worker_registration,
48 blink::WebSyncRegistrationCallbacks* callbacks);
49 void getRegistrations(
50 blink::WebSyncRegistration::Periodicity periodicity,
51 blink::WebServiceWorkerRegistration* service_worker_registration,
52 blink::WebSyncGetRegistrationsCallbacks* callbacks);
53
54 // Entry points for Background Sync API calls from worker threads
55 void RegisterBackgroundSyncForWorker(
56 scoped_ptr<blink::WebSyncRegistration> options,
57 blink::WebServiceWorkerRegistration* service_worker_registration,
58 blink::WebSyncRegistrationCallbacks* callbacks, int worker_thread_id);
59 void UnregisterBackgroundSyncForWorker(
60 blink::WebSyncRegistration::Periodicity periodicity, int64_t id,
61 const blink::WebString& tag,
62 blink::WebServiceWorkerRegistration* service_worker_registration,
63 blink::WebSyncUnregistrationCallbacks* callbacks, int worker_thread_id);
64 void GetRegistrationForWorker(
65 blink::WebSyncRegistration::Periodicity periodicity,
66 const blink::WebString& tag,
67 blink::WebServiceWorkerRegistration* service_worker_registration,
68 blink::WebSyncRegistrationCallbacks* callbacks, int worker_thread_id);
69 void GetRegistrationsForWorker(
70 blink::WebSyncRegistration::Periodicity periodicity,
71 blink::WebServiceWorkerRegistration* service_worker_registration,
72 blink::WebSyncGetRegistrationsCallbacks* callbacks, int worker_thread_id);
73
74 private:
75 // Callback handlers
76 void RegisterCallback(blink::WebSyncRegistrationCallbacks* callbacks,
77 int worker_thread_id,
78 const SyncRegistrationPtr &options);
79 void UnregisterCallback(blink::WebSyncUnregistrationCallbacks* callbacks,
80 int worker_thread_id, bool success);
81 void GetRegistrationsCallback(
82 blink::WebSyncGetRegistrationsCallbacks* callbacks, int worker_thread_id,
83 const mojo::Array<SyncRegistrationPtr> &registrations);
84
85 // Helper method that returns an initialized BackgroundSyncServicePtr.
86 BackgroundSyncServicePtr& GetBackgroundSyncServicePtr();
87
88 ServiceRegistry* service_registry_;
89 BackgroundSyncServicePtr background_sync_service_;
90
91 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncProvider);
92 };
93
94 } // namespace content
95
96 #endif // CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698