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

Side by Side Diff: Source/modules/push_messaging/PushRegistrationCallbacks.cpp

Issue 841333002: Push API: rename registration to subscription. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use https in the spec link. Created 5 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "modules/push_messaging/PushRegistrationCallbacks.h"
7
8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "modules/push_messaging/PushError.h"
10 #include "modules/push_messaging/PushRegistration.h"
11 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
12
13 namespace blink {
14
15 PushRegistrationCallbacks::PushRegistrationCallbacks(PassRefPtrWillBeRawPtr<Scri ptPromiseResolver> resolver, ServiceWorkerRegistration* registration)
16 : m_resolver(resolver)
17 , m_serviceWorkerRegistration(registration)
18 {
19 ASSERT(m_resolver);
20 ASSERT(m_serviceWorkerRegistration);
21 }
22
23 PushRegistrationCallbacks::~PushRegistrationCallbacks()
24 {
25 }
26
27 void PushRegistrationCallbacks::onSuccess(WebPushRegistration* webPushRegistrati on)
28 {
29 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ eDOMObjectsAreStopped()) {
30 PushRegistration::dispose(webPushRegistration);
31 return;
32 }
33
34 if (!webPushRegistration) {
35 m_resolver->resolve(v8::Null(m_resolver->scriptState()->isolate()));
36 return;
37 }
38 m_resolver->resolve(PushRegistration::take(m_resolver.get(), webPushRegistra tion, m_serviceWorkerRegistration));
39 }
40
41 void PushRegistrationCallbacks::onError(WebPushError* error)
42 {
43 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ eDOMObjectsAreStopped()) {
44 PushError::dispose(error);
45 return;
46 }
47 m_resolver->reject(PushError::take(m_resolver.get(), error));
48 }
49
50 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/push_messaging/PushRegistrationCallbacks.h ('k') | Source/modules/push_messaging/PushSubscription.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698