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 #include "modules/push_messaging/PushSubscription.h" | 5 #include "modules/push_messaging/PushSubscription.h" |
6 | 6 |
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
9 #include "bindings/core/v8/V8ObjectBuilder.h" | 9 #include "bindings/core/v8/V8ObjectBuilder.h" |
10 #include "modules/push_messaging/PushError.h" | 10 #include "modules/push_messaging/PushError.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 ScriptPromise PushSubscription::unsubscribe(ScriptState* scriptState) { | 58 ScriptPromise PushSubscription::unsubscribe(ScriptState* scriptState) { |
59 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 59 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
60 ScriptPromise promise = resolver->promise(); | 60 ScriptPromise promise = resolver->promise(); |
61 | 61 |
62 WebPushProvider* webPushProvider = Platform::current()->pushProvider(); | 62 WebPushProvider* webPushProvider = Platform::current()->pushProvider(); |
63 DCHECK(webPushProvider); | 63 DCHECK(webPushProvider); |
64 | 64 |
65 webPushProvider->unsubscribe( | 65 webPushProvider->unsubscribe( |
66 m_serviceWorkerRegistration->webRegistration(), | 66 m_serviceWorkerRegistration->webRegistration(), |
67 new CallbackPromiseAdapter<bool, PushError>(resolver)); | 67 WTF::makeUnique<CallbackPromiseAdapter<bool, PushError>>(resolver)); |
68 return promise; | 68 return promise; |
69 } | 69 } |
70 | 70 |
71 ScriptValue PushSubscription::toJSONForBinding(ScriptState* scriptState) { | 71 ScriptValue PushSubscription::toJSONForBinding(ScriptState* scriptState) { |
72 DCHECK(m_p256dh); | 72 DCHECK(m_p256dh); |
73 | 73 |
74 V8ObjectBuilder result(scriptState); | 74 V8ObjectBuilder result(scriptState); |
75 result.addString("endpoint", endpoint()); | 75 result.addString("endpoint", endpoint()); |
76 | 76 |
77 V8ObjectBuilder keys(scriptState); | 77 V8ObjectBuilder keys(scriptState); |
78 keys.add("p256dh", | 78 keys.add("p256dh", |
79 WTF::base64URLEncode(static_cast<const char*>(m_p256dh->data()), | 79 WTF::base64URLEncode(static_cast<const char*>(m_p256dh->data()), |
80 m_p256dh->byteLength())); | 80 m_p256dh->byteLength())); |
81 keys.add("auth", | 81 keys.add("auth", |
82 WTF::base64URLEncode(static_cast<const char*>(m_auth->data()), | 82 WTF::base64URLEncode(static_cast<const char*>(m_auth->data()), |
83 m_auth->byteLength())); | 83 m_auth->byteLength())); |
84 result.add("keys", keys); | 84 result.add("keys", keys); |
85 | 85 |
86 return result.scriptValue(); | 86 return result.scriptValue(); |
87 } | 87 } |
88 | 88 |
89 DEFINE_TRACE(PushSubscription) { | 89 DEFINE_TRACE(PushSubscription) { |
90 visitor->trace(m_options); | 90 visitor->trace(m_options); |
91 visitor->trace(m_p256dh); | 91 visitor->trace(m_p256dh); |
92 visitor->trace(m_auth); | 92 visitor->trace(m_auth); |
93 visitor->trace(m_serviceWorkerRegistration); | 93 visitor->trace(m_serviceWorkerRegistration); |
94 } | 94 } |
95 | 95 |
96 } // namespace blink | 96 } // namespace blink |
OLD | NEW |