| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BackgroundSyncProvider_h | 5 #ifndef BackgroundSyncProvider_h |
| 6 #define BackgroundSyncProvider_h | 6 #define BackgroundSyncProvider_h |
| 7 | 7 |
| 8 #include "modules/background_sync/SyncCallbacks.h" | |
| 9 #include "public/platform/modules/background_sync/background_sync.mojom-blink.h" | 8 #include "public/platform/modules/background_sync/background_sync.mojom-blink.h" |
| 10 #include "wtf/Noncopyable.h" | 9 #include "wtf/Noncopyable.h" |
| 11 #include <memory> | |
| 12 | 10 |
| 13 namespace blink { | 11 namespace blink { |
| 14 | 12 |
| 13 class ScriptPromiseResolver; |
| 15 class WebServiceWorkerRegistration; | 14 class WebServiceWorkerRegistration; |
| 16 | 15 |
| 17 // The BackgroundSyncProvider is called by the SyncManager and SyncRegistration | 16 // The BackgroundSyncProvider is called by the SyncManager and SyncRegistration |
| 18 // objects and communicates with the BackgroundSyncManager object in the browser | 17 // objects and communicates with the BackgroundSyncManager object in the browser |
| 19 // process. Each thread will have its own instance (e.g. main thread, worker | 18 // process. Each thread will have its own instance (e.g. main thread, worker |
| 20 // threads), instantiated as needed by SyncManager. Each instance of the | 19 // threads), instantiated as needed by SyncManager. Each instance of the |
| 21 // provider creates a new mojo connection to a new BackgroundSyncManagerImpl, | 20 // provider creates a new mojo connection to a new BackgroundSyncManagerImpl, |
| 22 // which then talks to the BackgroundSyncManager object. | 21 // which then talks to the BackgroundSyncManager object. |
| 23 class BackgroundSyncProvider { | 22 class BackgroundSyncProvider { |
| 24 WTF_MAKE_NONCOPYABLE(BackgroundSyncProvider); | 23 WTF_MAKE_NONCOPYABLE(BackgroundSyncProvider); |
| 25 | 24 |
| 26 public: | 25 public: |
| 27 BackgroundSyncProvider() = default; | 26 BackgroundSyncProvider() = default; |
| 28 | 27 |
| 29 void registerBackgroundSync(mojom::blink::SyncRegistrationPtr options, | 28 void registerBackgroundSync(mojom::blink::SyncRegistrationPtr options, |
| 30 WebServiceWorkerRegistration*, | 29 WebServiceWorkerRegistration*, |
| 31 std::unique_ptr<SyncRegistrationCallbacks>); | 30 ScriptPromiseResolver*); |
| 32 void getRegistrations(WebServiceWorkerRegistration*, | 31 void getRegistrations(WebServiceWorkerRegistration*, ScriptPromiseResolver*); |
| 33 std::unique_ptr<SyncGetRegistrationsCallbacks>); | |
| 34 | 32 |
| 35 private: | 33 private: |
| 36 // Callback handlers | 34 // Callback handlers |
| 37 static void registerCallback( | 35 static void registerCallback(ScriptPromiseResolver*, |
| 38 std::unique_ptr<blink::SyncRegistrationCallbacks>, | 36 mojom::blink::BackgroundSyncError, |
| 39 mojom::blink::BackgroundSyncError, | 37 mojom::blink::SyncRegistrationPtr options); |
| 40 mojom::blink::SyncRegistrationPtr options); | |
| 41 static void getRegistrationsCallback( | 38 static void getRegistrationsCallback( |
| 42 std::unique_ptr<SyncGetRegistrationsCallbacks>, | 39 ScriptPromiseResolver*, |
| 43 mojom::blink::BackgroundSyncError, | 40 mojom::blink::BackgroundSyncError, |
| 44 mojo::WTFArray<mojom::blink::SyncRegistrationPtr> registrations); | 41 mojo::WTFArray<mojom::blink::SyncRegistrationPtr> registrations); |
| 45 | 42 |
| 46 // Returns an initialized BackgroundSyncServicePtr. A connection with the | 43 // Returns an initialized BackgroundSyncServicePtr. A connection with the |
| 47 // the browser's BackgroundSyncService is created the first time this method | 44 // the browser's BackgroundSyncService is created the first time this method |
| 48 // is called. | 45 // is called. |
| 49 mojom::blink::BackgroundSyncServicePtr& GetBackgroundSyncServicePtr(); | 46 mojom::blink::BackgroundSyncServicePtr& GetBackgroundSyncServicePtr(); |
| 50 | 47 |
| 51 mojom::blink::BackgroundSyncServicePtr m_backgroundSyncService; | 48 mojom::blink::BackgroundSyncServicePtr m_backgroundSyncService; |
| 52 }; | 49 }; |
| 53 | 50 |
| 54 } // namespace blink | 51 } // namespace blink |
| 55 | 52 |
| 56 #endif // BackgroundSyncProvider_h | 53 #endif // BackgroundSyncProvider_h |
| OLD | NEW |