| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/push_messaging/PushSubscription.h" | 6 #include "modules/push_messaging/PushSubscription.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "bindings/core/v8/V8ObjectBuilder.h" | 10 #include "bindings/core/v8/V8ObjectBuilder.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 KURL PushSubscription::endpoint() const | 44 KURL PushSubscription::endpoint() const |
| 45 { | 45 { |
| 46 return m_endpoint; | 46 return m_endpoint; |
| 47 } | 47 } |
| 48 | 48 |
| 49 PassRefPtr<DOMArrayBuffer> PushSubscription::curve25519dh() const | 49 PassRefPtr<DOMArrayBuffer> PushSubscription::curve25519dh() const |
| 50 { | 50 { |
| 51 return m_curve25519dh; | 51 return m_curve25519dh; |
| 52 } | 52 } |
| 53 | 53 |
| 54 PassRefPtr<DOMArrayBuffer> PushSubscription::getKey(const AtomicString& name) co
nst |
| 55 { |
| 56 if (name == "curve25519dh") |
| 57 return m_curve25519dh; |
| 58 |
| 59 return nullptr; |
| 60 } |
| 61 |
| 54 ScriptPromise PushSubscription::unsubscribe(ScriptState* scriptState) | 62 ScriptPromise PushSubscription::unsubscribe(ScriptState* scriptState) |
| 55 { | 63 { |
| 56 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 64 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 57 ScriptPromise promise = resolver->promise(); | 65 ScriptPromise promise = resolver->promise(); |
| 58 | 66 |
| 59 WebPushProvider* webPushProvider = Platform::current()->pushProvider(); | 67 WebPushProvider* webPushProvider = Platform::current()->pushProvider(); |
| 60 ASSERT(webPushProvider); | 68 ASSERT(webPushProvider); |
| 61 | 69 |
| 62 webPushProvider->unsubscribe(m_serviceWorkerRegistration->webRegistration(),
new CallbackPromiseAdapter<bool, PushError>(resolver)); | 70 webPushProvider->unsubscribe(m_serviceWorkerRegistration->webRegistration(),
new CallbackPromiseAdapter<bool, PushError>(resolver)); |
| 63 return promise; | 71 return promise; |
| 64 } | 72 } |
| 65 | 73 |
| 66 ScriptValue PushSubscription::toJSONForBinding(ScriptState* scriptState) | 74 ScriptValue PushSubscription::toJSONForBinding(ScriptState* scriptState) |
| 67 { | 75 { |
| 68 V8ObjectBuilder result(scriptState); | 76 V8ObjectBuilder result(scriptState); |
| 69 result.addString("endpoint", endpoint()); | 77 result.addString("endpoint", endpoint()); |
| 70 | 78 |
| 71 // TODO(peter): Include |curve25519dh| in the serialized JSON blob if the in
tended | 79 // TODO(peter): Include |curve25519dh| in the serialized JSON blob if the in
tended |
| 72 // serialization behavior gets defined in the spec. | 80 // serialization behavior gets defined in the spec. |
| 73 | 81 |
| 74 return result.scriptValue(); | 82 return result.scriptValue(); |
| 75 } | 83 } |
| 76 | 84 |
| 77 DEFINE_TRACE(PushSubscription) | 85 DEFINE_TRACE(PushSubscription) |
| 78 { | 86 { |
| 79 visitor->trace(m_serviceWorkerRegistration); | 87 visitor->trace(m_serviceWorkerRegistration); |
| 80 } | 88 } |
| 81 | 89 |
| 82 } // namespace blink | 90 } // namespace blink |
| OLD | NEW |