OLD | NEW |
(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 class BackgroundSyncProvider : public blink::WebSyncProvider { |
| 25 public: |
| 26 explicit BackgroundSyncProvider(ServiceRegistry* service_registry); |
| 27 |
| 28 ~BackgroundSyncProvider() override; |
| 29 |
| 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, |
| 37 int64_t id, |
| 38 const blink::WebString& tag, |
| 39 blink::WebServiceWorkerRegistration* service_worker_registration, |
| 40 blink::WebSyncUnregistrationCallbacks* callbacks); |
| 41 void getRegistration( |
| 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 |
| 51 private: |
| 52 // Callback handlers |
| 53 void RegisterCallback( |
| 54 scoped_ptr<blink::WebSyncRegistrationCallbacks> callbacks, |
| 55 const SyncRegistrationPtr& options); |
| 56 void UnregisterCallback( |
| 57 scoped_ptr<blink::WebSyncUnregistrationCallbacks> callbacks, |
| 58 bool success); |
| 59 void GetRegistrationsCallback( |
| 60 scoped_ptr<blink::WebSyncGetRegistrationsCallbacks> callbacks, |
| 61 const mojo::Array<SyncRegistrationPtr>& registrations); |
| 62 |
| 63 // Helper method that returns an initialized BackgroundSyncServicePtr. |
| 64 BackgroundSyncServicePtr& GetBackgroundSyncServicePtr(); |
| 65 |
| 66 ServiceRegistry* service_registry_; |
| 67 BackgroundSyncServicePtr background_sync_service_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncProvider); |
| 70 }; |
| 71 |
| 72 } // namespace content |
| 73 |
| 74 #endif // CONTENT_CHILD_BACKGROUND_SYNC_BACKGROUND_SYNC_PROVIDER_H_ |
OLD | NEW |