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

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

Issue 2745243002: Implement a Mojo service for Background Fetch (Closed)
Patch Set: rebase + comments v2 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef BackgroundFetchBridge_h
6 #define BackgroundFetchBridge_h
7
8 #include <memory>
9 #include "modules/serviceworkers/ServiceWorkerRegistration.h"
10 #include "platform/Supplementable.h"
11 #include "platform/heap/Handle.h"
12 #include "public/platform/modules/background_fetch/background_fetch.mojom-blink. h"
13 #include "wtf/Functional.h"
14 #include "wtf/Vector.h"
15 #include "wtf/text/WTFString.h"
16
17 namespace blink {
18
19 class BackgroundFetchRegistration;
20
21 // The bridge is responsible for establishing and maintaining the Mojo
22 // connection to the BackgroundFetchService. It's keyed on an active Service
23 // Worker Registration.
24 class BackgroundFetchBridge final
25 : public GarbageCollectedFinalized<BackgroundFetchBridge>,
26 public Supplement<ServiceWorkerRegistration> {
27 USING_GARBAGE_COLLECTED_MIXIN(BackgroundFetchBridge);
28 WTF_MAKE_NONCOPYABLE(BackgroundFetchBridge);
29
30 public:
31 using UpdateUICallback = Function<void(mojom::blink::BackgroundFetchError)>;
32 using GetRegistrationCallback =
33 Function<void(mojom::blink::BackgroundFetchError,
34 BackgroundFetchRegistration*)>;
35 using GetTagsCallback =
36 Function<void(mojom::blink::BackgroundFetchError, const Vector<String>&)>;
37
38 static BackgroundFetchBridge* from(ServiceWorkerRegistration*);
39 static const char* supplementName();
40
41 virtual ~BackgroundFetchBridge();
42
43 // TODO(peter): Implement support for the `fetch()` function in the bridge.
44
45 // Updates the user interface for the Background Fetch identified by |tag|
46 // with the updated |title|. Will invoke the |callback| when the interface
47 // has been requested to update.
48 void updateUI(const String& tag,
49 const String& title,
50 std::unique_ptr<UpdateUICallback>);
51
52 // Aborts the active Background Fetch for |tag|. Does not respond.
53 void abort(const String& tag);
54
55 // Gets the Background Fetch registration for the given |tag|. Will invoke the
56 // |callback| with the Background Fetch registration, which may be a nullptr
57 // if the |tag| does not exist, when the Mojo call has completed.
58 void getRegistration(const String& tag,
59 std::unique_ptr<GetRegistrationCallback>);
60
61 // Gets the sequence of tags for active Background Fetch registrations. Will
62 // invoke the |callback| with the tags when the Mojo call has completed.
63 void getTags(std::unique_ptr<GetTagsCallback>);
64
65 private:
66 explicit BackgroundFetchBridge(ServiceWorkerRegistration&);
67
68 // Returns an initialized BackgroundFetchServicePtr. A connection will be
69 // established after the first call to this method.
70 mojom::blink::BackgroundFetchServicePtr& getService();
71
72 void didGetRegistration(std::unique_ptr<GetRegistrationCallback>,
73 mojom::blink::BackgroundFetchError,
74 mojom::blink::BackgroundFetchRegistrationPtr);
75
76 mojom::blink::BackgroundFetchServicePtr m_backgroundFetchService;
77 };
78
79 } // namespace blink
80
81 #endif // BackgroundFetchBridge_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698