| 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/PushRegistration.h" | 6 #include "modules/push_messaging/PushRegistration.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 "modules/push_messaging/PushError.h" |
| 10 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 11 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| 11 #include "public/platform/Platform.h" | 12 #include "public/platform/Platform.h" |
| 12 #include "public/platform/WebPushProvider.h" | 13 #include "public/platform/WebPushProvider.h" |
| 13 #include "public/platform/WebPushRegistration.h" | 14 #include "public/platform/WebPushRegistration.h" |
| 14 #include "wtf/OwnPtr.h" | 15 #include "wtf/OwnPtr.h" |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 | 18 |
| 18 PushRegistration* PushRegistration::take(ScriptPromiseResolver*, WebPushRegistra
tion* pushRegistration, ServiceWorkerRegistration* serviceWorkerRegistration) | 19 PushRegistration* PushRegistration::take(ScriptPromiseResolver*, WebPushRegistra
tion* pushRegistration, ServiceWorkerRegistration* serviceWorkerRegistration) |
| 19 { | 20 { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 38 } | 39 } |
| 39 | 40 |
| 40 ScriptPromise PushRegistration::unregister(ScriptState* scriptState) | 41 ScriptPromise PushRegistration::unregister(ScriptState* scriptState) |
| 41 { | 42 { |
| 42 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); | 43 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); |
| 43 ScriptPromise promise = resolver->promise(); | 44 ScriptPromise promise = resolver->promise(); |
| 44 | 45 |
| 45 WebPushProvider* webPushProvider = Platform::current()->pushProvider(); | 46 WebPushProvider* webPushProvider = Platform::current()->pushProvider(); |
| 46 ASSERT(webPushProvider); | 47 ASSERT(webPushProvider); |
| 47 | 48 |
| 48 webPushProvider->unregister(m_serviceWorkerRegistration->webRegistration(),
new CallbackPromiseAdapter<bool, void>(resolver)); | 49 webPushProvider->unregister(m_serviceWorkerRegistration->webRegistration(),
new CallbackPromiseAdapter<bool, PushError>(resolver)); |
| 49 return promise; | 50 return promise; |
| 50 } | 51 } |
| 51 | 52 |
| 52 void PushRegistration::trace(Visitor* visitor) | 53 void PushRegistration::trace(Visitor* visitor) |
| 53 { | 54 { |
| 54 visitor->trace(m_serviceWorkerRegistration); | 55 visitor->trace(m_serviceWorkerRegistration); |
| 55 } | 56 } |
| 56 | 57 |
| 57 } // namespace blink | 58 } // namespace blink |
| OLD | NEW |