| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "config.h" |
| 6 #include "modules/push_messaging/PushRegistrationCallback.h" |
| 7 |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "modules/push_messaging/PushError.h" |
| 10 #include "modules/push_messaging/PushRegistration.h" |
| 11 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 PushRegistrationCallback::PushRegistrationCallback(PassRefPtr<ScriptPromiseResol
ver> resolver, ServiceWorkerRegistration* registration) |
| 16 : m_resolver(resolver) |
| 17 , m_registration(registration) |
| 18 { |
| 19 ASSERT(m_resolver); |
| 20 ASSERT(m_registration); |
| 21 } |
| 22 |
| 23 PushRegistrationCallback::~PushRegistrationCallback() |
| 24 { |
| 25 } |
| 26 |
| 27 void PushRegistrationCallback::onSuccess(WebPushRegistration* result) |
| 28 { |
| 29 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ
eDOMObjectsAreStopped()) { |
| 30 PushRegistration::dispose(result); |
| 31 return; |
| 32 } |
| 33 m_resolver->resolve(PushRegistration::take(m_resolver.get(), result, m_regis
tration)); |
| 34 } |
| 35 |
| 36 void PushRegistrationCallback::onError(WebPushError* error) |
| 37 { |
| 38 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ
eDOMObjectsAreStopped()) { |
| 39 PushError::dispose(error); |
| 40 return; |
| 41 } |
| 42 m_resolver->reject(PushError::take(m_resolver.get(), error)); |
| 43 } |
| 44 |
| 45 void PushRegistrationCallback::trace(Visitor* visitor) |
| 46 { |
| 47 visitor->trace(m_registration); |
| 48 } |
| 49 |
| 50 } // namespace blink |
| OLD | NEW |