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 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight: | 604 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight: |
605 threadableLoaderOptions.crossOriginRequestPolicy = UseAccessControl; | 605 threadableLoaderOptions.crossOriginRequestPolicy = UseAccessControl; |
606 break; | 606 break; |
607 case WebURLRequest::FetchRequestModeNavigate: | 607 case WebURLRequest::FetchRequestModeNavigate: |
608 // Using DenyCrossOriginRequests here to reduce the security risk. | 608 // Using DenyCrossOriginRequests here to reduce the security risk. |
609 // "navigate" request is only available in ServiceWorker. | 609 // "navigate" request is only available in ServiceWorker. |
610 threadableLoaderOptions.crossOriginRequestPolicy = DenyCrossOriginReques
ts; | 610 threadableLoaderOptions.crossOriginRequestPolicy = DenyCrossOriginReques
ts; |
611 break; | 611 break; |
612 } | 612 } |
613 InspectorInstrumentation::willStartFetch(executionContext(), this); | 613 InspectorInstrumentation::willStartFetch(executionContext(), this); |
614 m_loader = ThreadableLoader::create(*executionContext(), this, request, thre
adableLoaderOptions, resourceLoaderOptions); | 614 m_loader = ThreadableLoader::create(*executionContext(), this, threadableLoa
derOptions, resourceLoaderOptions); |
615 if (!m_loader) | 615 m_loader->start(request); |
616 performNetworkError("Can't create ThreadableLoader"); | |
617 } | 616 } |
618 | 617 |
619 // performDataFetch() is almost the same as performHTTPFetch(), except for: | 618 // performDataFetch() is almost the same as performHTTPFetch(), except for: |
620 // - We set AllowCrossOriginRequests to allow requests to data: URLs in | 619 // - We set AllowCrossOriginRequests to allow requests to data: URLs in |
621 // 'same-origin' mode. | 620 // 'same-origin' mode. |
622 // - We reject non-GET method. | 621 // - We reject non-GET method. |
623 void FetchManager::Loader::performDataFetch() | 622 void FetchManager::Loader::performDataFetch() |
624 { | 623 { |
625 ASSERT(m_request->url().protocolIsData()); | 624 ASSERT(m_request->url().protocolIsData()); |
626 | 625 |
(...skipping 12 matching lines...) Expand all Loading... |
639 | 638 |
640 ResourceLoaderOptions resourceLoaderOptions; | 639 ResourceLoaderOptions resourceLoaderOptions; |
641 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; | 640 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; |
642 resourceLoaderOptions.securityOrigin = m_request->origin().get(); | 641 resourceLoaderOptions.securityOrigin = m_request->origin().get(); |
643 | 642 |
644 ThreadableLoaderOptions threadableLoaderOptions; | 643 ThreadableLoaderOptions threadableLoaderOptions; |
645 threadableLoaderOptions.contentSecurityPolicyEnforcement = ContentSecurityPo
licy::shouldBypassMainWorld(executionContext()) ? DoNotEnforceContentSecurityPol
icy : EnforceConnectSrcDirective; | 644 threadableLoaderOptions.contentSecurityPolicyEnforcement = ContentSecurityPo
licy::shouldBypassMainWorld(executionContext()) ? DoNotEnforceContentSecurityPol
icy : EnforceConnectSrcDirective; |
646 threadableLoaderOptions.crossOriginRequestPolicy = AllowCrossOriginRequests; | 645 threadableLoaderOptions.crossOriginRequestPolicy = AllowCrossOriginRequests; |
647 | 646 |
648 InspectorInstrumentation::willStartFetch(executionContext(), this); | 647 InspectorInstrumentation::willStartFetch(executionContext(), this); |
649 m_loader = ThreadableLoader::create(*executionContext(), this, request, thre
adableLoaderOptions, resourceLoaderOptions); | 648 m_loader = ThreadableLoader::create(*executionContext(), this, threadableLoa
derOptions, resourceLoaderOptions); |
650 if (!m_loader) | 649 m_loader->start(request); |
651 performNetworkError("Can't create ThreadableLoader"); | |
652 } | 650 } |
653 | 651 |
654 void FetchManager::Loader::failed(const String& message) | 652 void FetchManager::Loader::failed(const String& message) |
655 { | 653 { |
656 if (m_failed || m_finished) | 654 if (m_failed || m_finished) |
657 return; | 655 return; |
658 m_failed = true; | 656 m_failed = true; |
659 if (!message.isEmpty()) | 657 if (!message.isEmpty()) |
660 executionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSo
urce, ErrorMessageLevel, message)); | 658 executionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSo
urce, ErrorMessageLevel, message)); |
661 if (m_resolver) { | 659 if (m_resolver) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 loader->dispose(); | 714 loader->dispose(); |
717 } | 715 } |
718 | 716 |
719 DEFINE_TRACE(FetchManager) | 717 DEFINE_TRACE(FetchManager) |
720 { | 718 { |
721 visitor->trace(m_executionContext); | 719 visitor->trace(m_executionContext); |
722 visitor->trace(m_loaders); | 720 visitor->trace(m_loaders); |
723 } | 721 } |
724 | 722 |
725 } // namespace blink | 723 } // namespace blink |
OLD | NEW |