OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 BackgroundFetchBridge_h | 5 #ifndef BackgroundFetchBridge_h |
6 #define BackgroundFetchBridge_h | 6 #define BackgroundFetchBridge_h |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 9 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
10 #include "platform/Supplementable.h" | 10 #include "platform/Supplementable.h" |
11 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
12 #include "public/platform/modules/background_fetch/background_fetch.mojom-blink.
h" | 12 #include "public/platform/modules/background_fetch/background_fetch.mojom-blink.
h" |
13 #include "wtf/Functional.h" | 13 #include "wtf/Functional.h" |
14 #include "wtf/Vector.h" | 14 #include "wtf/Vector.h" |
15 #include "wtf/text/WTFString.h" | 15 #include "wtf/text/WTFString.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 class BackgroundFetchOptions; | 19 class BackgroundFetchOptions; |
20 class BackgroundFetchRegistration; | 20 class BackgroundFetchRegistration; |
| 21 class WebServiceWorkerRequest; |
21 | 22 |
22 // The bridge is responsible for establishing and maintaining the Mojo | 23 // The bridge is responsible for establishing and maintaining the Mojo |
23 // connection to the BackgroundFetchService. It's keyed on an active Service | 24 // connection to the BackgroundFetchService. It's keyed on an active Service |
24 // Worker Registration. | 25 // Worker Registration. |
25 class BackgroundFetchBridge final | 26 class BackgroundFetchBridge final |
26 : public GarbageCollectedFinalized<BackgroundFetchBridge>, | 27 : public GarbageCollectedFinalized<BackgroundFetchBridge>, |
27 public Supplement<ServiceWorkerRegistration> { | 28 public Supplement<ServiceWorkerRegistration> { |
28 USING_GARBAGE_COLLECTED_MIXIN(BackgroundFetchBridge); | 29 USING_GARBAGE_COLLECTED_MIXIN(BackgroundFetchBridge); |
29 WTF_MAKE_NONCOPYABLE(BackgroundFetchBridge); | 30 WTF_MAKE_NONCOPYABLE(BackgroundFetchBridge); |
30 | 31 |
31 public: | 32 public: |
32 using AbortCallback = Function<void(mojom::blink::BackgroundFetchError)>; | 33 using AbortCallback = Function<void(mojom::blink::BackgroundFetchError)>; |
33 using GetTagsCallback = | 34 using GetTagsCallback = |
34 Function<void(mojom::blink::BackgroundFetchError, const Vector<String>&)>; | 35 Function<void(mojom::blink::BackgroundFetchError, const Vector<String>&)>; |
35 using RegistrationCallback = Function<void(mojom::blink::BackgroundFetchError, | 36 using RegistrationCallback = Function<void(mojom::blink::BackgroundFetchError, |
36 BackgroundFetchRegistration*)>; | 37 BackgroundFetchRegistration*)>; |
37 using UpdateUICallback = Function<void(mojom::blink::BackgroundFetchError)>; | 38 using UpdateUICallback = Function<void(mojom::blink::BackgroundFetchError)>; |
38 | 39 |
39 static BackgroundFetchBridge* from(ServiceWorkerRegistration*); | 40 static BackgroundFetchBridge* from(ServiceWorkerRegistration*); |
40 static const char* supplementName(); | 41 static const char* supplementName(); |
41 | 42 |
42 virtual ~BackgroundFetchBridge(); | 43 virtual ~BackgroundFetchBridge(); |
43 | 44 |
44 // Creates a new Background Fetch registration identified by |tag| with the | 45 // Creates a new Background Fetch registration identified by |tag| with the |
45 // given |options| for the sequence of |requests|. The |callback| will be | 46 // given |options| for the sequence of |requests|. The |callback| will be |
46 // invoked when the registration has been created. | 47 // invoked when the registration has been created. |
47 void fetch(const String& tag, | 48 void fetch(const String& tag, |
| 49 Vector<WebServiceWorkerRequest> requests, |
48 const BackgroundFetchOptions&, | 50 const BackgroundFetchOptions&, |
49 std::unique_ptr<RegistrationCallback>); | 51 std::unique_ptr<RegistrationCallback>); |
50 | 52 |
51 // Updates the user interface for the Background Fetch identified by |tag| | 53 // Updates the user interface for the Background Fetch identified by |tag| |
52 // with the updated |title|. Will invoke the |callback| when the interface | 54 // with the updated |title|. Will invoke the |callback| when the interface |
53 // has been requested to update. | 55 // has been requested to update. |
54 void updateUI(const String& tag, | 56 void updateUI(const String& tag, |
55 const String& title, | 57 const String& title, |
56 std::unique_ptr<UpdateUICallback>); | 58 std::unique_ptr<UpdateUICallback>); |
57 | 59 |
(...skipping 22 matching lines...) Expand all Loading... |
80 void didGetRegistration(std::unique_ptr<RegistrationCallback>, | 82 void didGetRegistration(std::unique_ptr<RegistrationCallback>, |
81 mojom::blink::BackgroundFetchError, | 83 mojom::blink::BackgroundFetchError, |
82 mojom::blink::BackgroundFetchRegistrationPtr); | 84 mojom::blink::BackgroundFetchRegistrationPtr); |
83 | 85 |
84 mojom::blink::BackgroundFetchServicePtr m_backgroundFetchService; | 86 mojom::blink::BackgroundFetchServicePtr m_backgroundFetchService; |
85 }; | 87 }; |
86 | 88 |
87 } // namespace blink | 89 } // namespace blink |
88 | 90 |
89 #endif // BackgroundFetchBridge_h | 91 #endif // BackgroundFetchBridge_h |
OLD | NEW |