Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1129)

Unified Diff: Source/modules/background_sync/SyncRegistrationCallbacks.cpp

Issue 963683002: Add IDL and initial Blink API for Background Sync (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update failing layout test Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698