OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 PushSubscriptionCallbacks_h | 5 #ifndef PushSubscriptionCallbacks_h |
6 #define PushSubscriptionCallbacks_h | 6 #define PushSubscriptionCallbacks_h |
7 | 7 |
8 #include "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
9 #include "public/platform/modules/push_messaging/WebPushProvider.h" | 9 #include "public/platform/modules/push_messaging/WebPushProvider.h" |
10 #include "wtf/Noncopyable.h" | 10 #include "wtf/Noncopyable.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 class ServiceWorkerRegistration; | 14 class ServiceWorkerRegistration; |
15 class ScriptPromiseResolver; | 15 class ScriptPromiseResolver; |
16 struct WebPushError; | 16 struct WebPushError; |
17 struct WebPushSubscription; | 17 struct WebPushSubscription; |
18 | 18 |
19 // PushSubscriptionCallbacks is an implementation of WebPushSubscriptionCallback
s | 19 // This class is an implementation of WebPushSubscriptionCallbacks that will |
20 // that will resolve the underlying promise depending on the result passed to | 20 // resolve the underlying promise depending on the result passed to the |
21 // the callback. It takes a ServiceWorkerRegistration in its constructor and | 21 // callback. It takes a ServiceWorkerRegistration in its constructor and will |
22 // will pass it to the PushSubscription. | 22 // pass it to the PushSubscription. |
23 class PushSubscriptionCallbacks final : public WebPushSubscriptionCallbacks { | 23 class PushSubscriptionCallbacks final : public WebPushSubscriptionCallbacks { |
24 WTF_MAKE_NONCOPYABLE(PushSubscriptionCallbacks); | 24 WTF_MAKE_NONCOPYABLE(PushSubscriptionCallbacks); |
25 USING_FAST_MALLOC(PushSubscriptionCallbacks); | 25 USING_FAST_MALLOC(PushSubscriptionCallbacks); |
26 | 26 |
27 public: | 27 public: |
28 PushSubscriptionCallbacks(ScriptPromiseResolver*, ServiceWorkerRegistration*); | 28 PushSubscriptionCallbacks(ScriptPromiseResolver*, ServiceWorkerRegistration*); |
29 ~PushSubscriptionCallbacks() override; | 29 ~PushSubscriptionCallbacks() override; |
30 | 30 |
| 31 // WebPushSubscriptionCallbacks interface. |
31 void onSuccess(std::unique_ptr<WebPushSubscription>) override; | 32 void onSuccess(std::unique_ptr<WebPushSubscription>) override; |
32 void onError(const WebPushError&) override; | 33 void onError(const WebPushError&) override; |
33 | 34 |
34 private: | 35 private: |
35 Persistent<ScriptPromiseResolver> m_resolver; | 36 Persistent<ScriptPromiseResolver> m_resolver; |
36 Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration; | 37 Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration; |
37 }; | 38 }; |
38 | 39 |
39 } // namespace blink | 40 } // namespace blink |
40 | 41 |
41 #endif // PushSubscriptionCallbacks_h | 42 #endif // PushSubscriptionCallbacks_h |
OLD | NEW |