| 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 #include "modules/background_fetch/BackgroundFetchManager.h" | 5 #include "modules/background_fetch/BackgroundFetchManager.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "bindings/core/v8/V8ThrowException.h" | 9 #include "bindings/core/v8/V8ThrowException.h" |
| 10 #include "modules/background_fetch/BackgroundFetchOptions.h" | 10 #include "modules/background_fetch/BackgroundFetchOptions.h" |
| 11 #include "modules/background_fetch/BackgroundFetchRegistration.h" | 11 #include "modules/background_fetch/BackgroundFetchRegistration.h" |
| 12 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 12 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 BackgroundFetchManager::BackgroundFetchManager( | 16 BackgroundFetchManager::BackgroundFetchManager( |
| 17 ServiceWorkerRegistration* registration) | 17 ServiceWorkerRegistration* registration) |
| 18 : m_registration(registration) { | 18 : m_registration(registration) { |
| 19 DCHECK(registration); | 19 DCHECK(registration); |
| 20 } | 20 } |
| 21 | 21 |
| 22 ScriptPromise BackgroundFetchManager::fetch( | 22 ScriptPromise BackgroundFetchManager::fetch( |
| 23 ScriptState* scriptState, | 23 ScriptState* scriptState, |
| 24 String tag, | 24 String tag, |
| 25 HeapVector<RequestOrUSVString> requests, | 25 const RequestOrUSVStringOrRequestOrUSVStringSequence& requests, |
| 26 const BackgroundFetchOptions& options) { | 26 const BackgroundFetchOptions& options) { |
| 27 if (!m_registration->active()) { | 27 if (!m_registration->active()) { |
| 28 return ScriptPromise::reject( | 28 return ScriptPromise::reject( |
| 29 scriptState, | 29 scriptState, |
| 30 V8ThrowException::createTypeError(scriptState->isolate(), | 30 V8ThrowException::createTypeError(scriptState->isolate(), |
| 31 "No active registration available on " | 31 "No active registration available on " |
| 32 "the ServiceWorkerRegistration.")); | 32 "the ServiceWorkerRegistration.")); |
| 33 } | 33 } |
| 34 | 34 |
| 35 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 35 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 resolver->resolve(Vector<String>()); | 83 resolver->resolve(Vector<String>()); |
| 84 | 84 |
| 85 return promise; | 85 return promise; |
| 86 } | 86 } |
| 87 | 87 |
| 88 DEFINE_TRACE(BackgroundFetchManager) { | 88 DEFINE_TRACE(BackgroundFetchManager) { |
| 89 visitor->trace(m_registration); | 89 visitor->trace(m_registration); |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace blink | 92 } // namespace blink |
| OLD | NEW |