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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 } | 209 } |
210 if (r == WebDataConsumerHandle::ShouldWait) | 210 if (r == WebDataConsumerHandle::ShouldWait) |
211 return; | 211 return; |
212 String errorMessage = | 212 String errorMessage = |
213 "Unknown error occurred while trying to verify integrity."; | 213 "Unknown error occurred while trying to verify integrity."; |
214 m_finished = true; | 214 m_finished = true; |
215 if (r == WebDataConsumerHandle::Done) { | 215 if (r == WebDataConsumerHandle::Done) { |
216 if (SubresourceIntegrity::CheckSubresourceIntegrity( | 216 if (SubresourceIntegrity::CheckSubresourceIntegrity( |
217 m_integrityMetadata, m_buffer.data(), m_buffer.size(), m_url, | 217 m_integrityMetadata, m_buffer.data(), m_buffer.size(), m_url, |
218 *m_loader->document(), errorMessage)) { | 218 *m_loader->executionContext(), errorMessage)) { |
219 m_updater->update( | 219 m_updater->update( |
220 new FormDataBytesConsumer(m_buffer.data(), m_buffer.size())); | 220 new FormDataBytesConsumer(m_buffer.data(), m_buffer.size())); |
221 m_loader->m_resolver->resolve(m_response); | 221 m_loader->m_resolver->resolve(m_response); |
222 m_loader->m_resolver.clear(); | 222 m_loader->m_resolver.clear(); |
223 // FetchManager::Loader::didFinishLoading() can | 223 // FetchManager::Loader::didFinishLoading() can |
224 // be called before didGetReadable() is called | 224 // be called before didGetReadable() is called |
225 // when the data is ready. In that case, | 225 // when the data is ready. In that case, |
226 // didFinishLoading() doesn't clean up and call | 226 // didFinishLoading() doesn't clean up and call |
227 // notifyFinished(), so it is necessary to | 227 // notifyFinished(), so it is necessary to |
228 // explicitly finish the loader here. | 228 // explicitly finish the loader here. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 FetchRequestData*, | 265 FetchRequestData*, |
266 bool isIsolatedWorld); | 266 bool isIsolatedWorld); |
267 | 267 |
268 void performBasicFetch(); | 268 void performBasicFetch(); |
269 void performNetworkError(const String& message); | 269 void performNetworkError(const String& message); |
270 void performHTTPFetch(bool corsFlag, bool corsPreflightFlag); | 270 void performHTTPFetch(bool corsFlag, bool corsPreflightFlag); |
271 void performDataFetch(); | 271 void performDataFetch(); |
272 void failed(const String& message); | 272 void failed(const String& message); |
273 void notifyFinished(); | 273 void notifyFinished(); |
274 Document* document() const; | 274 Document* document() const; |
| 275 ExecutionContext* executionContext() { return m_executionContext; } |
275 void loadSucceeded(); | 276 void loadSucceeded(); |
276 | 277 |
277 Member<FetchManager> m_fetchManager; | 278 Member<FetchManager> m_fetchManager; |
278 Member<ScriptPromiseResolver> m_resolver; | 279 Member<ScriptPromiseResolver> m_resolver; |
279 Member<FetchRequestData> m_request; | 280 Member<FetchRequestData> m_request; |
280 Member<ThreadableLoader> m_loader; | 281 Member<ThreadableLoader> m_loader; |
281 bool m_failed; | 282 bool m_failed; |
282 bool m_finished; | 283 bool m_finished; |
283 int m_responseHttpStatusCode; | 284 int m_responseHttpStatusCode; |
284 Member<SRIVerifier> m_integrityVerifier; | 285 Member<SRIVerifier> m_integrityVerifier; |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 m_loaders.remove(loader); | 932 m_loaders.remove(loader); |
932 loader->dispose(); | 933 loader->dispose(); |
933 } | 934 } |
934 | 935 |
935 DEFINE_TRACE(FetchManager) { | 936 DEFINE_TRACE(FetchManager) { |
936 visitor->trace(m_loaders); | 937 visitor->trace(m_loaders); |
937 ContextLifecycleObserver::trace(visitor); | 938 ContextLifecycleObserver::trace(visitor); |
938 } | 939 } |
939 | 940 |
940 } // namespace blink | 941 } // namespace blink |
OLD | NEW |