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_
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"
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
{
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 blink::WebSyncRegistrationCallbacks
* callbacks
);
35 void unregisterBackgroundSync(
36 blink::WebSyncRegistration::Periodicity periodicity
,
38 const blink::WebString
& tag
,
39 blink::WebServiceWorkerRegistration
* service_worker_registration
,
40 blink::WebSyncUnregistrationCallbacks
* callbacks
);
42 blink::WebSyncRegistration::Periodicity
,
43 const blink::WebString
& tag
,
44 blink::WebServiceWorkerRegistration
* service_worker_registration
,
45 blink::WebSyncRegistrationCallbacks
* callbacks
);
46 void getRegistrations(
47 blink::WebSyncRegistration::Periodicity periodicity
,
48 blink::WebServiceWorkerRegistration
* service_worker_registration
,
49 blink::WebSyncGetRegistrationsCallbacks
* callbacks
);
50 void getPermissionStatus(
51 blink::WebSyncRegistration::Periodicity periodicity
,
52 blink::WebServiceWorkerRegistration
* service_worker_registration
,
53 blink::WebSyncGetPermissionStatusCallbacks
* callbacks
);
57 void RegisterCallback(
58 scoped_ptr
<blink::WebSyncRegistrationCallbacks
> callbacks
,
59 BackgroundSyncError error
,
60 const SyncRegistrationPtr
& options
);
61 void UnregisterCallback(
62 scoped_ptr
<blink::WebSyncUnregistrationCallbacks
> callbacks
,
63 BackgroundSyncError error
);
64 void GetRegistrationCallback(
65 scoped_ptr
<blink::WebSyncRegistrationCallbacks
> callbacks
,
66 BackgroundSyncError error
,
67 const SyncRegistrationPtr
& options
);
68 void GetRegistrationsCallback(
69 scoped_ptr
<blink::WebSyncGetRegistrationsCallbacks
> callbacks
,
70 BackgroundSyncError error
,
71 const mojo::Array
<SyncRegistrationPtr
>& registrations
);
72 void GetPermissionStatusCallback(
73 scoped_ptr
<blink::WebSyncGetPermissionStatusCallbacks
> callbacks
,
74 BackgroundSyncError error
,
75 PermissionStatus status
);
77 // Helper method that returns an initialized BackgroundSyncServicePtr.
78 BackgroundSyncServicePtr
& GetBackgroundSyncServicePtr();
80 ServiceRegistry
* service_registry_
;
81 BackgroundSyncServicePtr background_sync_service_
;
83 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncProvider
);
86 } // namespace content
88 #endif // CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_H_