| 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 28 matching lines...) Expand all Loading... |
| 39 { | 39 { |
| 40 } | 40 } |
| 41 | 41 |
| 42 KURL PushSubscription::endpoint() const | 42 KURL PushSubscription::endpoint() const |
| 43 { | 43 { |
| 44 return m_endpoint; | 44 return m_endpoint; |
| 45 } | 45 } |
| 46 | 46 |
| 47 ScriptPromise PushSubscription::unsubscribe(ScriptState* scriptState) | 47 ScriptPromise PushSubscription::unsubscribe(ScriptState* scriptState) |
| 48 { | 48 { |
| 49 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::
create(scriptState); | 49 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 50 ScriptPromise promise = resolver->promise(); | 50 ScriptPromise promise = resolver->promise(); |
| 51 | 51 |
| 52 WebPushProvider* webPushProvider = Platform::current()->pushProvider(); | 52 WebPushProvider* webPushProvider = Platform::current()->pushProvider(); |
| 53 ASSERT(webPushProvider); | 53 ASSERT(webPushProvider); |
| 54 | 54 |
| 55 webPushProvider->unsubscribe(m_serviceWorkerRegistration->webRegistration(),
new CallbackPromiseAdapter<bool, PushError>(resolver)); | 55 webPushProvider->unsubscribe(m_serviceWorkerRegistration->webRegistration(),
new CallbackPromiseAdapter<bool, PushError>(resolver)); |
| 56 return promise; | 56 return promise; |
| 57 } | 57 } |
| 58 | 58 |
| 59 ScriptValue PushSubscription::toJSONForBinding(ScriptState* scriptState) | 59 ScriptValue PushSubscription::toJSONForBinding(ScriptState* scriptState) |
| 60 { | 60 { |
| 61 V8ObjectBuilder result(scriptState); | 61 V8ObjectBuilder result(scriptState); |
| 62 result.addString("endpoint", endpoint()); | 62 result.addString("endpoint", endpoint()); |
| 63 | 63 |
| 64 return result.scriptValue(); | 64 return result.scriptValue(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 DEFINE_TRACE(PushSubscription) | 67 DEFINE_TRACE(PushSubscription) |
| 68 { | 68 { |
| 69 visitor->trace(m_serviceWorkerRegistration); | 69 visitor->trace(m_serviceWorkerRegistration); |
| 70 } | 70 } |
| 71 | 71 |
| 72 } // namespace blink | 72 } // namespace blink |
| OLD | NEW |