Infobar material design refresh: bg color
[chromium-blink-merge.git] / content / child / background_sync / background_sync_provider.h
blob43d54d5393cf5e9b6a370978de06b7890af78afe
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.
5 #ifndef CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_H_
6 #define CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_H_
8 #include <string>
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/WebSyncProvider.h"
15 namespace content {
17 class ServiceRegistry;
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 class BackgroundSyncProvider : public blink::WebSyncProvider {
25 public:
26 explicit BackgroundSyncProvider(ServiceRegistry* service_registry);
28 ~BackgroundSyncProvider() override;
30 // blink::WebSyncProvider implementation
31 void registerBackgroundSync(
32 const blink::WebSyncRegistration* options,
33 blink::WebServiceWorkerRegistration* service_worker_registration,
34 bool requested_from_service_worker,
35 blink::WebSyncRegistrationCallbacks* callbacks);
36 void unregisterBackgroundSync(
37 blink::WebSyncRegistration::Periodicity periodicity,
38 int64_t id,
39 const blink::WebString& tag,
40 blink::WebServiceWorkerRegistration* service_worker_registration,
41 blink::WebSyncUnregistrationCallbacks* callbacks);
42 void getRegistration(
43 blink::WebSyncRegistration::Periodicity,
44 const blink::WebString& tag,
45 blink::WebServiceWorkerRegistration* service_worker_registration,
46 blink::WebSyncRegistrationCallbacks* callbacks);
47 void getRegistrations(
48 blink::WebSyncRegistration::Periodicity periodicity,
49 blink::WebServiceWorkerRegistration* service_worker_registration,
50 blink::WebSyncGetRegistrationsCallbacks* callbacks);
51 void getPermissionStatus(
52 blink::WebSyncRegistration::Periodicity periodicity,
53 blink::WebServiceWorkerRegistration* service_worker_registration,
54 blink::WebSyncGetPermissionStatusCallbacks* callbacks);
56 private:
57 // Callback handlers
58 void RegisterCallback(
59 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacks,
60 BackgroundSyncError error,
61 const SyncRegistrationPtr& options);
62 void UnregisterCallback(
63 scoped_ptr<blink::WebSyncUnregistrationCallbacks> callbacks,
64 BackgroundSyncError error);
65 void GetRegistrationCallback(
66 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacks,
67 BackgroundSyncError error,
68 const SyncRegistrationPtr& options);
69 void GetRegistrationsCallback(
70 scoped_ptr<blink::WebSyncGetRegistrationsCallbacks> callbacks,
71 BackgroundSyncError error,
72 const mojo::Array<SyncRegistrationPtr>& registrations);
73 void GetPermissionStatusCallback(
74 scoped_ptr<blink::WebSyncGetPermissionStatusCallbacks> callbacks,
75 BackgroundSyncError error,
76 PermissionStatus status);
78 // Helper method that returns an initialized BackgroundSyncServicePtr.
79 BackgroundSyncServicePtr& GetBackgroundSyncServicePtr();
81 ServiceRegistry* service_registry_;
82 BackgroundSyncServicePtr background_sync_service_;
84 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncProvider);
87 } // namespace content
89 #endif // CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_H_