OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/fetch/GlobalFetch.h" | 5 #include "modules/fetch/GlobalFetch.h" |
6 | 6 |
7 #include "core/frame/LocalDOMWindow.h" | 7 #include "core/frame/LocalDOMWindow.h" |
8 #include "core/frame/UseCounter.h" | 8 #include "core/frame/UseCounter.h" |
9 #include "core/workers/WorkerGlobalScope.h" | 9 #include "core/workers/WorkerGlobalScope.h" |
10 #include "modules/fetch/FetchManager.h" | 10 #include "modules/fetch/FetchManager.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 GlobalFetchImpl* supplement = static_cast<GlobalFetchImpl*>(Supplement<T
>::from(supplementable, supplementName())); | 26 GlobalFetchImpl* supplement = static_cast<GlobalFetchImpl*>(Supplement<T
>::from(supplementable, supplementName())); |
27 if (!supplement) { | 27 if (!supplement) { |
28 supplement = new GlobalFetchImpl(executionContext); | 28 supplement = new GlobalFetchImpl(executionContext); |
29 Supplement<T>::provideTo(supplementable, supplementName(), supplemen
t); | 29 Supplement<T>::provideTo(supplementable, supplementName(), supplemen
t); |
30 } | 30 } |
31 return supplement; | 31 return supplement; |
32 } | 32 } |
33 | 33 |
34 ScriptPromise fetch(ScriptState* scriptState, const RequestInfo& input, cons
t Dictionary& init, ExceptionState& exceptionState) override | 34 ScriptPromise fetch(ScriptState* scriptState, const RequestInfo& input, cons
t Dictionary& init, ExceptionState& exceptionState) override |
35 { | 35 { |
| 36 if (!scriptState->contextIsValid()) { |
| 37 // TODO(yhirano): Should this be moved to bindings? |
| 38 exceptionState.throwTypeError("The global scope is shutting down."); |
| 39 return ScriptPromise(); |
| 40 } |
36 if (m_fetchManager->isStopped()) { | 41 if (m_fetchManager->isStopped()) { |
37 exceptionState.throwTypeError("The global scope is shutting down."); | 42 exceptionState.throwTypeError("The global scope is shutting down."); |
38 return ScriptPromise(); | 43 return ScriptPromise(); |
39 } | 44 } |
40 | 45 |
41 // "Let |r| be the associated request of the result of invoking the | 46 // "Let |r| be the associated request of the result of invoking the |
42 // initial value of Request as constructor with |input| and |init| as | 47 // initial value of Request as constructor with |input| and |init| as |
43 // arguments. If this throws an exception, reject |p| with it." | 48 // arguments. If this throws an exception, reject |p| with it." |
44 Request* r = Request::create(scriptState, input, init, exceptionState); | 49 Request* r = Request::create(scriptState, input, init, exceptionState); |
45 if (exceptionState.hadException()) | 50 if (exceptionState.hadException()) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } | 97 } |
93 | 98 |
94 ScriptPromise GlobalFetch::fetch(ScriptState* scriptState, WorkerGlobalScope& wo
rker, const RequestInfo& input, const Dictionary& init, ExceptionState& exceptio
nState) | 99 ScriptPromise GlobalFetch::fetch(ScriptState* scriptState, WorkerGlobalScope& wo
rker, const RequestInfo& input, const Dictionary& init, ExceptionState& exceptio
nState) |
95 { | 100 { |
96 // Note that UseCounter doesn't work with SharedWorker or ServiceWorker. | 101 // Note that UseCounter doesn't work with SharedWorker or ServiceWorker. |
97 UseCounter::count(worker.getExecutionContext(), UseCounter::Fetch); | 102 UseCounter::count(worker.getExecutionContext(), UseCounter::Fetch); |
98 return ScopedFetcher::from(worker)->fetch(scriptState, input, init, exceptio
nState); | 103 return ScopedFetcher::from(worker)->fetch(scriptState, input, init, exceptio
nState); |
99 } | 104 } |
100 | 105 |
101 } // namespace blink | 106 } // namespace blink |
OLD | NEW |