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> | 10 #include <memory> |
|
jbroman
2016/11/18 16:53:32
super-nit: I think this include was here for uniqu
adithyas
2016/11/18 20:05:00
Done.
| |
| 12 | 11 |
| 13 namespace blink { | 12 namespace blink { |
| 14 | 13 |
| 15 class WebServiceWorkerRegistration; | 14 class WebServiceWorkerRegistration; |
| 15 class ScriptPromiseResolver; | |
|
jbroman
2016/11/18 16:53:31
nit: alphabetize these
adithyas
2016/11/18 20:05:00
Done.
| |
| 16 class SyncError; | |
| 16 | 17 |
| 17 // The BackgroundSyncProvider is called by the SyncManager and SyncRegistration | 18 // The BackgroundSyncProvider is called by the SyncManager and SyncRegistration |
| 18 // objects and communicates with the BackgroundSyncManager object in the browser | 19 // 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 // 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 // threads), instantiated as needed by SyncManager. Each instance of the |
| 21 // provider creates a new mojo connection to a new BackgroundSyncManagerImpl, | 22 // provider creates a new mojo connection to a new BackgroundSyncManagerImpl, |
| 22 // which then talks to the BackgroundSyncManager object. | 23 // which then talks to the BackgroundSyncManager object. |
| 23 class BackgroundSyncProvider { | 24 class BackgroundSyncProvider { |
| 24 WTF_MAKE_NONCOPYABLE(BackgroundSyncProvider); | 25 WTF_MAKE_NONCOPYABLE(BackgroundSyncProvider); |
| 25 | 26 |
| 26 public: | 27 public: |
| 27 BackgroundSyncProvider() = default; | 28 BackgroundSyncProvider() = default; |
| 28 | 29 |
| 29 void registerBackgroundSync(mojom::blink::SyncRegistrationPtr options, | 30 void registerBackgroundSync(mojom::blink::SyncRegistrationPtr options, |
| 30 WebServiceWorkerRegistration*, | 31 WebServiceWorkerRegistration*, |
| 31 std::unique_ptr<SyncRegistrationCallbacks>); | 32 ScriptPromiseResolver*); |
|
jbroman
2016/11/18 16:53:32
Since there's only the one implementation of Sync*
adithyas
2016/11/18 20:05:00
Yup I definitely agree with that thought, both cla
iclelland
2016/11/18 20:53:46
The difference, I believe, is that there can be mu
jbroman
2016/11/19 03:32:15
Right, that's the difference (unless there's a cor
haraken
2016/11/21 00:21:58
+1
| |
| 32 void getRegistrations(WebServiceWorkerRegistration*, | 33 void getRegistrations(WebServiceWorkerRegistration*, ScriptPromiseResolver*); |
| 33 std::unique_ptr<SyncGetRegistrationsCallbacks>); | |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 // Callback handlers | 36 // Callback handlers |
| 37 static void registerCallback( | 37 static void registerCallback(ScriptPromiseResolver*, |
| 38 std::unique_ptr<blink::SyncRegistrationCallbacks>, | 38 mojom::blink::BackgroundSyncError, |
| 39 mojom::blink::BackgroundSyncError, | 39 mojom::blink::SyncRegistrationPtr options); |
| 40 mojom::blink::SyncRegistrationPtr options); | |
| 41 static void getRegistrationsCallback( | 40 static void getRegistrationsCallback( |
| 42 std::unique_ptr<SyncGetRegistrationsCallbacks>, | 41 ScriptPromiseResolver*, |
| 43 mojom::blink::BackgroundSyncError, | 42 mojom::blink::BackgroundSyncError, |
| 44 mojo::WTFArray<mojom::blink::SyncRegistrationPtr> registrations); | 43 mojo::WTFArray<mojom::blink::SyncRegistrationPtr> registrations); |
| 45 | 44 |
| 45 // Success and error handlers | |
| 46 static void onRegisterSuccess(ScriptPromiseResolver*, | |
| 47 mojom::blink::SyncRegistrationPtr); | |
| 48 static void onRegisterError(ScriptPromiseResolver*, const SyncError&); | |
| 49 static void onGetRegistrationsSuccess( | |
| 50 ScriptPromiseResolver*, | |
| 51 const Vector<mojom::blink::SyncRegistrationPtr>&); | |
| 52 static void onGetRegistrationsError(ScriptPromiseResolver*, const SyncError&); | |
| 53 | |
| 46 // Returns an initialized BackgroundSyncServicePtr. A connection with the | 54 // Returns an initialized BackgroundSyncServicePtr. A connection with the |
| 47 // the browser's BackgroundSyncService is created the first time this method | 55 // the browser's BackgroundSyncService is created the first time this method |
| 48 // is called. | 56 // is called. |
| 49 mojom::blink::BackgroundSyncServicePtr& GetBackgroundSyncServicePtr(); | 57 mojom::blink::BackgroundSyncServicePtr& GetBackgroundSyncServicePtr(); |
| 50 | 58 |
| 51 mojom::blink::BackgroundSyncServicePtr m_backgroundSyncService; | 59 mojom::blink::BackgroundSyncServicePtr m_backgroundSyncService; |
| 52 }; | 60 }; |
| 53 | 61 |
| 54 } // namespace blink | 62 } // namespace blink |
| 55 | 63 |
| 56 #endif // BackgroundSyncProvider_h | 64 #endif // BackgroundSyncProvider_h |
| OLD | NEW |