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

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: Add missing serviceWorkerRegistration.syncManager to interface tests 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SyncCallbacks_h
6 #define SyncCallbacks_h
7
8 #include "platform/heap/Handle.h"
9 #include "public/platform/WebCallbacks.h"
10 #include "public/platform/modules/background_sync/WebSyncProvider.h"
11 #include "public/platform/modules/background_sync/WebSyncRegistration.h"
12 #include "wtf/Noncopyable.h"
13 #include "wtf/PassRefPtr.h"
14 #include "wtf/RefPtr.h"
15
16 namespace blink {
17
18 class ServiceWorkerRegistration;
19 class ScriptPromiseResolver;
20 struct WebSyncError;
21 struct WebSyncRegistration;
22 class WebString;
23
24 using WebSyncGetRegistrationsCallbacks = WebCallbacks<WebVector<WebSyncRegistrat ion>, WebSyncError>;
25
26 // SyncRegistrationCallbacks is an implementation of WebSyncRegistrationCallback s
27 // that will resolve the underlying promise depending on the result passed to
28 // the callback. It takes a ServiceWorkerRegistration in its constructor and
29 // will pass it to the SyncRegistration.
30 class SyncRegistrationCallbacks final : public WebCallbacks<WebSyncRegistration, WebSyncError> {
31 WTF_MAKE_NONCOPYABLE(SyncRegistrationCallbacks);
32 public:
33 SyncRegistrationCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver>, Ser viceWorkerRegistration*);
34 ~SyncRegistrationCallbacks() override;
35
36 void onSuccess(WebSyncRegistration*) override;
37 void onError(WebSyncError*) override;
38
39 private:
40 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver;
41 Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration;
42 };
43
44 // SyncUnregistrationCallbacks is an implementation of
45 // WebSyncUnregistrationCallbacks that will resolve the underlying promise
46 // depending on the result passed to the callback. It takes a
47 // ServiceWorkerRegistration in its constructor and will pass it to the
48 // SyncProvider.
49 class SyncUnregistrationCallbacks final : public WebCallbacks<bool, WebSyncError > {
50 WTF_MAKE_NONCOPYABLE(SyncUnregistrationCallbacks);
51 public:
52 SyncUnregistrationCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver>, S erviceWorkerRegistration*);
53 ~SyncUnregistrationCallbacks() override;
54
55 void onSuccess(bool*) override;
56 void onError(WebSyncError*) override;
57
58 private:
59 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver;
60 Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration;
61 };
62
63 // SyncGetRegistrationsCallbacks is an implementation of WebSyncGetRegistrations Callbacks
64 // that will resolve the underlying promise depending on the result passed to
65 // the callback. It takes a ServiceWorkerRegistration in its constructor and
66 // will pass it to the SyncRegistration.
67 class SyncGetRegistrationsCallbacks final : public WebCallbacks<WebVector<WebSyn cRegistration>, WebSyncError> {
68 WTF_MAKE_NONCOPYABLE(SyncGetRegistrationsCallbacks);
69 public:
70 SyncGetRegistrationsCallbacks(PassRefPtrWillBeRawPtr<ScriptPromiseResolver>, ServiceWorkerRegistration*);
71 ~SyncGetRegistrationsCallbacks() override;
72
73 void onSuccess(WebVector<WebSyncRegistration>*) override;
74 void onError(WebSyncError*) override;
75
76 private:
77 RefPtrWillBePersistent<ScriptPromiseResolver> m_resolver;
78 Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration;
79 };
80
81 } // namespace blink
82
83 #endif // SyncCallbacks_h
OLDNEW
« no previous file with comments | « Source/modules/background_sync/ServiceWorkerRegistrationSync.idl ('k') | Source/modules/background_sync/SyncCallbacks.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698