| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 return m_endpoint; | 45 return m_endpoint; |
| 46 } | 46 } |
| 47 | 47 |
| 48 PassRefPtr<DOMArrayBuffer> PushSubscription::curve25519dh() const | 48 PassRefPtr<DOMArrayBuffer> PushSubscription::curve25519dh() const |
| 49 { | 49 { |
| 50 return m_curve25519dh; | 50 return m_curve25519dh; |
| 51 } | 51 } |
| 52 | 52 |
| 53 ScriptPromise PushSubscription::unsubscribe(ScriptState* scriptState) | 53 ScriptPromise PushSubscription::unsubscribe(ScriptState* scriptState) |
| 54 { | 54 { |
| 55 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 55 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 56 ScriptPromise promise = resolver->promise(); | 56 ScriptPromise promise = resolver->promise(); |
| 57 | 57 |
| 58 WebPushProvider* webPushProvider = Platform::current()->pushProvider(); | 58 WebPushProvider* webPushProvider = Platform::current()->pushProvider(); |
| 59 ASSERT(webPushProvider); | 59 ASSERT(webPushProvider); |
| 60 | 60 |
| 61 webPushProvider->unsubscribe(m_serviceWorkerRegistration->webRegistration(),
new CallbackPromiseAdapter<bool, PushError>(resolver)); | 61 webPushProvider->unsubscribe(m_serviceWorkerRegistration->webRegistration(),
new CallbackPromiseAdapter<bool, PushError>(resolver)); |
| 62 return promise; | 62 return promise; |
| 63 } | 63 } |
| 64 | 64 |
| 65 ScriptValue PushSubscription::toJSONForBinding(ScriptState* scriptState) | 65 ScriptValue PushSubscription::toJSONForBinding(ScriptState* scriptState) |
| 66 { | 66 { |
| 67 V8ObjectBuilder result(scriptState); | 67 V8ObjectBuilder result(scriptState); |
| 68 result.addString("endpoint", endpoint()); | 68 result.addString("endpoint", endpoint()); |
| 69 | 69 |
| 70 // TODO(peter): Include |curve25519dh| in the serialized JSON blob if the in
tended | 70 // TODO(peter): Include |curve25519dh| in the serialized JSON blob if the in
tended |
| 71 // serialization behavior gets defined in the spec. | 71 // serialization behavior gets defined in the spec. |
| 72 | 72 |
| 73 return result.scriptValue(); | 73 return result.scriptValue(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 DEFINE_TRACE(PushSubscription) | 76 DEFINE_TRACE(PushSubscription) |
| 77 { | 77 { |
| 78 visitor->trace(m_serviceWorkerRegistration); | 78 visitor->trace(m_serviceWorkerRegistration); |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace blink | 81 } // namespace blink |
| OLD | NEW |