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

Unified Diff: Source/modules/push_messaging/PushRegistrationCallback.cpp

Issue 793913002: Stub implementation for PushRegistration.unregister(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@mvan_6
Patch Set: rebase Created 6 years 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/push_messaging/PushRegistrationCallback.cpp
diff --git a/Source/modules/push_messaging/PushRegistrationCallback.cpp b/Source/modules/push_messaging/PushRegistrationCallback.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b693ec4fd8226ee75c0803ce426c34263e292105
--- /dev/null
+++ b/Source/modules/push_messaging/PushRegistrationCallback.cpp
@@ -0,0 +1,50 @@
+// Copyright 2014 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/PushRegistrationCallback.h"
+
+#include "bindings/core/v8/ScriptPromiseResolver.h"
+#include "modules/push_messaging/PushError.h"
+#include "modules/push_messaging/PushRegistration.h"
+#include "modules/serviceworkers/ServiceWorkerRegistration.h"
+
+namespace blink {
+
+PushRegistrationCallback::PushRegistrationCallback(PassRefPtr<ScriptPromiseResolver> resolver, ServiceWorkerRegistration* registration)
+ : m_resolver(resolver)
+ , m_registration(registration)
+{
+ ASSERT(m_resolver);
+ ASSERT(m_registration);
+}
+
+PushRegistrationCallback::~PushRegistrationCallback()
+{
+}
+
+void PushRegistrationCallback::onSuccess(WebPushRegistration* result)
+{
+ if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
+ PushRegistration::dispose(result);
+ return;
+ }
+ m_resolver->resolve(PushRegistration::take(m_resolver.get(), result, m_registration));
+}
+
+void PushRegistrationCallback::onError(WebPushError* error)
+{
+ if (!m_resolver->executionContext() || m_resolver->executionContext()->activeDOMObjectsAreStopped()) {
+ PushError::dispose(error);
+ return;
+ }
+ m_resolver->reject(PushError::take(m_resolver.get(), error));
+}
+
+void PushRegistrationCallback::trace(Visitor* visitor)
+{
+ visitor->trace(m_registration);
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698