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

Side by Side Diff: third_party/WebKit/Source/modules/background_fetch/BackgroundFetchBridge.h

Issue 2762663002: BackgroundFetchRegistration.abort() should return a Promise. (Closed)
Patch Set: Created 3 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 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"
(...skipping 10 matching lines...) Expand all
21 // The bridge is responsible for establishing and maintaining the Mojo 21 // The bridge is responsible for establishing and maintaining the Mojo
22 // connection to the BackgroundFetchService. It's keyed on an active Service 22 // connection to the BackgroundFetchService. It's keyed on an active Service
23 // Worker Registration. 23 // Worker Registration.
24 class BackgroundFetchBridge final 24 class BackgroundFetchBridge final
25 : public GarbageCollectedFinalized<BackgroundFetchBridge>, 25 : public GarbageCollectedFinalized<BackgroundFetchBridge>,
26 public Supplement<ServiceWorkerRegistration> { 26 public Supplement<ServiceWorkerRegistration> {
27 USING_GARBAGE_COLLECTED_MIXIN(BackgroundFetchBridge); 27 USING_GARBAGE_COLLECTED_MIXIN(BackgroundFetchBridge);
28 WTF_MAKE_NONCOPYABLE(BackgroundFetchBridge); 28 WTF_MAKE_NONCOPYABLE(BackgroundFetchBridge);
29 29
30 public: 30 public:
31 using UpdateUICallback = Function<void(mojom::blink::BackgroundFetchError)>; 31 using AbortCallback = Function<void(mojom::blink::BackgroundFetchError)>;
32 using GetRegistrationCallback = 32 using GetRegistrationCallback =
33 Function<void(mojom::blink::BackgroundFetchError, 33 Function<void(mojom::blink::BackgroundFetchError,
34 BackgroundFetchRegistration*)>; 34 BackgroundFetchRegistration*)>;
35 using GetTagsCallback = 35 using GetTagsCallback =
36 Function<void(mojom::blink::BackgroundFetchError, const Vector<String>&)>; 36 Function<void(mojom::blink::BackgroundFetchError, const Vector<String>&)>;
37 using UpdateUICallback = Function<void(mojom::blink::BackgroundFetchError)>;
37 38
38 static BackgroundFetchBridge* from(ServiceWorkerRegistration*); 39 static BackgroundFetchBridge* from(ServiceWorkerRegistration*);
39 static const char* supplementName(); 40 static const char* supplementName();
40 41
41 virtual ~BackgroundFetchBridge(); 42 virtual ~BackgroundFetchBridge();
42 43
43 // TODO(peter): Implement support for the `fetch()` function in the bridge. 44 // TODO(peter): Implement support for the `fetch()` function in the bridge.
44 45
45 // Updates the user interface for the Background Fetch identified by |tag| 46 // Updates the user interface for the Background Fetch identified by |tag|
46 // with the updated |title|. Will invoke the |callback| when the interface 47 // with the updated |title|. Will invoke the |callback| when the interface
47 // has been requested to update. 48 // has been requested to update.
48 void updateUI(const String& tag, 49 void updateUI(const String& tag,
49 const String& title, 50 const String& title,
50 std::unique_ptr<UpdateUICallback>); 51 std::unique_ptr<UpdateUICallback>);
51 52
52 // Aborts the active Background Fetch for |tag|. Does not respond. 53 // Aborts the active Background Fetch for |tag|. Will invoke the |callback|
53 void abort(const String& tag); 54 // when the Background Fetch identified by |tag| has been aborted, or could
55 // not be aborted for operational reasons.
56 void abort(const String& tag, std::unique_ptr<AbortCallback>);
54 57
55 // Gets the Background Fetch registration for the given |tag|. Will invoke the 58 // Gets the Background Fetch registration for the given |tag|. Will invoke the
56 // |callback| with the Background Fetch registration, which may be a nullptr 59 // |callback| with the Background Fetch registration, which may be a nullptr
57 // if the |tag| does not exist, when the Mojo call has completed. 60 // if the |tag| does not exist, when the Mojo call has completed.
58 void getRegistration(const String& tag, 61 void getRegistration(const String& tag,
59 std::unique_ptr<GetRegistrationCallback>); 62 std::unique_ptr<GetRegistrationCallback>);
60 63
61 // Gets the sequence of tags for active Background Fetch registrations. Will 64 // Gets the sequence of tags for active Background Fetch registrations. Will
62 // invoke the |callback| with the tags when the Mojo call has completed. 65 // invoke the |callback| with the tags when the Mojo call has completed.
63 void getTags(std::unique_ptr<GetTagsCallback>); 66 void getTags(std::unique_ptr<GetTagsCallback>);
64 67
65 private: 68 private:
66 explicit BackgroundFetchBridge(ServiceWorkerRegistration&); 69 explicit BackgroundFetchBridge(ServiceWorkerRegistration&);
67 70
68 // Returns an initialized BackgroundFetchServicePtr. A connection will be 71 // Returns an initialized BackgroundFetchServicePtr. A connection will be
69 // established after the first call to this method. 72 // established after the first call to this method.
70 mojom::blink::BackgroundFetchServicePtr& getService(); 73 mojom::blink::BackgroundFetchServicePtr& getService();
71 74
72 void didGetRegistration(std::unique_ptr<GetRegistrationCallback>, 75 void didGetRegistration(std::unique_ptr<GetRegistrationCallback>,
73 mojom::blink::BackgroundFetchError, 76 mojom::blink::BackgroundFetchError,
74 mojom::blink::BackgroundFetchRegistrationPtr); 77 mojom::blink::BackgroundFetchRegistrationPtr);
75 78
76 mojom::blink::BackgroundFetchServicePtr m_backgroundFetchService; 79 mojom::blink::BackgroundFetchServicePtr m_backgroundFetchService;
77 }; 80 };
78 81
79 } // namespace blink 82 } // namespace blink
80 83
81 #endif // BackgroundFetchBridge_h 84 #endif // BackgroundFetchBridge_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698