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