| 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 "modules/push_messaging/PushSubscriptionCallbacks.h" | 5 #include "modules/push_messaging/PushSubscriptionCallbacks.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "modules/push_messaging/PushError.h" | 8 #include "modules/push_messaging/PushError.h" |
| 9 #include "modules/push_messaging/PushSubscription.h" | 9 #include "modules/push_messaging/PushSubscription.h" |
| 10 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 10 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 PushSubscriptionCallbacks::~PushSubscriptionCallbacks() {} | 26 PushSubscriptionCallbacks::~PushSubscriptionCallbacks() {} |
| 27 | 27 |
| 28 void PushSubscriptionCallbacks::onSuccess( | 28 void PushSubscriptionCallbacks::onSuccess( |
| 29 std::unique_ptr<WebPushSubscription> webPushSubscription) { | 29 std::unique_ptr<WebPushSubscription> webPushSubscription) { |
| 30 if (!m_resolver->getExecutionContext() || | 30 if (!m_resolver->getExecutionContext() || |
| 31 m_resolver->getExecutionContext()->isContextDestroyed()) | 31 m_resolver->getExecutionContext()->isContextDestroyed()) |
| 32 return; | 32 return; |
| 33 | 33 |
| 34 m_resolver->resolve(PushSubscription::take( | 34 m_resolver->resolve(PushSubscription::take( |
| 35 m_resolver.get(), wrapUnique(webPushSubscription.release()), | 35 m_resolver.get(), WTF::wrapUnique(webPushSubscription.release()), |
| 36 m_serviceWorkerRegistration)); | 36 m_serviceWorkerRegistration)); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void PushSubscriptionCallbacks::onError(const WebPushError& error) { | 39 void PushSubscriptionCallbacks::onError(const WebPushError& error) { |
| 40 if (!m_resolver->getExecutionContext() || | 40 if (!m_resolver->getExecutionContext() || |
| 41 m_resolver->getExecutionContext()->isContextDestroyed()) | 41 m_resolver->getExecutionContext()->isContextDestroyed()) |
| 42 return; | 42 return; |
| 43 m_resolver->reject(PushError::take(m_resolver.get(), error)); | 43 m_resolver->reject(PushError::take(m_resolver.get(), error)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 } // namespace blink | 46 } // namespace blink |
| OLD | NEW |