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

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

Issue 2762243002: Convert Background Fetch' input to a WebServiceWorkerRequest vector (Closed)
Patch Set: Convert Background Fetch' input to a WebServiceWorkerRequest vector 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 BackgroundFetchManager_h 5 #ifndef BackgroundFetchManager_h
6 #define BackgroundFetchManager_h 6 #define BackgroundFetchManager_h
7 7
8 #include "bindings/core/v8/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptWrappable.h" 9 #include "bindings/core/v8/ScriptWrappable.h"
10 #include "modules/ModulesExport.h"
10 #include "platform/heap/GarbageCollected.h" 11 #include "platform/heap/GarbageCollected.h"
11 #include "platform/heap/Handle.h" 12 #include "platform/heap/Handle.h"
12 #include "public/platform/modules/background_fetch/background_fetch.mojom-blink. h" 13 #include "public/platform/modules/background_fetch/background_fetch.mojom-blink. h"
13 14
14 namespace blink { 15 namespace blink {
15 16
16 class BackgroundFetchBridge; 17 class BackgroundFetchBridge;
17 class BackgroundFetchOptions; 18 class BackgroundFetchOptions;
18 class BackgroundFetchRegistration; 19 class BackgroundFetchRegistration;
20 class ExceptionState;
19 class RequestOrUSVStringOrRequestOrUSVStringSequence; 21 class RequestOrUSVStringOrRequestOrUSVStringSequence;
20 class ScriptPromiseResolver; 22 class ScriptPromiseResolver;
21 class ScriptState; 23 class ScriptState;
22 class ServiceWorkerRegistration; 24 class ServiceWorkerRegistration;
25 class WebServiceWorkerRequest;
23 26
24 // Implementation of the BackgroundFetchManager JavaScript object, accessible 27 // Implementation of the BackgroundFetchManager JavaScript object, accessible
25 // by developers through ServiceWorkerRegistration.backgroundFetch. 28 // by developers through ServiceWorkerRegistration.backgroundFetch.
26 class BackgroundFetchManager final 29 class MODULES_EXPORT BackgroundFetchManager final
27 : public GarbageCollected<BackgroundFetchManager>, 30 : public GarbageCollected<BackgroundFetchManager>,
28 public ScriptWrappable { 31 public ScriptWrappable {
29 DEFINE_WRAPPERTYPEINFO(); 32 DEFINE_WRAPPERTYPEINFO();
30 33
31 public: 34 public:
32 static BackgroundFetchManager* create( 35 static BackgroundFetchManager* create(
33 ServiceWorkerRegistration* registration) { 36 ServiceWorkerRegistration* registration) {
34 return new BackgroundFetchManager(registration); 37 return new BackgroundFetchManager(registration);
35 } 38 }
36 39
37 // Web Exposed methods defined in the IDL file. 40 // Web Exposed methods defined in the IDL file.
38 ScriptPromise fetch( 41 ScriptPromise fetch(
39 ScriptState*, 42 ScriptState*,
40 const String& tag, 43 const String& tag,
41 const RequestOrUSVStringOrRequestOrUSVStringSequence& requests, 44 const RequestOrUSVStringOrRequestOrUSVStringSequence& requests,
42 const BackgroundFetchOptions&); 45 const BackgroundFetchOptions&,
46 ExceptionState&);
43 ScriptPromise get(ScriptState*, const String& tag); 47 ScriptPromise get(ScriptState*, const String& tag);
44 ScriptPromise getTags(ScriptState*); 48 ScriptPromise getTags(ScriptState*);
45 49
46 DECLARE_TRACE(); 50 DECLARE_TRACE();
47 51
48 private: 52 private:
53 friend class BackgroundFetchManagerTest;
54
49 explicit BackgroundFetchManager(ServiceWorkerRegistration*); 55 explicit BackgroundFetchManager(ServiceWorkerRegistration*);
50 56
57 // Creates a vector of WebServiceWorkerRequest objects for the given set of
58 // |requests|, which can be either Request objects or URL strings.
59 static Vector<WebServiceWorkerRequest> createWebRequestVector(
60 ScriptState*,
61 const RequestOrUSVStringOrRequestOrUSVStringSequence& requests,
62 ExceptionState&);
63
51 void didFetch(ScriptPromiseResolver*, 64 void didFetch(ScriptPromiseResolver*,
52 mojom::blink::BackgroundFetchError, 65 mojom::blink::BackgroundFetchError,
53 BackgroundFetchRegistration*); 66 BackgroundFetchRegistration*);
54 void didGetRegistration(ScriptPromiseResolver*, 67 void didGetRegistration(ScriptPromiseResolver*,
55 mojom::blink::BackgroundFetchError, 68 mojom::blink::BackgroundFetchError,
56 BackgroundFetchRegistration*); 69 BackgroundFetchRegistration*);
57 void didGetTags(ScriptPromiseResolver*, 70 void didGetTags(ScriptPromiseResolver*,
58 mojom::blink::BackgroundFetchError, 71 mojom::blink::BackgroundFetchError,
59 const Vector<String>& tags); 72 const Vector<String>& tags);
60 73
61 Member<ServiceWorkerRegistration> m_registration; 74 Member<ServiceWorkerRegistration> m_registration;
62 Member<BackgroundFetchBridge> m_bridge; 75 Member<BackgroundFetchBridge> m_bridge;
63 }; 76 };
64 77
65 } // namespace blink 78 } // namespace blink
66 79
67 #endif // BackgroundFetchManager_h 80 #endif // BackgroundFetchManager_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698