| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 SyncCallbacks_h | 5 #ifndef SyncCallbacks_h |
| 6 #define SyncCallbacks_h | 6 #define SyncCallbacks_h |
| 7 | 7 |
| 8 #include "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
| 9 #include "public/platform/WebCallbacks.h" | 9 #include "public/platform/WebCallbacks.h" |
| 10 #include "public/platform/modules/background_sync/WebSyncProvider.h" | 10 #include "public/platform/modules/background_sync/WebSyncProvider.h" |
| 11 #include "public/platform/modules/background_sync/WebSyncRegistration.h" | 11 #include "public/platform/modules/background_sync/WebSyncRegistration.h" |
| 12 #include "wtf/Noncopyable.h" | 12 #include "wtf/Noncopyable.h" |
| 13 #include "wtf/PassRefPtr.h" | 13 #include "wtf/PassRefPtr.h" |
| 14 #include "wtf/RefPtr.h" | 14 #include "wtf/RefPtr.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 class ServiceWorkerRegistration; | 18 class ServiceWorkerRegistration; |
| 19 class ScriptPromiseResolver; | 19 class ScriptPromiseResolver; |
| 20 struct WebSyncError; | 20 struct WebSyncError; |
| 21 struct WebSyncRegistration; | 21 struct WebSyncRegistration; |
| 22 class WebString; | 22 class WebString; |
| 23 | 23 |
| 24 // SyncRegistrationCallbacks is an implementation of WebSyncRegistrationCallback
s | 24 // SyncRegistrationCallbacks is an implementation of |
| 25 // that will resolve the underlying promise depending on the result passed to | 25 // WebSyncRegistrationCallbacks that will resolve the underlying promise |
| 26 // the callback. It takes a ServiceWorkerRegistration in its constructor and | 26 // depending on the result passed to the callback. It takes a |
| 27 // will pass it to the SyncRegistration. | 27 // ServiceWorkerRegistration in its constructor and will pass it to the |
| 28 // SyncRegistration. |
| 28 class SyncRegistrationCallbacks final : public WebSyncRegistrationCallbacks { | 29 class SyncRegistrationCallbacks final : public WebSyncRegistrationCallbacks { |
| 29 WTF_MAKE_NONCOPYABLE(SyncRegistrationCallbacks); | 30 WTF_MAKE_NONCOPYABLE(SyncRegistrationCallbacks); |
| 30 // FIXME(tasak): when making public/platform classes to use PartitionAlloc, | 31 // FIXME(tasak): When making public/platform classes to use PartitionAlloc, |
| 31 // the following macro should be moved to WebCallbacks defined in public/platf
ormWebCallbacks.h. | 32 // the following macro should be moved to WebCallbacks defined in |
| 33 // public/platformWebCallbacks.h. |
| 32 USING_FAST_MALLOC(SyncRegistrationCallbacks); | 34 USING_FAST_MALLOC(SyncRegistrationCallbacks); |
| 33 | 35 |
| 34 public: | 36 public: |
| 35 SyncRegistrationCallbacks(ScriptPromiseResolver*, ServiceWorkerRegistration*); | 37 SyncRegistrationCallbacks(ScriptPromiseResolver*, ServiceWorkerRegistration*); |
| 36 ~SyncRegistrationCallbacks() override; | 38 ~SyncRegistrationCallbacks() override; |
| 37 | 39 |
| 38 void onSuccess(std::unique_ptr<WebSyncRegistration>) override; | 40 void onSuccess(std::unique_ptr<WebSyncRegistration>) override; |
| 39 void onError(const WebSyncError&) override; | 41 void onError(const WebSyncError&) override; |
| 40 | 42 |
| 41 private: | 43 private: |
| 42 Persistent<ScriptPromiseResolver> m_resolver; | 44 Persistent<ScriptPromiseResolver> m_resolver; |
| 43 Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration; | 45 Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration; |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 // SyncGetRegistrationsCallbacks is an implementation of WebSyncGetRegistrations
Callbacks | 48 // SyncGetRegistrationsCallbacks is an implementation of |
| 47 // that will resolve the underlying promise depending on the result passed to | 49 // WebSyncGetRegistrationsCallbacks that will resolve the underlying promise |
| 48 // the callback. It takes a ServiceWorkerRegistration in its constructor and | 50 // depending on the result passed to the callback. It takes a |
| 49 // will pass it to the SyncRegistration. | 51 // ServiceWorkerRegistration in its constructor and will pass it to the |
| 52 // SyncRegistration. |
| 50 class SyncGetRegistrationsCallbacks final | 53 class SyncGetRegistrationsCallbacks final |
| 51 : public WebSyncGetRegistrationsCallbacks { | 54 : public WebSyncGetRegistrationsCallbacks { |
| 52 WTF_MAKE_NONCOPYABLE(SyncGetRegistrationsCallbacks); | 55 WTF_MAKE_NONCOPYABLE(SyncGetRegistrationsCallbacks); |
| 53 // FIXME(tasak): when making public/platform classes to use PartitionAlloc, | 56 // FIXME(tasak): When making public/platform classes to use PartitionAlloc, |
| 54 // the following macro should be moved to WebCallbacks defined in public/platf
ormWebCallbacks.h. | 57 // the following macro should be moved to WebCallbacks defined in |
| 58 // public/platformWebCallbacks.h. |
| 55 USING_FAST_MALLOC(SyncGetRegistrationsCallbacks); | 59 USING_FAST_MALLOC(SyncGetRegistrationsCallbacks); |
| 56 | 60 |
| 57 public: | 61 public: |
| 58 SyncGetRegistrationsCallbacks(ScriptPromiseResolver*, | 62 SyncGetRegistrationsCallbacks(ScriptPromiseResolver*, |
| 59 ServiceWorkerRegistration*); | 63 ServiceWorkerRegistration*); |
| 60 ~SyncGetRegistrationsCallbacks() override; | 64 ~SyncGetRegistrationsCallbacks() override; |
| 61 | 65 |
| 62 void onSuccess(const WebVector<WebSyncRegistration*>&) override; | 66 void onSuccess(const WebVector<WebSyncRegistration*>&) override; |
| 63 void onError(const WebSyncError&) override; | 67 void onError(const WebSyncError&) override; |
| 64 | 68 |
| 65 private: | 69 private: |
| 66 Persistent<ScriptPromiseResolver> m_resolver; | 70 Persistent<ScriptPromiseResolver> m_resolver; |
| 67 Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration; | 71 Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration; |
| 68 }; | 72 }; |
| 69 | 73 |
| 70 } // namespace blink | 74 } // namespace blink |
| 71 | 75 |
| 72 #endif // SyncCallbacks_h | 76 #endif // SyncCallbacks_h |
| OLD | NEW |