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

Side by Side Diff: Source/modules/background_sync/SyncCallbacks.h

Issue 963683002: Add IDL and initial Blink API for Background Sync (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressing first round style issues Created 5 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 PushSubscriptionCallbacks_h 5 #ifndef SyncCallbacks_h
6 #define PushSubscriptionCallbacks_h 6 #define SyncCallbacks_h
7 7
8 #include "platform/heap/Handle.h" 8 #include "platform/heap/Handle.h"
9 #include "public/platform/WebCallbacks.h" 9 #include "public/platform/WebCallbacks.h"
10 #include "wtf/Noncopyable.h" 10 #include "wtf/Noncopyable.h"
11 #include "wtf/PassRefPtr.h" 11 #include "wtf/PassRefPtr.h"
12 #include "wtf/RefPtr.h" 12 #include "wtf/RefPtr.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class ServiceWorkerRegistration; 16 class ServiceWorkerRegistration;
17 class ScriptPromiseResolver; 17 class ScriptPromiseResolver;
18 struct WebPushError; 18 struct WebSyncError;
19 struct WebPushSubscription; 19 struct WebSyncRegistration;
20 20
21 // PushSubscriptionCallbacks is an implementation of WebPushSubscriptionCallback s 21 // SyncRegistrationCallbacks is an implementation of WebSyncRegistrationCallback s
22 // that will resolve the underlying promise depending on the result passed to 22 // that will resolve the underlying promise depending on the result passed to
23 // the callback. It takes a ServiceWorkerRegistration in its constructor and 23 // the callback. It takes a ServiceWorkerRegistration in its constructor and
24 // will pass it to the PushSubscription. 24 // will pass it to the SyncProvider.
Michael van Ouwerkerk 2015/03/02 14:19:11 s/SyncProvider/SyncRegistration/
iclelland 2015/03/05 04:32:48 Done.
25 class PushSubscriptionCallbacks final : public WebCallbacks<WebPushSubscription, WebPushError> { 25 class SyncRegistrationCallbacks final : public WebCallbacks<WebSyncRegistration, WebSyncError> {
26 WTF_MAKE_NONCOPYABLE(PushSubscriptionCallbacks); 26 WTF_MAKE_NONCOPYABLE(SyncRegistrationCallbacks);
27 public: 27 public:
28 PushSubscriptionCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver>, Ser viceWorkerRegistration*); 28 SyncRegistrationCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver>, Ser viceWorkerRegistration*);
29 ~PushSubscriptionCallbacks() override; 29 ~SyncRegistrationCallbacks() override;
30 30
31 void onSuccess(WebPushSubscription*) override; 31 void onSuccess(WebSyncRegistration*) override;
32 void onError(WebPushError*) override; 32 void onError(WebSyncError*) override;
33 33
34 private: 34 private:
35 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver; 35 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver;
36 Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration;
37 };
38
39 // SyncUnregistrationCallbacks is an implementation of
40 // WebSyncUnregistrationCallbacks that will resolve the underlying promise
41 // depending on the result passed to the callback. It takes a
42 // ServiceWorkerRegistration in its constructor and will pass it to the
43 // SyncProvider.
44 class SyncUnregistrationCallbacks final : public WebCallbacks<bool, WebSyncError > {
45 WTF_MAKE_NONCOPYABLE(SyncUnregistrationCallbacks);
46 public:
47 SyncUnregistrationCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver>, S erviceWorkerRegistration*);
48 ~SyncUnregistrationCallbacks() override;
49
50 void onSuccess(bool*) override;
51 void onError(WebSyncError*) override;
52
53 private:
54 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver;
36 Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration; 55 Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration;
Michael van Ouwerkerk 2015/03/02 14:19:11 This is never used.
37 }; 56 };
38 57
39 } // namespace blink 58 } // namespace blink
40 59
41 #endif // PushSubscriptionCallbacks_h 60 #endif // SyncCallbacks_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698