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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/GlobalFetch.cpp

Issue 1924193002: [Fetch API] Abort fetching when the passed ScriptState is invalid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698