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

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

Issue 2473483012: Move content/child/background_sync to Blink. (Closed)
Patch Set: Update OWNERS to make presubmit happy Created 4 years, 1 month 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 2015 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 SyncCallbacks_h 5 #ifndef SyncCallbacks_h
6 #define SyncCallbacks_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 "public/platform/modules/background_sync/WebSyncProvider.h" 10 #include "public/platform/modules/background_sync/background_sync.mojom-blink.h"
11 #include "public/platform/modules/background_sync/WebSyncRegistration.h"
12 #include "wtf/Noncopyable.h" 11 #include "wtf/Noncopyable.h"
13 #include "wtf/PassRefPtr.h" 12 #include "wtf/PassRefPtr.h"
14 #include "wtf/RefPtr.h" 13 #include "wtf/RefPtr.h"
15 14
16 namespace blink { 15 namespace blink {
17 16
18 class ServiceWorkerRegistration; 17 class ServiceWorkerRegistration;
19 class ScriptPromiseResolver; 18 class ScriptPromiseResolver;
20 struct WebSyncError; 19 struct WebSyncError;
21 struct WebSyncRegistration; 20 struct WebSyncRegistration;
22 21
23 // SyncRegistrationCallbacks is an implementation of 22 // SyncRegistrationCallbacks is an implementation of
24 // WebSyncRegistrationCallbacks that will resolve the underlying promise 23 // WebSyncRegistrationCallbacks that will resolve the underlying promise
25 // depending on the result passed to the callback. It takes a 24 // depending on the result passed to the callback. It takes a
26 // ServiceWorkerRegistration in its constructor and will pass it to the 25 // ServiceWorkerRegistration in its constructor and will pass it to the
27 // SyncRegistration. 26 // SyncRegistration.
28 class SyncRegistrationCallbacks final : public WebSyncRegistrationCallbacks { 27 class SyncRegistrationCallbacks final
jbroman 2016/11/05 22:51:09 It should probably be a followup CL, but this can
adithyas 2016/11/07 19:22:55 Acknowledged.
28 : public WebCallbacks<blink::mojom::blink::SyncRegistrationPtr,
29 const WebSyncError&> {
29 WTF_MAKE_NONCOPYABLE(SyncRegistrationCallbacks); 30 WTF_MAKE_NONCOPYABLE(SyncRegistrationCallbacks);
30 // FIXME(tasak): When making public/platform classes to use PartitionAlloc, 31 // FIXME(tasak): When making public/platform classes to use PartitionAlloc,
31 // the following macro should be moved to WebCallbacks defined in 32 // the following macro should be moved to WebCallbacks defined in
32 // public/platformWebCallbacks.h. 33 // public/platformWebCallbacks.h.
33 USING_FAST_MALLOC(SyncRegistrationCallbacks); 34 USING_FAST_MALLOC(SyncRegistrationCallbacks);
34 35
35 public: 36 public:
36 SyncRegistrationCallbacks(ScriptPromiseResolver*, ServiceWorkerRegistration*); 37 SyncRegistrationCallbacks(ScriptPromiseResolver*, ServiceWorkerRegistration*);
37 ~SyncRegistrationCallbacks() override; 38 ~SyncRegistrationCallbacks() override;
38 39
39 void onSuccess(std::unique_ptr<WebSyncRegistration>) override; 40 void onSuccess(blink::mojom::blink::SyncRegistrationPtr) override;
40 void onError(const WebSyncError&) override; 41 void onError(const WebSyncError&) override;
41 42
42 private: 43 private:
43 Persistent<ScriptPromiseResolver> m_resolver; 44 Persistent<ScriptPromiseResolver> m_resolver;
44 Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration; 45 Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration;
45 }; 46 };
46 47
47 // SyncGetRegistrationsCallbacks is an implementation of 48 // SyncGetRegistrationsCallbacks is an implementation of
48 // WebSyncGetRegistrationsCallbacks that will resolve the underlying promise 49 // WebSyncGetRegistrationsCallbacks that will resolve the underlying promise
49 // depending on the result passed to the callback. It takes a 50 // depending on the result passed to the callback. It takes a
50 // ServiceWorkerRegistration in its constructor and will pass it to the 51 // ServiceWorkerRegistration in its constructor and will pass it to the
51 // SyncRegistration. 52 // SyncRegistration.
52 class SyncGetRegistrationsCallbacks final 53 class SyncGetRegistrationsCallbacks final
53 : public WebSyncGetRegistrationsCallbacks { 54 : public WebCallbacks<
55 const WebVector<blink::mojom::blink::SyncRegistration*>&,
56 const WebSyncError&> {
54 WTF_MAKE_NONCOPYABLE(SyncGetRegistrationsCallbacks); 57 WTF_MAKE_NONCOPYABLE(SyncGetRegistrationsCallbacks);
55 // FIXME(tasak): When making public/platform classes to use PartitionAlloc, 58 // FIXME(tasak): When making public/platform classes to use PartitionAlloc,
56 // the following macro should be moved to WebCallbacks defined in 59 // the following macro should be moved to WebCallbacks defined in
57 // public/platformWebCallbacks.h. 60 // public/platformWebCallbacks.h.
58 USING_FAST_MALLOC(SyncGetRegistrationsCallbacks); 61 USING_FAST_MALLOC(SyncGetRegistrationsCallbacks);
59 62
60 public: 63 public:
61 SyncGetRegistrationsCallbacks(ScriptPromiseResolver*, 64 SyncGetRegistrationsCallbacks(ScriptPromiseResolver*,
62 ServiceWorkerRegistration*); 65 ServiceWorkerRegistration*);
63 ~SyncGetRegistrationsCallbacks() override; 66 ~SyncGetRegistrationsCallbacks() override;
64 67
65 void onSuccess(const WebVector<WebSyncRegistration*>&) override; 68 void onSuccess(
69 const WebVector<blink::mojom::blink::SyncRegistration*>&) override;
66 void onError(const WebSyncError&) override; 70 void onError(const WebSyncError&) override;
67 71
68 private: 72 private:
69 Persistent<ScriptPromiseResolver> m_resolver; 73 Persistent<ScriptPromiseResolver> m_resolver;
70 Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration; 74 Persistent<ServiceWorkerRegistration> m_serviceWorkerRegistration;
71 }; 75 };
72 76
73 } // namespace blink 77 } // namespace blink
74 78
75 #endif // SyncCallbacks_h 79 #endif // SyncCallbacks_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698