| 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" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| 11 #include "public/platform/Platform.h" |
| 12 #include "public/platform/WebPushProvider.h" |
| 8 #include "wtf/OwnPtr.h" | 13 #include "wtf/OwnPtr.h" |
| 9 | 14 |
| 10 namespace blink { | 15 namespace blink { |
| 11 | 16 |
| 12 PushRegistration* PushRegistration::take(ScriptPromiseResolver*, WebType* regist
rationRaw) | 17 PushRegistration* PushRegistration::take(ScriptPromiseResolver*, WebType* pushRe
gistration, ServiceWorkerRegistration* serviceWorkerRegistration) |
| 13 { | 18 { |
| 14 OwnPtr<WebType> registration = adoptPtr(registrationRaw); | 19 OwnPtr<WebType> registration = adoptPtr(pushRegistration); |
| 15 return new PushRegistration(registration->endpoint, registration->registrati
onId); | 20 return new PushRegistration(registration->endpoint, registration->registrati
onId, serviceWorkerRegistration); |
| 16 } | 21 } |
| 17 | 22 |
| 18 void PushRegistration::dispose(WebType* registrationRaw) | 23 void PushRegistration::dispose(WebType* pushRegistration) |
| 19 { | 24 { |
| 20 delete registrationRaw; | 25 delete pushRegistration; |
| 21 } | 26 } |
| 22 | 27 |
| 23 PushRegistration::PushRegistration(const String& pushEndpoint, const String& pus
hRegistrationId) | 28 PushRegistration::PushRegistration(const String& pushEndpoint, const String& pus
hRegistrationId, ServiceWorkerRegistration* registration) |
| 24 : m_pushEndpoint(pushEndpoint) | 29 : m_pushEndpoint(pushEndpoint) |
| 25 , m_pushRegistrationId(pushRegistrationId) | 30 , m_pushRegistrationId(pushRegistrationId) |
| 31 , m_registration(registration) |
| 26 { | 32 { |
| 27 } | 33 } |
| 28 | 34 |
| 29 PushRegistration::~PushRegistration() | 35 PushRegistration::~PushRegistration() |
| 30 { | 36 { |
| 31 } | 37 } |
| 32 | 38 |
| 39 ScriptPromise PushRegistration::unregister(ScriptState* scriptState) |
| 40 { |
| 41 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); |
| 42 ScriptPromise promise = resolver->promise(); |
| 43 |
| 44 WebPushProvider* webPushProvider = Platform::current()->pushProvider(); |
| 45 ASSERT(webPushProvider); |
| 46 |
| 47 webPushProvider->unregister(m_registration->webRegistration(), new CallbackP
romiseAdapter<bool, void>(resolver)); |
| 48 return promise; |
| 49 } |
| 50 |
| 51 void PushRegistration::trace(Visitor* visitor) |
| 52 { |
| 53 visitor->trace(m_registration); |
| 54 } |
| 55 |
| 33 } // namespace blink | 56 } // namespace blink |
| OLD | NEW |