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

Side by Side 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 unified diff | Download patch
OLDNEW
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 "config.h" 5 #include "config.h"
6 #include "modules/push_messaging/PushRegistration.h" 6 #include "modules/push_messaging/PushRegistration.h"
7 7
8 #include "bindings/core/v8/CallbackPromiseAdapter.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
11 #include "public/platform/Platform.h"
12 #include "public/platform/WebPushProvider.h"
13 #include "public/platform/WebPushRegistration.h"
8 #include "wtf/OwnPtr.h" 14 #include "wtf/OwnPtr.h"
9 15
10 namespace blink { 16 namespace blink {
11 17
12 PushRegistration* PushRegistration::take(ScriptPromiseResolver*, WebType* regist rationRaw) 18 PushRegistration* PushRegistration::take(ScriptPromiseResolver*, WebPushRegistra tion* pushRegistration, ServiceWorkerRegistration* serviceWorkerRegistration)
13 { 19 {
14 OwnPtr<WebType> registration = adoptPtr(registrationRaw); 20 OwnPtr<WebPushRegistration> registration = adoptPtr(pushRegistration);
15 return new PushRegistration(registration->endpoint, registration->registrati onId); 21 return new PushRegistration(registration->endpoint, registration->registrati onId, serviceWorkerRegistration);
16 } 22 }
17 23
18 void PushRegistration::dispose(WebType* registrationRaw) 24 void PushRegistration::dispose(WebPushRegistration* pushRegistration)
19 { 25 {
20 delete registrationRaw; 26 delete pushRegistration;
21 } 27 }
22 28
23 PushRegistration::PushRegistration(const String& pushEndpoint, const String& pus hRegistrationId) 29 PushRegistration::PushRegistration(const String& pushEndpoint, const String& pus hRegistrationId, ServiceWorkerRegistration* registration)
24 : m_pushEndpoint(pushEndpoint) 30 : m_pushEndpoint(pushEndpoint)
25 , m_pushRegistrationId(pushRegistrationId) 31 , m_pushRegistrationId(pushRegistrationId)
32 , m_serviceWorkerRegistration(registration)
26 { 33 {
27 } 34 }
28 35
29 PushRegistration::~PushRegistration() 36 PushRegistration::~PushRegistration()
30 { 37 {
31 } 38 }
32 39
40 ScriptPromise PushRegistration::unregister(ScriptState* scriptState)
41 {
42 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState);
43 ScriptPromise promise = resolver->promise();
44
45 WebPushProvider* webPushProvider = Platform::current()->pushProvider();
46 ASSERT(webPushProvider);
47
48 webPushProvider->unregister(m_serviceWorkerRegistration->webRegistration(), new CallbackPromiseAdapter<bool, void>(resolver));
49 return promise;
50 }
51
52 void PushRegistration::trace(Visitor* visitor)
53 {
54 visitor->trace(m_serviceWorkerRegistration);
55 }
56
33 } // namespace blink 57 } // namespace blink
OLDNEW
« 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