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