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

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

Issue 1304723002: [PushMessaging] Use appopriate type parameters for WebCallbacks (1/3). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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
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/PushSubscriptionCallbacks.h" 6 #include "modules/push_messaging/PushSubscriptionCallbacks.h"
7 7
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "modules/push_messaging/PushError.h" 9 #include "modules/push_messaging/PushError.h"
10 #include "modules/push_messaging/PushSubscription.h" 10 #include "modules/push_messaging/PushSubscription.h"
11 #include "modules/serviceworkers/ServiceWorkerRegistration.h" 11 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
12 #include "public/platform/modules/push_messaging/WebPushSubscription.h"
12 13
13 namespace blink { 14 namespace blink {
14 15
15 PushSubscriptionCallbacks::PushSubscriptionCallbacks(ScriptPromiseResolver* reso lver, ServiceWorkerRegistration* serviceWorkerRegistration) 16 PushSubscriptionCallbacks::PushSubscriptionCallbacks(ScriptPromiseResolver* reso lver, ServiceWorkerRegistration* serviceWorkerRegistration)
16 : m_resolver(resolver) 17 : m_resolver(resolver)
17 , m_serviceWorkerRegistration(serviceWorkerRegistration) 18 , m_serviceWorkerRegistration(serviceWorkerRegistration)
18 { 19 {
19 ASSERT(m_resolver); 20 ASSERT(m_resolver);
20 ASSERT(m_serviceWorkerRegistration); 21 ASSERT(m_serviceWorkerRegistration);
21 } 22 }
22 23
23 PushSubscriptionCallbacks::~PushSubscriptionCallbacks() 24 PushSubscriptionCallbacks::~PushSubscriptionCallbacks()
24 { 25 {
25 } 26 }
26 27
27 void PushSubscriptionCallbacks::onSuccess(WebPushSubscription* webPushSubscripti on) 28 void PushSubscriptionCallbacks::onSuccess(WebPassOwnPtr<WebPushSubscription> web PushSubscription)
28 { 29 {
29 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ eDOMObjectsAreStopped()) 30 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ eDOMObjectsAreStopped())
30 return; 31 return;
31 32
32 if (!webPushSubscription) { 33 m_resolver->resolve(PushSubscription::take(m_resolver.get(), webPushSubscrip tion.release(), m_serviceWorkerRegistration));
33 m_resolver->resolve(v8::Null(m_resolver->scriptState()->isolate()));
34 return;
35 }
36 m_resolver->resolve(PushSubscription::take(m_resolver.get(), webPushSubscrip tion, m_serviceWorkerRegistration));
37 } 34 }
38 35
39 void PushSubscriptionCallbacks::onError(WebPushError* error) 36 void PushSubscriptionCallbacks::onError(const WebPushError& error)
40 { 37 {
41 OwnPtr<WebPushError> ownError = adoptPtr(error);
42 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ eDOMObjectsAreStopped()) 38 if (!m_resolver->executionContext() || m_resolver->executionContext()->activ eDOMObjectsAreStopped())
43 return; 39 return;
44 m_resolver->reject(PushError::take(m_resolver.get(), *ownError)); 40 m_resolver->reject(PushError::take(m_resolver.get(), error));
45 } 41 }
46 42
47 } // namespace blink 43 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/push_messaging/PushSubscriptionCallbacks.h ('k') | public/platform/modules/push_messaging/WebPushClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698