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