Chromium Code Reviews| 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; | |
| 14 class SyncError; | |
|
iclelland
2016/11/18 20:53:46
blink::SyncError isn't used in this file; do you n
adithyas
2016/11/21 15:25:17
Don't need it, removed :)
| |
| 15 class WebServiceWorkerRegistration; | 15 class WebServiceWorkerRegistration; |
| 16 | 16 |
| 17 // The BackgroundSyncProvider is called by the SyncManager and SyncRegistration | 17 // The BackgroundSyncProvider is called by the SyncManager and SyncRegistration |
| 18 // objects and communicates with the BackgroundSyncManager object in the browser | 18 // objects and communicates with the BackgroundSyncManager object in the browser |
| 19 // process. Each thread will have its own instance (e.g. main thread, worker | 19 // process. Each thread will have its own instance (e.g. main thread, worker |
| 20 // threads), instantiated as needed by SyncManager. Each instance of the | 20 // threads), instantiated as needed by SyncManager. Each instance of the |
| 21 // provider creates a new mojo connection to a new BackgroundSyncManagerImpl, | 21 // provider creates a new mojo connection to a new BackgroundSyncManagerImpl, |
| 22 // which then talks to the BackgroundSyncManager object. | 22 // which then talks to the BackgroundSyncManager object. |
| 23 class BackgroundSyncProvider { | 23 class BackgroundSyncProvider { |
| 24 WTF_MAKE_NONCOPYABLE(BackgroundSyncProvider); | 24 WTF_MAKE_NONCOPYABLE(BackgroundSyncProvider); |
| 25 | 25 |
| 26 public: | 26 public: |
| 27 BackgroundSyncProvider() = default; | 27 BackgroundSyncProvider() = default; |
| 28 | 28 |
| 29 void registerBackgroundSync(mojom::blink::SyncRegistrationPtr options, | 29 void registerBackgroundSync(mojom::blink::SyncRegistrationPtr options, |
| 30 WebServiceWorkerRegistration*, | 30 WebServiceWorkerRegistration*, |
| 31 std::unique_ptr<SyncRegistrationCallbacks>); | 31 ScriptPromiseResolver*); |
| 32 void getRegistrations(WebServiceWorkerRegistration*, | 32 void getRegistrations(WebServiceWorkerRegistration*, ScriptPromiseResolver*); |
| 33 std::unique_ptr<SyncGetRegistrationsCallbacks>); | |
| 34 | 33 |
| 35 private: | 34 private: |
| 36 // Callback handlers | 35 // Callback handlers |
| 37 static void registerCallback( | 36 static void registerCallback(ScriptPromiseResolver*, |
| 38 std::unique_ptr<blink::SyncRegistrationCallbacks>, | 37 mojom::blink::BackgroundSyncError, |
| 39 mojom::blink::BackgroundSyncError, | 38 mojom::blink::SyncRegistrationPtr options); |
| 40 mojom::blink::SyncRegistrationPtr options); | |
| 41 static void getRegistrationsCallback( | 39 static void getRegistrationsCallback( |
| 42 std::unique_ptr<SyncGetRegistrationsCallbacks>, | 40 ScriptPromiseResolver*, |
| 43 mojom::blink::BackgroundSyncError, | 41 mojom::blink::BackgroundSyncError, |
| 44 mojo::WTFArray<mojom::blink::SyncRegistrationPtr> registrations); | 42 mojo::WTFArray<mojom::blink::SyncRegistrationPtr> registrations); |
| 45 | 43 |
| 46 // Returns an initialized BackgroundSyncServicePtr. A connection with the | 44 // Returns an initialized BackgroundSyncServicePtr. A connection with the |
| 47 // the browser's BackgroundSyncService is created the first time this method | 45 // the browser's BackgroundSyncService is created the first time this method |
| 48 // is called. | 46 // is called. |
| 49 mojom::blink::BackgroundSyncServicePtr& GetBackgroundSyncServicePtr(); | 47 mojom::blink::BackgroundSyncServicePtr& GetBackgroundSyncServicePtr(); |
| 50 | 48 |
| 51 mojom::blink::BackgroundSyncServicePtr m_backgroundSyncService; | 49 mojom::blink::BackgroundSyncServicePtr m_backgroundSyncService; |
| 52 }; | 50 }; |
| 53 | 51 |
| 54 } // namespace blink | 52 } // namespace blink |
| 55 | 53 |
| 56 #endif // BackgroundSyncProvider_h | 54 #endif // BackgroundSyncProvider_h |
| OLD | NEW |