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

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

Issue 2631153002: Do not initiate fetch() on a destroyed FetchManager. (Closed)
Patch Set: Created 3 years, 11 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 | « no previous file | 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/inspector/InspectorInstrumentation.h" 9 #include "core/inspector/InspectorInstrumentation.h"
10 #include "core/workers/WorkerGlobalScope.h" 10 #include "core/workers/WorkerGlobalScope.h"
(...skipping 22 matching lines...) Expand all
33 supplement = new GlobalFetchImpl(executionContext); 33 supplement = new GlobalFetchImpl(executionContext);
34 Supplement<T>::provideTo(supplementable, supplementName(), supplement); 34 Supplement<T>::provideTo(supplementable, supplementName(), supplement);
35 } 35 }
36 return supplement; 36 return supplement;
37 } 37 }
38 38
39 ScriptPromise fetch(ScriptState* scriptState, 39 ScriptPromise fetch(ScriptState* scriptState,
40 const RequestInfo& input, 40 const RequestInfo& input,
41 const Dictionary& init, 41 const Dictionary& init,
42 ExceptionState& exceptionState) override { 42 ExceptionState& exceptionState) override {
43 if (!scriptState->contextIsValid()) { 43 ExecutionContext* executionContext = m_fetchManager->getExecutionContext();
44 if (!scriptState->contextIsValid() || !executionContext) {
44 // TODO(yhirano): Should this be moved to bindings? 45 // TODO(yhirano): Should this be moved to bindings?
45 exceptionState.throwTypeError("The global scope is shutting down."); 46 exceptionState.throwTypeError("The global scope is shutting down.");
46 return ScriptPromise(); 47 return ScriptPromise();
47 } 48 }
48 49
49 // "Let |r| be the associated request of the result of invoking the 50 // "Let |r| be the associated request of the result of invoking the
50 // initial value of Request as constructor with |input| and |init| as 51 // initial value of Request as constructor with |input| and |init| as
51 // arguments. If this throws an exception, reject |p| with it." 52 // arguments. If this throws an exception, reject |p| with it."
52 Request* r = Request::create(scriptState, input, init, exceptionState); 53 Request* r = Request::create(scriptState, input, init, exceptionState);
53 if (exceptionState.hadException()) 54 if (exceptionState.hadException())
54 return ScriptPromise(); 55 return ScriptPromise();
55 56
56 if (ExecutionContext* executionContext = 57 InspectorInstrumentation::willSendXMLHttpOrFetchNetworkRequest(
57 m_fetchManager->getExecutionContext()) 58 executionContext, r->url());
58 InspectorInstrumentation::willSendXMLHttpOrFetchNetworkRequest(
59 executionContext, r->url());
60 return m_fetchManager->fetch(scriptState, r->passRequestData(scriptState)); 59 return m_fetchManager->fetch(scriptState, r->passRequestData(scriptState));
61 } 60 }
62 61
63 DEFINE_INLINE_VIRTUAL_TRACE() { 62 DEFINE_INLINE_VIRTUAL_TRACE() {
64 visitor->trace(m_fetchManager); 63 visitor->trace(m_fetchManager);
65 ScopedFetcher::trace(visitor); 64 ScopedFetcher::trace(visitor);
66 Supplement<T>::trace(visitor); 65 Supplement<T>::trace(visitor);
67 } 66 }
68 67
69 private: 68 private:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 const RequestInfo& input, 107 const RequestInfo& input,
109 const Dictionary& init, 108 const Dictionary& init,
110 ExceptionState& exceptionState) { 109 ExceptionState& exceptionState) {
111 // Note that UseCounter doesn't work with SharedWorker or ServiceWorker. 110 // Note that UseCounter doesn't work with SharedWorker or ServiceWorker.
112 UseCounter::count(worker.getExecutionContext(), UseCounter::Fetch); 111 UseCounter::count(worker.getExecutionContext(), UseCounter::Fetch);
113 return ScopedFetcher::from(worker)->fetch(scriptState, input, init, 112 return ScopedFetcher::from(worker)->fetch(scriptState, input, init,
114 exceptionState); 113 exceptionState);
115 } 114 }
116 115
117 } // namespace blink 116 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698