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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 void FetchManager::Loader::performNetworkError(const String& message) { | 694 void FetchManager::Loader::performNetworkError(const String& message) { |
695 failed(message); | 695 failed(message); |
696 } | 696 } |
697 | 697 |
698 void FetchManager::Loader::performHTTPFetch(bool corsFlag, | 698 void FetchManager::Loader::performHTTPFetch(bool corsFlag, |
699 bool corsPreflightFlag) { | 699 bool corsPreflightFlag) { |
700 ASSERT( | 700 ASSERT( |
701 SchemeRegistry::shouldTreatURLSchemeAsSupportingFetchAPI( | 701 SchemeRegistry::shouldTreatURLSchemeAsSupportingFetchAPI( |
702 m_request->url().protocol()) || | 702 m_request->url().protocol()) || |
703 (m_request->url().protocolIs("blob") && !corsFlag && !corsPreflightFlag)); | 703 (m_request->url().protocolIs("blob") && !corsFlag && !corsPreflightFlag)); |
704 // CORS preflight fetch procedure is implemented inside DocumentThreadableLoad
er. | 704 // CORS preflight fetch procedure is implemented inside |
| 705 // DocumentThreadableLoader. |
705 | 706 |
706 // "1. Let |HTTPRequest| be a copy of |request|, except that |HTTPRequest|'s | 707 // "1. Let |HTTPRequest| be a copy of |request|, except that |HTTPRequest|'s |
707 // body is a tee of |request|'s body." | 708 // body is a tee of |request|'s body." |
708 // We use ResourceRequest class for HTTPRequest. | 709 // We use ResourceRequest class for HTTPRequest. |
709 // FIXME: Support body. | 710 // FIXME: Support body. |
710 ResourceRequest request(m_request->url()); | 711 ResourceRequest request(m_request->url()); |
711 request.setRequestContext(m_request->context()); | 712 request.setRequestContext(m_request->context()); |
712 request.setHTTPMethod(m_request->method()); | 713 request.setHTTPMethod(m_request->method()); |
713 request.setFetchRequestMode(m_request->mode()); | 714 request.setFetchRequestMode(m_request->mode()); |
714 request.setFetchCredentialsMode(m_request->credentials()); | 715 request.setFetchCredentialsMode(m_request->credentials()); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 performNetworkError( | 828 performNetworkError( |
828 "Only 'GET' method is allowed for data URLs in Fetch API."); | 829 "Only 'GET' method is allowed for data URLs in Fetch API."); |
829 return; | 830 return; |
830 } | 831 } |
831 | 832 |
832 ResourceRequest request(m_request->url()); | 833 ResourceRequest request(m_request->url()); |
833 request.setRequestContext(m_request->context()); | 834 request.setRequestContext(m_request->context()); |
834 request.setUseStreamOnResponse(true); | 835 request.setUseStreamOnResponse(true); |
835 request.setHTTPMethod(m_request->method()); | 836 request.setHTTPMethod(m_request->method()); |
836 request.setFetchRedirectMode(WebURLRequest::FetchRedirectModeError); | 837 request.setFetchRedirectMode(WebURLRequest::FetchRedirectModeError); |
837 // We intentionally skip 'setExternalRequestStateFromRequestorAddressSpace', a
s 'data:' can never be external. | 838 // We intentionally skip 'setExternalRequestStateFromRequestorAddressSpace', |
| 839 // as 'data:' can never be external. |
838 | 840 |
839 ResourceLoaderOptions resourceLoaderOptions; | 841 ResourceLoaderOptions resourceLoaderOptions; |
840 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; | 842 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; |
841 resourceLoaderOptions.securityOrigin = m_request->origin().get(); | 843 resourceLoaderOptions.securityOrigin = m_request->origin().get(); |
842 | 844 |
843 ThreadableLoaderOptions threadableLoaderOptions; | 845 ThreadableLoaderOptions threadableLoaderOptions; |
844 threadableLoaderOptions.contentSecurityPolicyEnforcement = | 846 threadableLoaderOptions.contentSecurityPolicyEnforcement = |
845 ContentSecurityPolicy::shouldBypassMainWorld(m_executionContext) | 847 ContentSecurityPolicy::shouldBypassMainWorld(m_executionContext) |
846 ? DoNotEnforceContentSecurityPolicy | 848 ? DoNotEnforceContentSecurityPolicy |
847 : EnforceContentSecurityPolicy; | 849 : EnforceContentSecurityPolicy; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 m_loaders.remove(loader); | 913 m_loaders.remove(loader); |
912 loader->dispose(); | 914 loader->dispose(); |
913 } | 915 } |
914 | 916 |
915 DEFINE_TRACE(FetchManager) { | 917 DEFINE_TRACE(FetchManager) { |
916 visitor->trace(m_loaders); | 918 visitor->trace(m_loaders); |
917 ContextLifecycleObserver::trace(visitor); | 919 ContextLifecycleObserver::trace(visitor); |
918 } | 920 } |
919 | 921 |
920 } // namespace blink | 922 } // namespace blink |
OLD | NEW |