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 Member<ThreadableLoader> m_loader; | 172 std::unique_ptr<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); | |
208 visitor->trace(m_integrityVerifier); | 207 visitor->trace(m_integrityVerifier); |
209 visitor->trace(m_executionContext); | 208 visitor->trace(m_executionContext); |
210 } | 209 } |
211 | 210 |
212 void FetchManager::Loader::didReceiveResponse(unsigned long, const ResourceRespo
nse& response, std::unique_ptr<WebDataConsumerHandle> handle) | 211 void FetchManager::Loader::didReceiveResponse(unsigned long, const ResourceRespo
nse& response, std::unique_ptr<WebDataConsumerHandle> handle) |
213 { | 212 { |
214 ASSERT(handle); | 213 ASSERT(handle); |
215 ScriptState* scriptState = m_resolver->getScriptState(); | 214 ScriptState* scriptState = m_resolver->getScriptState(); |
216 ScriptState::Scope scope(scriptState); | 215 ScriptState::Scope scope(scriptState); |
217 | 216 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 // |CORS flag| set." | 517 // |CORS flag| set." |
519 performHTTPFetch(true, false); | 518 performHTTPFetch(true, false); |
520 } | 519 } |
521 | 520 |
522 void FetchManager::Loader::dispose() | 521 void FetchManager::Loader::dispose() |
523 { | 522 { |
524 // Prevent notification | 523 // Prevent notification |
525 m_fetchManager = nullptr; | 524 m_fetchManager = nullptr; |
526 if (m_loader) { | 525 if (m_loader) { |
527 m_loader->cancel(); | 526 m_loader->cancel(); |
528 m_loader = nullptr; | 527 m_loader.reset(); |
529 } | 528 } |
530 m_executionContext = nullptr; | 529 m_executionContext = nullptr; |
531 } | 530 } |
532 | 531 |
533 void FetchManager::Loader::performBasicFetch() | 532 void FetchManager::Loader::performBasicFetch() |
534 { | 533 { |
535 // "To perform a basic fetch using |request|, switch on |request|'s url's | 534 // "To perform a basic fetch using |request|, switch on |request|'s url's |
536 // scheme, and run the associated steps:" | 535 // scheme, and run the associated steps:" |
537 if (SchemeRegistry::shouldTreatURLSchemeAsSupportingFetchAPI(m_request->url(
).protocol())) { | 536 if (SchemeRegistry::shouldTreatURLSchemeAsSupportingFetchAPI(m_request->url(
).protocol())) { |
538 // "Return the result of performing an HTTP fetch using |request|." | 537 // "Return the result of performing an HTTP fetch using |request|." |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 loader->dispose(); | 741 loader->dispose(); |
743 } | 742 } |
744 | 743 |
745 DEFINE_TRACE(FetchManager) | 744 DEFINE_TRACE(FetchManager) |
746 { | 745 { |
747 visitor->trace(m_loaders); | 746 visitor->trace(m_loaders); |
748 ContextLifecycleObserver::trace(visitor); | 747 ContextLifecycleObserver::trace(visitor); |
749 } | 748 } |
750 | 749 |
751 } // namespace blink | 750 } // namespace blink |
OLD | NEW |