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

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

Issue 1302833004: [PushMessaging] Use appopriate type parameters for WebCallbacks (3/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 | « no previous file | 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" 9 #include "public/platform/WebPassOwnPtr.h"
10 #include "public/platform/modules/push_messaging/WebPushError.h"
11 #include "public/platform/modules/push_messaging/WebPushPermissionStatus.h" 10 #include "public/platform/modules/push_messaging/WebPushPermissionStatus.h"
12 #include "public/platform/modules/push_messaging/WebPushSubscription.h" 11 #include "public/platform/modules/push_messaging/WebPushSubscription.h"
13 12
14 namespace blink { 13 namespace blink {
15 14
16 class WebServiceWorkerRegistration; 15 class WebServiceWorkerRegistration;
16 struct WebPushError;
17 struct WebPushSubscriptionOptions; 17 struct WebPushSubscriptionOptions;
18 18
19 class WebPushSubscriptionCallbacks : public WebCallbacks<WebPassOwnPtr<WebPushSu bscription>, const WebPushError&> { 19 using WebPushSubscriptionCallbacks = WebCallbacks<WebPassOwnPtr<WebPushSubscript ion>, const WebPushError&>;
20 public: 20 using WebPushPermissionStatusCallbacks = WebCallbacks<WebPushPermissionStatus, c onst WebPushError&>;
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 };
47 using WebPushUnsubscribeCallbacks = WebCallbacks<bool, const WebPushError&>; 21 using WebPushUnsubscribeCallbacks = WebCallbacks<bool, const WebPushError&>;
48 22
49 class WebPushProvider { 23 class WebPushProvider {
50 public: 24 public:
51 virtual ~WebPushProvider() { } 25 virtual ~WebPushProvider() { }
52 26
53 // Takes ownership of the WebPushSubscriptionCallbacks. 27 // Takes ownership of the WebPushSubscriptionCallbacks.
54 // Does not take ownership of the WebServiceWorkerRegistration. 28 // Does not take ownership of the WebServiceWorkerRegistration.
55 virtual void subscribe(WebServiceWorkerRegistration*, const WebPushSubscript ionOptions&, WebPushSubscriptionCallbacks*) = 0; 29 virtual void subscribe(WebServiceWorkerRegistration*, const WebPushSubscript ionOptions&, WebPushSubscriptionCallbacks*) = 0;
56 30
57 // Takes ownership of the WebPushSubscriptionCallbacks. 31 // Takes ownership of the WebPushSubscriptionCallbacks.
58 // Does not take ownership of the WebServiceWorkerRegistration. 32 // Does not take ownership of the WebServiceWorkerRegistration.
59 virtual void getSubscription(WebServiceWorkerRegistration*, WebPushSubscript ionCallbacks*) = 0; 33 virtual void getSubscription(WebServiceWorkerRegistration*, WebPushSubscript ionCallbacks*) = 0;
60 34
61 // Takes ownership of the WebPushPermissionStatusCallbacks. 35 // Takes ownership of the WebPushPermissionStatusCallbacks.
62 // Does not take ownership of the WebServiceWorkerRegistration. 36 // Does not take ownership of the WebServiceWorkerRegistration.
63 virtual void getPermissionStatus(WebServiceWorkerRegistration*, const WebPus hSubscriptionOptions&, WebPushPermissionStatusCallbacks*) = 0; 37 virtual void getPermissionStatus(WebServiceWorkerRegistration*, const WebPus hSubscriptionOptions&, WebPushPermissionStatusCallbacks*) = 0;
64 38
65 // Takes ownership if the WebPushUnsubscribeCallbacks. 39 // Takes ownership if the WebPushUnsubscribeCallbacks.
66 // Does not take ownership of the WebServiceWorkerRegistration. 40 // Does not take ownership of the WebServiceWorkerRegistration.
67 virtual void unsubscribe(WebServiceWorkerRegistration*, WebPushUnsubscribeCa llbacks*) = 0; 41 virtual void unsubscribe(WebServiceWorkerRegistration*, WebPushUnsubscribeCa llbacks*) = 0;
68 }; 42 };
69 43
70 } // namespace blink 44 } // namespace blink
71 45
72 #endif // WebPushProvider_h 46 #endif // WebPushProvider_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698