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

Side by Side Diff: public/platform/modules/push_messaging/WebPushProvider.h

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
« no previous file with comments | « public/platform/modules/push_messaging/WebPushClient.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef WebPushProvider_h 5 #ifndef WebPushProvider_h
6 #define WebPushProvider_h 6 #define WebPushProvider_h
7 7
8 #include "public/platform/WebCallbacks.h" 8 #include "public/platform/WebCallbacks.h"
9 #include "public/platform/WebPassOwnPtr.h"
10 #include "public/platform/modules/push_messaging/WebPushError.h"
9 #include "public/platform/modules/push_messaging/WebPushPermissionStatus.h" 11 #include "public/platform/modules/push_messaging/WebPushPermissionStatus.h"
12 #include "public/platform/modules/push_messaging/WebPushSubscription.h"
10 13
11 namespace blink { 14 namespace blink {
12 15
13 class WebServiceWorkerRegistration; 16 class WebServiceWorkerRegistration;
14 struct WebPushError;
15 struct WebPushSubscription;
16 struct WebPushSubscriptionOptions; 17 struct WebPushSubscriptionOptions;
17 18
18 using WebPushSubscriptionCallbacks = WebCallbacks<WebPushSubscription*, WebPushE rror*>; 19 class WebPushSubscriptionCallbacks : public WebCallbacks<WebPassOwnPtr<WebPushSu bscription>, const WebPushError&> {
19 using WebPushPermissionStatusCallbacks = WebCallbacks<WebPushPermissionStatus*, WebPushError*>; 20 public:
21 void onSuccess(WebPushSubscription* r)
22 {
23 onSuccess(adoptWebPtr(r));
24 }
25 void onError(WebPushError* e)
26 {
27 onError(*e);
28 delete e;
29 }
30 void onSuccess(WebPassOwnPtr<WebPushSubscription>) override {}
31 void onError(const WebPushError&) override {}
32 };
33 class WebPushPermissionStatusCallbacks : public WebCallbacks<WebPushPermissionSt atus, const WebPushError&> {
34 public:
35 void onSuccess(WebPushPermissionStatus* r)
36 {
37 onSuccess(*r);
38 }
39 void onError(WebPushError* e)
40 {
41 onError(*e);
42 delete e;
43 }
44 void onSuccess(WebPushPermissionStatus) override {}
45 void onError(const WebPushError&) override {}
46 };
20 using WebPushUnsubscribeCallbacks = WebCallbacks<bool, const WebPushError&>; 47 using WebPushUnsubscribeCallbacks = WebCallbacks<bool, const WebPushError&>;
21 48
22 class WebPushProvider { 49 class WebPushProvider {
23 public: 50 public:
24 virtual ~WebPushProvider() { } 51 virtual ~WebPushProvider() { }
25 52
26 // Takes ownership of the WebPushSubscriptionCallbacks. 53 // Takes ownership of the WebPushSubscriptionCallbacks.
27 // Does not take ownership of the WebServiceWorkerRegistration. 54 // Does not take ownership of the WebServiceWorkerRegistration.
28 virtual void subscribe(WebServiceWorkerRegistration*, const WebPushSubscript ionOptions&, WebPushSubscriptionCallbacks*) = 0; 55 virtual void subscribe(WebServiceWorkerRegistration*, const WebPushSubscript ionOptions&, WebPushSubscriptionCallbacks*) = 0;
29 56
30 // Takes ownership of the WebPushSubscriptionCallbacks. 57 // Takes ownership of the WebPushSubscriptionCallbacks.
31 // Does not take ownership of the WebServiceWorkerRegistration. 58 // Does not take ownership of the WebServiceWorkerRegistration.
32 virtual void getSubscription(WebServiceWorkerRegistration*, WebPushSubscript ionCallbacks*) = 0; 59 virtual void getSubscription(WebServiceWorkerRegistration*, WebPushSubscript ionCallbacks*) = 0;
33 60
34 // Takes ownership of the WebPushPermissionStatusCallbacks. 61 // Takes ownership of the WebPushPermissionStatusCallbacks.
35 // Does not take ownership of the WebServiceWorkerRegistration. 62 // Does not take ownership of the WebServiceWorkerRegistration.
36 virtual void getPermissionStatus(WebServiceWorkerRegistration*, const WebPus hSubscriptionOptions&, WebPushPermissionStatusCallbacks*) = 0; 63 virtual void getPermissionStatus(WebServiceWorkerRegistration*, const WebPus hSubscriptionOptions&, WebPushPermissionStatusCallbacks*) = 0;
37 64
38 // Takes ownership if the WebPushUnsubscribeCallbacks. 65 // Takes ownership if the WebPushUnsubscribeCallbacks.
39 // Does not take ownership of the WebServiceWorkerRegistration. 66 // Does not take ownership of the WebServiceWorkerRegistration.
40 virtual void unsubscribe(WebServiceWorkerRegistration*, WebPushUnsubscribeCa llbacks*) = 0; 67 virtual void unsubscribe(WebServiceWorkerRegistration*, WebPushUnsubscribeCa llbacks*) = 0;
41 }; 68 };
42 69
43 } // namespace blink 70 } // namespace blink
44 71
45 #endif // WebPushProvider_h 72 #endif // WebPushProvider_h
OLDNEW
« no previous file with comments | « public/platform/modules/push_messaging/WebPushClient.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698