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

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

Issue 793913002: Stub implementation for PushRegistration.unregister(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@mvan_6
Patch Set: remove trace 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/PushRegistration.cpp
diff --git a/Source/modules/push_messaging/PushRegistration.cpp b/Source/modules/push_messaging/PushRegistration.cpp
index 79a9bbae88b1fdde1f6109bdc2e282ed3f1a7ff3..83713fb00f76519612903129bd7abfab58f5b639 100644
--- a/Source/modules/push_messaging/PushRegistration.cpp
+++ b/Source/modules/push_messaging/PushRegistration.cpp
@@ -5,24 +5,31 @@
#include "config.h"
#include "modules/push_messaging/PushRegistration.h"
+#include "bindings/core/v8/CallbackPromiseAdapter.h"
+#include "bindings/core/v8/ScriptPromiseResolver.h"
+#include "modules/serviceworkers/ServiceWorkerRegistration.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebPushProvider.h"
+#include "public/platform/WebPushRegistration.h"
#include "wtf/OwnPtr.h"
namespace blink {
-PushRegistration* PushRegistration::take(ScriptPromiseResolver*, WebType* registrationRaw)
+PushRegistration* PushRegistration::take(ScriptPromiseResolver*, WebPushRegistration* pushRegistration, ServiceWorkerRegistration* serviceWorkerRegistration)
{
- OwnPtr<WebType> registration = adoptPtr(registrationRaw);
- return new PushRegistration(registration->endpoint, registration->registrationId);
+ OwnPtr<WebPushRegistration> registration = adoptPtr(pushRegistration);
+ return new PushRegistration(registration->endpoint, registration->registrationId, serviceWorkerRegistration);
}
-void PushRegistration::dispose(WebType* registrationRaw)
+void PushRegistration::dispose(WebPushRegistration* pushRegistration)
{
- delete registrationRaw;
+ delete pushRegistration;
}
-PushRegistration::PushRegistration(const String& pushEndpoint, const String& pushRegistrationId)
+PushRegistration::PushRegistration(const String& pushEndpoint, const String& pushRegistrationId, ServiceWorkerRegistration* registration)
: m_pushEndpoint(pushEndpoint)
, m_pushRegistrationId(pushRegistrationId)
+ , m_serviceWorkerRegistration(registration)
{
}
@@ -30,4 +37,21 @@ PushRegistration::~PushRegistration()
{
}
+ScriptPromise PushRegistration::unregister(ScriptState* scriptState)
+{
+ RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
+ ScriptPromise promise = resolver->promise();
+
+ WebPushProvider* webPushProvider = Platform::current()->pushProvider();
+ ASSERT(webPushProvider);
+
+ webPushProvider->unregister(m_serviceWorkerRegistration->webRegistration(), new CallbackPromiseAdapter<bool, void>(resolver));
+ return promise;
+}
+
+void PushRegistration::trace(Visitor* visitor)
+{
+ visitor->trace(m_serviceWorkerRegistration);
+}
+
} // namespace blink
« no previous file with comments | « Source/modules/push_messaging/PushRegistration.h ('k') | Source/modules/push_messaging/PushRegistration.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698