| Index: Source/modules/background_sync/SyncRegistrationCallbacks.cpp
|
| diff --git a/Source/modules/push_messaging/PushSubscriptionCallbacks.cpp b/Source/modules/background_sync/SyncRegistrationCallbacks.cpp
|
| similarity index 34%
|
| copy from Source/modules/push_messaging/PushSubscriptionCallbacks.cpp
|
| copy to Source/modules/background_sync/SyncRegistrationCallbacks.cpp
|
| index 9e64505a8705c78640a5325f5ee9c0abf527e67d..55ad9a45e6d153b57e0b9df28b3fe8955889669c 100644
|
| --- a/Source/modules/push_messaging/PushSubscriptionCallbacks.cpp
|
| +++ b/Source/modules/background_sync/SyncRegistrationCallbacks.cpp
|
| @@ -1,18 +1,18 @@
|
| -// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| #include "config.h"
|
| -#include "modules/push_messaging/PushSubscriptionCallbacks.h"
|
| +#include "modules/background_sync/SyncRegistrationCallbacks.h"
|
|
|
| #include "bindings/core/v8/ScriptPromiseResolver.h"
|
| -#include "modules/push_messaging/PushError.h"
|
| -#include "modules/push_messaging/PushSubscription.h"
|
| +#include "modules/background_sync/SyncError.h"
|
| +#include "modules/background_sync/SyncRegistration.h"
|
| #include "modules/serviceworkers/ServiceWorkerRegistration.h"
|
|
|
| namespace blink {
|
|
|
| -PushSubscriptionCallbacks::PushSubscriptionCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver, ServiceWorkerRegistration* serviceWorkerRegistration)
|
| +SyncRegistrationCallbacks::SyncRegistrationCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver, ServiceWorkerRegistration* serviceWorkerRegistration)
|
| : m_resolver(resolver)
|
| , m_serviceWorkerRegistration(serviceWorkerRegistration)
|
| {
|
| @@ -20,31 +20,61 @@ PushSubscriptionCallbacks::PushSubscriptionCallbacks(PassRefPtrWillBeRawPtr<Scri
|
| ASSERT(m_serviceWorkerRegistration);
|
| }
|
|
|
| -PushSubscriptionCallbacks::~PushSubscriptionCallbacks()
|
| +SyncRegistrationCallbacks::~SyncRegistrationCallbacks()
|
| {
|
| }
|
|
|
| -void PushSubscriptionCallbacks::onSuccess(WebPushSubscription* webPushSubscription)
|
| +void SyncRegistrationCallbacks::onSuccess(WebSyncRegistration* webSyncRegistration)
|
| {
|
| if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
|
| - PushSubscription::dispose(webPushSubscription);
|
| + SyncRegistration::dispose(webSyncRegistration);
|
| return;
|
| }
|
|
|
| - if (!webPushSubscription) {
|
| + if (!webSyncRegistration) {
|
| m_resolver->resolve(v8::Null(m_resolver->scriptState()->isolate()));
|
| return;
|
| }
|
| - m_resolver->resolve(PushSubscription::take(m_resolver.get(), webPushSubscription, m_serviceWorkerRegistration));
|
| + m_resolver->resolve(SyncRegistration::take(m_resolver.get(), webSyncRegistration, m_serviceWorkerRegistration));
|
| }
|
|
|
| -void PushSubscriptionCallbacks::onError(WebPushError* error)
|
| +void SyncRegistrationCallbacks::onError(WebSyncError* error)
|
| {
|
| if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
|
| - PushError::dispose(error);
|
| + SyncError::dispose(error);
|
| return;
|
| }
|
| - m_resolver->reject(PushError::take(m_resolver.get(), error));
|
| + m_resolver->reject(SyncError::take(m_resolver.get(), error));
|
| +}
|
| +
|
| +SyncUnregistrationCallbacks::SyncUnregistrationCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver> resolver, ServiceWorkerRegistration* serviceWorkerRegistration)
|
| + : m_resolver(resolver)
|
| + , m_serviceWorkerRegistration(serviceWorkerRegistration)
|
| +{
|
| + ASSERT(m_resolver);
|
| + ASSERT(m_serviceWorkerRegistration);
|
| +}
|
| +
|
| +SyncUnregistrationCallbacks::~SyncUnregistrationCallbacks()
|
| +{
|
| +}
|
| +
|
| +void SyncUnregistrationCallbacks::onSuccess(bool* status)
|
| +{
|
| + if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
|
| + return;
|
| + }
|
| +
|
| + m_resolver->resolve(*status);
|
| +}
|
| +
|
| +void SyncUnregistrationCallbacks::onError(WebSyncError* error)
|
| +{
|
| + if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
|
| + SyncError::dispose(error);
|
| + return;
|
| + }
|
| + m_resolver->reject(SyncError::take(m_resolver.get(), error));
|
| }
|
|
|
| } // namespace blink
|
|
|