Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: third_party/WebKit/Source/modules/fetch/FetchManager.cpp

Issue 1264453002: Split the constructor of ThreadableLoader into two methods (ctor and start()) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight: 602 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight:
603 threadableLoaderOptions.crossOriginRequestPolicy = UseAccessControl; 603 threadableLoaderOptions.crossOriginRequestPolicy = UseAccessControl;
604 break; 604 break;
605 case WebURLRequest::FetchRequestModeNavigate: 605 case WebURLRequest::FetchRequestModeNavigate:
606 // Using DenyCrossOriginRequests here to reduce the security risk. 606 // Using DenyCrossOriginRequests here to reduce the security risk.
607 // "navigate" request is only available in ServiceWorker. 607 // "navigate" request is only available in ServiceWorker.
608 threadableLoaderOptions.crossOriginRequestPolicy = DenyCrossOriginReques ts; 608 threadableLoaderOptions.crossOriginRequestPolicy = DenyCrossOriginReques ts;
609 break; 609 break;
610 } 610 }
611 InspectorInstrumentation::willStartFetch(executionContext(), this); 611 InspectorInstrumentation::willStartFetch(executionContext(), this);
612 m_loader = ThreadableLoader::create(*executionContext(), this, request, thre adableLoaderOptions, resourceLoaderOptions); 612 m_loader = ThreadableLoader::create(*executionContext(), this, threadableLoa derOptions, resourceLoaderOptions);
613 if (!m_loader) 613 m_loader->start(request);
614 performNetworkError("Can't create ThreadableLoader");
615 } 614 }
616 615
617 // performDataFetch() is almost the same as performHTTPFetch(), except for: 616 // performDataFetch() is almost the same as performHTTPFetch(), except for:
618 // - We set AllowCrossOriginRequests to allow requests to data: URLs in 617 // - We set AllowCrossOriginRequests to allow requests to data: URLs in
619 // 'same-origin' mode. 618 // 'same-origin' mode.
620 // - We reject non-GET method. 619 // - We reject non-GET method.
621 void FetchManager::Loader::performDataFetch() 620 void FetchManager::Loader::performDataFetch()
622 { 621 {
623 ASSERT(m_request->url().protocolIsData()); 622 ASSERT(m_request->url().protocolIsData());
624 623
(...skipping 12 matching lines...) Expand all
637 636
638 ResourceLoaderOptions resourceLoaderOptions; 637 ResourceLoaderOptions resourceLoaderOptions;
639 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; 638 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData;
640 resourceLoaderOptions.securityOrigin = m_request->origin().get(); 639 resourceLoaderOptions.securityOrigin = m_request->origin().get();
641 640
642 ThreadableLoaderOptions threadableLoaderOptions; 641 ThreadableLoaderOptions threadableLoaderOptions;
643 threadableLoaderOptions.contentSecurityPolicyEnforcement = ContentSecurityPo licy::shouldBypassMainWorld(executionContext()) ? DoNotEnforceContentSecurityPol icy : EnforceConnectSrcDirective; 642 threadableLoaderOptions.contentSecurityPolicyEnforcement = ContentSecurityPo licy::shouldBypassMainWorld(executionContext()) ? DoNotEnforceContentSecurityPol icy : EnforceConnectSrcDirective;
644 threadableLoaderOptions.crossOriginRequestPolicy = AllowCrossOriginRequests; 643 threadableLoaderOptions.crossOriginRequestPolicy = AllowCrossOriginRequests;
645 644
646 InspectorInstrumentation::willStartFetch(executionContext(), this); 645 InspectorInstrumentation::willStartFetch(executionContext(), this);
647 m_loader = ThreadableLoader::create(*executionContext(), this, request, thre adableLoaderOptions, resourceLoaderOptions); 646 m_loader = ThreadableLoader::create(*executionContext(), this, threadableLoa derOptions, resourceLoaderOptions);
648 if (!m_loader) 647 m_loader->start(request);
649 performNetworkError("Can't create ThreadableLoader");
650 } 648 }
651 649
652 void FetchManager::Loader::failed(const String& message) 650 void FetchManager::Loader::failed(const String& message)
653 { 651 {
654 if (m_failed || m_finished) 652 if (m_failed || m_finished)
655 return; 653 return;
656 m_failed = true; 654 m_failed = true;
657 if (!message.isEmpty()) 655 if (!message.isEmpty())
658 executionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSo urce, ErrorMessageLevel, message)); 656 executionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSo urce, ErrorMessageLevel, message));
659 if (m_resolver) { 657 if (m_resolver) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 loader->dispose(); 712 loader->dispose();
715 } 713 }
716 714
717 DEFINE_TRACE(FetchManager) 715 DEFINE_TRACE(FetchManager)
718 { 716 {
719 visitor->trace(m_executionContext); 717 visitor->trace(m_executionContext);
720 visitor->trace(m_loaders); 718 visitor->trace(m_loaders);
721 } 719 }
722 720
723 } // namespace blink 721 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698