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