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

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

Issue 2727633006: DevTools: Rename InspectorInstrumentation:: namespace into probe:: (Closed)
Patch Set: Created 3 years, 9 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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 void FetchManager::Loader::loadSucceeded() { 554 void FetchManager::Loader::loadSucceeded() {
555 ASSERT(!m_failed); 555 ASSERT(!m_failed);
556 556
557 m_finished = true; 557 m_finished = true;
558 558
559 if (document() && document()->frame() && document()->frame()->page() && 559 if (document() && document()->frame() && document()->frame()->page() &&
560 FetchUtils::isOkStatus(m_responseHttpStatusCode)) { 560 FetchUtils::isOkStatus(m_responseHttpStatusCode)) {
561 document()->frame()->page()->chromeClient().ajaxSucceeded( 561 document()->frame()->page()->chromeClient().ajaxSucceeded(
562 document()->frame()); 562 document()->frame());
563 } 563 }
564 InspectorInstrumentation::didFinishFetch(m_executionContext, this, 564 probe::didFinishFetch(m_executionContext, this, m_request->method(),
565 m_request->method(), 565 m_request->url().getString());
566 m_request->url().getString());
567 notifyFinished(); 566 notifyFinished();
568 } 567 }
569 568
570 void FetchManager::Loader::start() { 569 void FetchManager::Loader::start() {
571 // "1. If |request|'s url contains a Known HSTS Host, modify it per the 570 // "1. If |request|'s url contains a Known HSTS Host, modify it per the
572 // requirements of the 'URI [sic] Loading and Port Mapping' chapter of HTTP 571 // requirements of the 'URI [sic] Loading and Port Mapping' chapter of HTTP
573 // Strict Transport Security." 572 // Strict Transport Security."
574 // FIXME: Implement this. 573 // FIXME: Implement this.
575 574
576 // "2. If |request|'s referrer is not none, set |request|'s referrer to the 575 // "2. If |request|'s referrer is not none, set |request|'s referrer to the
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 668
670 // "- Otherwise 669 // "- Otherwise
671 // Set |request|'s response tainting to |CORS|." 670 // Set |request|'s response tainting to |CORS|."
672 m_request->setResponseTainting(FetchRequestData::CORSTainting); 671 m_request->setResponseTainting(FetchRequestData::CORSTainting);
673 // "The result of performing an HTTP fetch using |request| with the 672 // "The result of performing an HTTP fetch using |request| with the
674 // |CORS flag| set." 673 // |CORS flag| set."
675 performHTTPFetch(true, false); 674 performHTTPFetch(true, false);
676 } 675 }
677 676
678 void FetchManager::Loader::dispose() { 677 void FetchManager::Loader::dispose() {
679 InspectorInstrumentation::detachClientRequest(m_executionContext, this); 678 probe::detachClientRequest(m_executionContext, this);
680 // Prevent notification 679 // Prevent notification
681 m_fetchManager = nullptr; 680 m_fetchManager = nullptr;
682 if (m_loader) { 681 if (m_loader) {
683 m_loader->cancel(); 682 m_loader->cancel();
684 m_loader = nullptr; 683 m_loader = nullptr;
685 } 684 }
686 m_executionContext = nullptr; 685 m_executionContext = nullptr;
687 } 686 }
688 687
689 void FetchManager::Loader::performBasicFetch() { 688 void FetchManager::Loader::performBasicFetch() {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight: 830 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight:
832 threadableLoaderOptions.crossOriginRequestPolicy = UseAccessControl; 831 threadableLoaderOptions.crossOriginRequestPolicy = UseAccessControl;
833 break; 832 break;
834 case WebURLRequest::FetchRequestModeNavigate: 833 case WebURLRequest::FetchRequestModeNavigate:
835 // Using DenyCrossOriginRequests here to reduce the security risk. 834 // Using DenyCrossOriginRequests here to reduce the security risk.
836 // "navigate" request is only available in ServiceWorker. 835 // "navigate" request is only available in ServiceWorker.
837 threadableLoaderOptions.crossOriginRequestPolicy = 836 threadableLoaderOptions.crossOriginRequestPolicy =
838 DenyCrossOriginRequests; 837 DenyCrossOriginRequests;
839 break; 838 break;
840 } 839 }
841 InspectorInstrumentation::willStartFetch(m_executionContext, this); 840 probe::willStartFetch(m_executionContext, this);
842 m_loader = 841 m_loader =
843 ThreadableLoader::create(*m_executionContext, this, 842 ThreadableLoader::create(*m_executionContext, this,
844 threadableLoaderOptions, resourceLoaderOptions); 843 threadableLoaderOptions, resourceLoaderOptions);
845 m_loader->start(request); 844 m_loader->start(request);
846 } 845 }
847 846
848 // performDataFetch() is almost the same as performHTTPFetch(), except for: 847 // performDataFetch() is almost the same as performHTTPFetch(), except for:
849 // - We set AllowCrossOriginRequests to allow requests to data: URLs in 848 // - We set AllowCrossOriginRequests to allow requests to data: URLs in
850 // 'same-origin' mode. 849 // 'same-origin' mode.
851 // - We reject non-GET method. 850 // - We reject non-GET method.
(...skipping 12 matching lines...) Expand all
864 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; 863 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData;
865 resourceLoaderOptions.securityOrigin = m_request->origin().get(); 864 resourceLoaderOptions.securityOrigin = m_request->origin().get();
866 865
867 ThreadableLoaderOptions threadableLoaderOptions; 866 ThreadableLoaderOptions threadableLoaderOptions;
868 threadableLoaderOptions.contentSecurityPolicyEnforcement = 867 threadableLoaderOptions.contentSecurityPolicyEnforcement =
869 ContentSecurityPolicy::shouldBypassMainWorld(m_executionContext) 868 ContentSecurityPolicy::shouldBypassMainWorld(m_executionContext)
870 ? DoNotEnforceContentSecurityPolicy 869 ? DoNotEnforceContentSecurityPolicy
871 : EnforceContentSecurityPolicy; 870 : EnforceContentSecurityPolicy;
872 threadableLoaderOptions.crossOriginRequestPolicy = AllowCrossOriginRequests; 871 threadableLoaderOptions.crossOriginRequestPolicy = AllowCrossOriginRequests;
873 872
874 InspectorInstrumentation::willStartFetch(m_executionContext, this); 873 probe::willStartFetch(m_executionContext, this);
875 m_loader = 874 m_loader =
876 ThreadableLoader::create(*m_executionContext, this, 875 ThreadableLoader::create(*m_executionContext, this,
877 threadableLoaderOptions, resourceLoaderOptions); 876 threadableLoaderOptions, resourceLoaderOptions);
878 m_loader->start(request); 877 m_loader->start(request);
879 } 878 }
880 879
881 void FetchManager::Loader::failed(const String& message) { 880 void FetchManager::Loader::failed(const String& message) {
882 if (m_failed || m_finished) 881 if (m_failed || m_finished)
883 return; 882 return;
884 m_failed = true; 883 m_failed = true;
885 if (m_executionContext->isContextDestroyed()) 884 if (m_executionContext->isContextDestroyed())
886 return; 885 return;
887 if (!message.isEmpty()) 886 if (!message.isEmpty())
888 m_executionContext->addConsoleMessage( 887 m_executionContext->addConsoleMessage(
889 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); 888 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message));
890 if (m_resolver) { 889 if (m_resolver) {
891 ScriptState* state = m_resolver->getScriptState(); 890 ScriptState* state = m_resolver->getScriptState();
892 ScriptState::Scope scope(state); 891 ScriptState::Scope scope(state);
893 m_resolver->reject( 892 m_resolver->reject(
894 V8ThrowException::createTypeError(state->isolate(), "Failed to fetch")); 893 V8ThrowException::createTypeError(state->isolate(), "Failed to fetch"));
895 } 894 }
896 InspectorInstrumentation::didFailFetch(m_executionContext, this); 895 probe::didFailFetch(m_executionContext, this);
897 notifyFinished(); 896 notifyFinished();
898 } 897 }
899 898
900 void FetchManager::Loader::notifyFinished() { 899 void FetchManager::Loader::notifyFinished() {
901 if (m_fetchManager) 900 if (m_fetchManager)
902 m_fetchManager->onLoaderFinished(this); 901 m_fetchManager->onLoaderFinished(this);
903 } 902 }
904 903
905 FetchManager* FetchManager::create(ExecutionContext* executionContext) { 904 FetchManager* FetchManager::create(ExecutionContext* executionContext) {
906 return new FetchManager(executionContext); 905 return new FetchManager(executionContext);
(...skipping 26 matching lines...) Expand all
933 m_loaders.erase(loader); 932 m_loaders.erase(loader);
934 loader->dispose(); 933 loader->dispose();
935 } 934 }
936 935
937 DEFINE_TRACE(FetchManager) { 936 DEFINE_TRACE(FetchManager) {
938 visitor->trace(m_loaders); 937 visitor->trace(m_loaders);
939 ContextLifecycleObserver::trace(visitor); 938 ContextLifecycleObserver::trace(visitor);
940 } 939 }
941 940
942 } // namespace blink 941 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/eventsource/EventSource.cpp ('k') | third_party/WebKit/Source/modules/fetch/GlobalFetch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698