| 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 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 "platform/heap/GarbageCollected.h" | 10 #include "platform/heap/GarbageCollected.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 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 16 class BackgroundFetchBridge; |
| 15 class BackgroundFetchOptions; | 17 class BackgroundFetchOptions; |
| 18 class BackgroundFetchRegistration; |
| 16 class RequestOrUSVString; | 19 class RequestOrUSVString; |
| 20 class ScriptPromiseResolver; |
| 17 class ScriptState; | 21 class ScriptState; |
| 18 class ServiceWorkerRegistration; | 22 class ServiceWorkerRegistration; |
| 19 | 23 |
| 20 // Implementation of the BackgroundFetchManager JavaScript object, accessible | 24 // Implementation of the BackgroundFetchManager JavaScript object, accessible |
| 21 // by developers through ServiceWorkerRegistration.backgroundFetch. | 25 // by developers through ServiceWorkerRegistration.backgroundFetch. |
| 22 class BackgroundFetchManager final | 26 class BackgroundFetchManager final |
| 23 : public GarbageCollected<BackgroundFetchManager>, | 27 : public GarbageCollected<BackgroundFetchManager>, |
| 24 public ScriptWrappable { | 28 public ScriptWrappable { |
| 25 DEFINE_WRAPPERTYPEINFO(); | 29 DEFINE_WRAPPERTYPEINFO(); |
| 26 | 30 |
| 27 public: | 31 public: |
| 28 static BackgroundFetchManager* create( | 32 static BackgroundFetchManager* create( |
| 29 ServiceWorkerRegistration* registration) { | 33 ServiceWorkerRegistration* registration) { |
| 30 return new BackgroundFetchManager(registration); | 34 return new BackgroundFetchManager(registration); |
| 31 } | 35 } |
| 32 | 36 |
| 33 // Web Exposed methods defined in the IDL file. | 37 // Web Exposed methods defined in the IDL file. |
| 34 ScriptPromise fetch(ScriptState*, | 38 ScriptPromise fetch(ScriptState*, |
| 35 String tag, | 39 const String& tag, |
| 36 HeapVector<RequestOrUSVString> requests, | 40 HeapVector<RequestOrUSVString> requests, |
| 37 const BackgroundFetchOptions&); | 41 const BackgroundFetchOptions&); |
| 38 ScriptPromise get(ScriptState*, String tag); | 42 ScriptPromise get(ScriptState*, const String& tag); |
| 39 ScriptPromise getTags(ScriptState*); | 43 ScriptPromise getTags(ScriptState*); |
| 40 | 44 |
| 41 DECLARE_TRACE(); | 45 DECLARE_TRACE(); |
| 42 | 46 |
| 43 private: | 47 private: |
| 44 explicit BackgroundFetchManager(ServiceWorkerRegistration*); | 48 explicit BackgroundFetchManager(ServiceWorkerRegistration*); |
| 45 | 49 |
| 50 void didGetRegistration(ScriptPromiseResolver*, |
| 51 mojom::blink::BackgroundFetchError, |
| 52 BackgroundFetchRegistration*); |
| 53 void didGetTags(ScriptPromiseResolver*, |
| 54 mojom::blink::BackgroundFetchError, |
| 55 const Vector<String>& tags); |
| 56 |
| 46 Member<ServiceWorkerRegistration> m_registration; | 57 Member<ServiceWorkerRegistration> m_registration; |
| 58 Member<BackgroundFetchBridge> m_bridge; |
| 47 }; | 59 }; |
| 48 | 60 |
| 49 } // namespace blink | 61 } // namespace blink |
| 50 | 62 |
| 51 #endif // BackgroundFetchManager_h | 63 #endif // BackgroundFetchManager_h |
| OLD | NEW |