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/FetchManager.h" | 5 #include "modules/fetch/FetchManager.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
10 #include "bindings/core/v8/V8ThrowException.h" | 10 #include "bindings/core/v8/V8ThrowException.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 void performHTTPFetch(bool corsFlag, bool corsPreflightFlag); | 162 void performHTTPFetch(bool corsFlag, bool corsPreflightFlag); |
163 void performDataFetch(); | 163 void performDataFetch(); |
164 void failed(const String& message); | 164 void failed(const String& message); |
165 void notifyFinished(); | 165 void notifyFinished(); |
166 Document* document() const; | 166 Document* document() const; |
167 void loadSucceeded(); | 167 void loadSucceeded(); |
168 | 168 |
169 Member<FetchManager> m_fetchManager; | 169 Member<FetchManager> m_fetchManager; |
170 Member<ScriptPromiseResolver> m_resolver; | 170 Member<ScriptPromiseResolver> m_resolver; |
171 Member<FetchRequestData> m_request; | 171 Member<FetchRequestData> m_request; |
172 std::unique_ptr<ThreadableLoader> m_loader; | 172 Member<ThreadableLoader> m_loader; |
173 bool m_failed; | 173 bool m_failed; |
174 bool m_finished; | 174 bool m_finished; |
175 int m_responseHttpStatusCode; | 175 int m_responseHttpStatusCode; |
176 Member<SRIVerifier> m_integrityVerifier; | 176 Member<SRIVerifier> m_integrityVerifier; |
177 bool m_didFinishLoading; | 177 bool m_didFinishLoading; |
178 bool m_isIsolatedWorld; | 178 bool m_isIsolatedWorld; |
179 Member<ExecutionContext> m_executionContext; | 179 Member<ExecutionContext> m_executionContext; |
180 }; | 180 }; |
181 | 181 |
182 FetchManager::Loader::Loader(ExecutionContext* executionContext, FetchManager* f
etchManager, ScriptPromiseResolver* resolver, FetchRequestData* request, bool is
IsolatedWorld) | 182 FetchManager::Loader::Loader(ExecutionContext* executionContext, FetchManager* f
etchManager, ScriptPromiseResolver* resolver, FetchRequestData* request, bool is
IsolatedWorld) |
(...skipping 14 matching lines...) Expand all Loading... |
197 FetchManager::Loader::~Loader() | 197 FetchManager::Loader::~Loader() |
198 { | 198 { |
199 ASSERT(!m_loader); | 199 ASSERT(!m_loader); |
200 } | 200 } |
201 | 201 |
202 DEFINE_TRACE(FetchManager::Loader) | 202 DEFINE_TRACE(FetchManager::Loader) |
203 { | 203 { |
204 visitor->trace(m_fetchManager); | 204 visitor->trace(m_fetchManager); |
205 visitor->trace(m_resolver); | 205 visitor->trace(m_resolver); |
206 visitor->trace(m_request); | 206 visitor->trace(m_request); |
| 207 visitor->trace(m_loader); |
207 visitor->trace(m_integrityVerifier); | 208 visitor->trace(m_integrityVerifier); |
208 visitor->trace(m_executionContext); | 209 visitor->trace(m_executionContext); |
209 } | 210 } |
210 | 211 |
211 void FetchManager::Loader::didReceiveResponse(unsigned long, const ResourceRespo
nse& response, std::unique_ptr<WebDataConsumerHandle> handle) | 212 void FetchManager::Loader::didReceiveResponse(unsigned long, const ResourceRespo
nse& response, std::unique_ptr<WebDataConsumerHandle> handle) |
212 { | 213 { |
213 ASSERT(handle); | 214 ASSERT(handle); |
214 ScriptState* scriptState = m_resolver->getScriptState(); | 215 ScriptState* scriptState = m_resolver->getScriptState(); |
215 ScriptState::Scope scope(scriptState); | 216 ScriptState::Scope scope(scriptState); |
216 | 217 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 // |CORS flag| set." | 518 // |CORS flag| set." |
518 performHTTPFetch(true, false); | 519 performHTTPFetch(true, false); |
519 } | 520 } |
520 | 521 |
521 void FetchManager::Loader::dispose() | 522 void FetchManager::Loader::dispose() |
522 { | 523 { |
523 // Prevent notification | 524 // Prevent notification |
524 m_fetchManager = nullptr; | 525 m_fetchManager = nullptr; |
525 if (m_loader) { | 526 if (m_loader) { |
526 m_loader->cancel(); | 527 m_loader->cancel(); |
527 m_loader.reset(); | 528 m_loader = nullptr; |
528 } | 529 } |
529 m_executionContext = nullptr; | 530 m_executionContext = nullptr; |
530 } | 531 } |
531 | 532 |
532 void FetchManager::Loader::performBasicFetch() | 533 void FetchManager::Loader::performBasicFetch() |
533 { | 534 { |
534 // "To perform a basic fetch using |request|, switch on |request|'s url's | 535 // "To perform a basic fetch using |request|, switch on |request|'s url's |
535 // scheme, and run the associated steps:" | 536 // scheme, and run the associated steps:" |
536 if (SchemeRegistry::shouldTreatURLSchemeAsSupportingFetchAPI(m_request->url(
).protocol())) { | 537 if (SchemeRegistry::shouldTreatURLSchemeAsSupportingFetchAPI(m_request->url(
).protocol())) { |
537 // "Return the result of performing an HTTP fetch using |request|." | 538 // "Return the result of performing an HTTP fetch using |request|." |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 loader->dispose(); | 742 loader->dispose(); |
742 } | 743 } |
743 | 744 |
744 DEFINE_TRACE(FetchManager) | 745 DEFINE_TRACE(FetchManager) |
745 { | 746 { |
746 visitor->trace(m_loaders); | 747 visitor->trace(m_loaders); |
747 ContextLifecycleObserver::trace(visitor); | 748 ContextLifecycleObserver::trace(visitor); |
748 } | 749 } |
749 | 750 |
750 } // namespace blink | 751 } // namespace blink |
OLD | NEW |