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

Side by Side Diff: third_party/WebKit/Source/core/loader/DocumentThreadableLoader.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 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013, Intel Corporation 3 * Copyright (C) 2013, Intel Corporation
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // Setting an outgoing referer is only supported in the async code path. 187 // Setting an outgoing referer is only supported in the async code path.
188 DCHECK(m_async || request.httpReferrer().isEmpty()); 188 DCHECK(m_async || request.httpReferrer().isEmpty());
189 189
190 m_sameOriginRequest = 190 m_sameOriginRequest =
191 getSecurityOrigin()->canRequestNoSuborigin(request.url()); 191 getSecurityOrigin()->canRequestNoSuborigin(request.url());
192 m_requestContext = request.requestContext(); 192 m_requestContext = request.requestContext();
193 m_redirectMode = request.fetchRedirectMode(); 193 m_redirectMode = request.fetchRedirectMode();
194 194
195 if (!m_sameOriginRequest && 195 if (!m_sameOriginRequest &&
196 m_options.crossOriginRequestPolicy == DenyCrossOriginRequests) { 196 m_options.crossOriginRequestPolicy == DenyCrossOriginRequests) {
197 InspectorInstrumentation:: 197 probe::documentThreadableLoaderFailedToStartLoadingForClient(document(),
198 documentThreadableLoaderFailedToStartLoadingForClient(document(), 198 m_client);
199 m_client);
200 ThreadableLoaderClient* client = m_client; 199 ThreadableLoaderClient* client = m_client;
201 clear(); 200 clear();
202 client->didFail(ResourceError(errorDomainBlinkInternal, 0, 201 client->didFail(ResourceError(errorDomainBlinkInternal, 0,
203 request.url().getString(), 202 request.url().getString(),
204 "Cross origin requests are not supported.")); 203 "Cross origin requests are not supported."));
205 return; 204 return;
206 } 205 }
207 206
208 m_requestStartedSeconds = monotonicallyIncreasingTime(); 207 m_requestStartedSeconds = monotonicallyIncreasingTime();
209 208
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 DCHECK(m_options.crossOriginRequestPolicy == UseAccessControl || 320 DCHECK(m_options.crossOriginRequestPolicy == UseAccessControl ||
322 request.isExternalRequest()); 321 request.isExternalRequest());
323 DCHECK(m_client); 322 DCHECK(m_client);
324 DCHECK(!resource()); 323 DCHECK(!resource());
325 324
326 // Cross-origin requests are only allowed certain registered schemes. We would 325 // Cross-origin requests are only allowed certain registered schemes. We would
327 // catch this when checking response headers later, but there is no reason to 326 // catch this when checking response headers later, but there is no reason to
328 // send a request, preflighted or not, that's guaranteed to be denied. 327 // send a request, preflighted or not, that's guaranteed to be denied.
329 if (!SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled( 328 if (!SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(
330 request.url().protocol())) { 329 request.url().protocol())) {
331 InspectorInstrumentation:: 330 probe::documentThreadableLoaderFailedToStartLoadingForClient(document(),
332 documentThreadableLoaderFailedToStartLoadingForClient(document(), 331 m_client);
333 m_client);
334 dispatchDidFailAccessControlCheck(ResourceError( 332 dispatchDidFailAccessControlCheck(ResourceError(
335 errorDomainBlinkInternal, 0, request.url().getString(), 333 errorDomainBlinkInternal, 0, request.url().getString(),
336 "Cross origin requests are only supported for protocol schemes: " + 334 "Cross origin requests are only supported for protocol schemes: " +
337 SchemeRegistry::listOfCORSEnabledURLSchemes() + ".")); 335 SchemeRegistry::listOfCORSEnabledURLSchemes() + "."));
338 return; 336 return;
339 } 337 }
340 338
341 // Non-secure origins may not make "external requests": 339 // Non-secure origins may not make "external requests":
342 // https://mikewest.github.io/cors-rfc1918/#integration-fetch 340 // https://mikewest.github.io/cors-rfc1918/#integration-fetch
343 if (!m_loadingContext->isSecureContext() && request.isExternalRequest()) { 341 if (!m_loadingContext->isSecureContext() && request.isExternalRequest()) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 // Explicitly set the ServiceWorkerMode to None here. Although the page is 379 // Explicitly set the ServiceWorkerMode to None here. Although the page is
382 // not controlled by a SW at this point, a new SW may be controlling the 380 // not controlled by a SW at this point, a new SW may be controlling the
383 // page when this request gets sent later. We should not send the actual 381 // page when this request gets sent later. We should not send the actual
384 // request to the SW. https://crbug.com/604583 382 // request to the SW. https://crbug.com/604583
385 // Similarly we don't want any requests that could involve a CORS preflight 383 // Similarly we don't want any requests that could involve a CORS preflight
386 // to get intercepted by a foreign fetch service worker, even if we have the 384 // to get intercepted by a foreign fetch service worker, even if we have the
387 // result of the preflight cached already. https://crbug.com/674370 385 // result of the preflight cached already. https://crbug.com/674370
388 crossOriginRequest.setServiceWorkerMode( 386 crossOriginRequest.setServiceWorkerMode(
389 WebURLRequest::ServiceWorkerMode::None); 387 WebURLRequest::ServiceWorkerMode::None);
390 388
391 bool shouldForcePreflight = 389 bool shouldForcePreflight = request.isExternalRequest() ||
392 request.isExternalRequest() || 390 probe::shouldForceCORSPreflight(document());
393 InspectorInstrumentation::shouldForceCORSPreflight(document());
394 bool canSkipPreflight = 391 bool canSkipPreflight =
395 CrossOriginPreflightResultCache::shared().canSkipPreflight( 392 CrossOriginPreflightResultCache::shared().canSkipPreflight(
396 getSecurityOrigin()->toString(), crossOriginRequest.url(), 393 getSecurityOrigin()->toString(), crossOriginRequest.url(),
397 effectiveAllowCredentials(), crossOriginRequest.httpMethod(), 394 effectiveAllowCredentials(), crossOriginRequest.httpMethod(),
398 crossOriginRequest.httpHeaderFields()); 395 crossOriginRequest.httpHeaderFields());
399 if (canSkipPreflight && !shouldForcePreflight) { 396 if (canSkipPreflight && !shouldForcePreflight) {
400 prepareCrossOriginRequest(crossOriginRequest); 397 prepareCrossOriginRequest(crossOriginRequest);
401 loadRequest(crossOriginRequest, crossOriginOptions); 398 loadRequest(crossOriginRequest, crossOriginOptions);
402 } else { 399 } else {
403 ResourceRequest preflightRequest = 400 ResourceRequest preflightRequest =
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 if (m_corsRedirectLimit <= 0) { 546 if (m_corsRedirectLimit <= 0) {
550 ThreadableLoaderClient* client = m_client; 547 ThreadableLoaderClient* client = m_client;
551 clear(); 548 clear();
552 client->didFailRedirectCheck(); 549 client->didFailRedirectCheck();
553 return false; 550 return false;
554 } 551 }
555 552
556 --m_corsRedirectLimit; 553 --m_corsRedirectLimit;
557 554
558 if (document() && document()->frame()) { 555 if (document() && document()->frame()) {
559 InspectorInstrumentation::didReceiveCORSRedirectResponse( 556 probe::didReceiveCORSRedirectResponse(
560 document()->frame(), resource->identifier(), 557 document()->frame(), resource->identifier(),
561 document()->frame()->loader().documentLoader(), redirectResponse, 558 document()->frame()->loader().documentLoader(), redirectResponse,
562 resource); 559 resource);
563 } 560 }
564 561
565 String accessControlErrorDescription; 562 String accessControlErrorDescription;
566 563
567 CrossOriginAccessControl::RedirectStatus redirectStatus = 564 CrossOriginAccessControl::RedirectStatus redirectStatus =
568 CrossOriginAccessControl::checkRedirectLocation(request.url()); 565 CrossOriginAccessControl::checkRedirectLocation(request.url());
569 bool allowRedirect = 566 bool allowRedirect =
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 void DocumentThreadableLoader::reportResponseReceived( 769 void DocumentThreadableLoader::reportResponseReceived(
773 unsigned long identifier, 770 unsigned long identifier,
774 const ResourceResponse& response) { 771 const ResourceResponse& response) {
775 LocalFrame* frame = document() ? document()->frame() : nullptr; 772 LocalFrame* frame = document() ? document()->frame() : nullptr;
776 if (!frame) 773 if (!frame)
777 return; 774 return;
778 TRACE_EVENT1( 775 TRACE_EVENT1(
779 "devtools.timeline", "ResourceReceiveResponse", "data", 776 "devtools.timeline", "ResourceReceiveResponse", "data",
780 InspectorReceiveResponseEvent::data(identifier, frame, response)); 777 InspectorReceiveResponseEvent::data(identifier, frame, response));
781 DocumentLoader* loader = frame->loader().documentLoader(); 778 DocumentLoader* loader = frame->loader().documentLoader();
782 InspectorInstrumentation::didReceiveResourceResponse( 779 probe::didReceiveResourceResponse(frame, identifier, loader, response,
783 frame, identifier, loader, response, resource()); 780 resource());
784 frame->console().reportResourceResponseReceived(loader, identifier, response); 781 frame->console().reportResourceResponseReceived(loader, identifier, response);
785 } 782 }
786 783
787 void DocumentThreadableLoader::handleResponse( 784 void DocumentThreadableLoader::handleResponse(
788 unsigned long identifier, 785 unsigned long identifier,
789 const ResourceResponse& response, 786 const ResourceResponse& response,
790 std::unique_ptr<WebDataConsumerHandle> handle) { 787 std::unique_ptr<WebDataConsumerHandle> handle) {
791 DCHECK(m_client); 788 DCHECK(m_client);
792 789
793 if (!m_actualRequest.isNull()) { 790 if (!m_actualRequest.isNull()) {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 ResourceFetcher* fetcher = m_loadingContext->getResourceFetcher(); 1004 ResourceFetcher* fetcher = m_loadingContext->getResourceFetcher();
1008 if (request.requestContext() == WebURLRequest::RequestContextVideo || 1005 if (request.requestContext() == WebURLRequest::RequestContextVideo ||
1009 request.requestContext() == WebURLRequest::RequestContextAudio) 1006 request.requestContext() == WebURLRequest::RequestContextAudio)
1010 setResource(RawResource::fetchMedia(newRequest, fetcher)); 1007 setResource(RawResource::fetchMedia(newRequest, fetcher));
1011 else if (request.requestContext() == WebURLRequest::RequestContextManifest) 1008 else if (request.requestContext() == WebURLRequest::RequestContextManifest)
1012 setResource(RawResource::fetchManifest(newRequest, fetcher)); 1009 setResource(RawResource::fetchManifest(newRequest, fetcher));
1013 else 1010 else
1014 setResource(RawResource::fetch(newRequest, fetcher)); 1011 setResource(RawResource::fetch(newRequest, fetcher));
1015 1012
1016 if (!resource()) { 1013 if (!resource()) {
1017 InspectorInstrumentation:: 1014 probe::documentThreadableLoaderFailedToStartLoadingForClient(document(),
1018 documentThreadableLoaderFailedToStartLoadingForClient(document(), 1015 m_client);
1019 m_client);
1020 ThreadableLoaderClient* client = m_client; 1016 ThreadableLoaderClient* client = m_client;
1021 clear(); 1017 clear();
1022 // setResource() might call notifyFinished() and thus clear() 1018 // setResource() might call notifyFinished() and thus clear()
1023 // synchronously, and in such cases ThreadableLoaderClient is already 1019 // synchronously, and in such cases ThreadableLoaderClient is already
1024 // notified and |client| is null. 1020 // notified and |client| is null.
1025 if (!client) 1021 if (!client)
1026 return; 1022 return;
1027 client->didFail(ResourceError(errorDomainBlinkInternal, 0, 1023 client->didFail(ResourceError(errorDomainBlinkInternal, 0,
1028 request.url().getString(), 1024 request.url().getString(),
1029 "Failed to start loading.")); 1025 "Failed to start loading."));
1030 return; 1026 return;
1031 } 1027 }
1032 1028
1033 if (resource()->isLoading()) { 1029 if (resource()->isLoading()) {
1034 unsigned long identifier = resource()->identifier(); 1030 unsigned long identifier = resource()->identifier();
1035 InspectorInstrumentation::documentThreadableLoaderStartedLoadingForClient( 1031 probe::documentThreadableLoaderStartedLoadingForClient(
1036 document(), identifier, m_client); 1032 document(), identifier, m_client);
1037 } else { 1033 } else {
1038 InspectorInstrumentation:: 1034 probe::documentThreadableLoaderFailedToStartLoadingForClient(document(),
1039 documentThreadableLoaderFailedToStartLoadingForClient(document(), 1035 m_client);
1040 m_client);
1041 } 1036 }
1042 } 1037 }
1043 1038
1044 void DocumentThreadableLoader::loadRequestSync( 1039 void DocumentThreadableLoader::loadRequestSync(
1045 const ResourceRequest& request, 1040 const ResourceRequest& request,
1046 ResourceLoaderOptions resourceLoaderOptions) { 1041 ResourceLoaderOptions resourceLoaderOptions) {
1047 FetchRequest fetchRequest(request, m_options.initiator, 1042 FetchRequest fetchRequest(request, m_options.initiator,
1048 resourceLoaderOptions); 1043 resourceLoaderOptions);
1049 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests) 1044 if (m_options.crossOriginRequestPolicy == AllowCrossOriginRequests)
1050 fetchRequest.setOriginRestriction(FetchRequest::NoOriginRestriction); 1045 fetchRequest.setOriginRestriction(FetchRequest::NoOriginRestriction);
1051 Resource* resource = RawResource::fetchSynchronously( 1046 Resource* resource = RawResource::fetchSynchronously(
1052 fetchRequest, m_loadingContext->getResourceFetcher()); 1047 fetchRequest, m_loadingContext->getResourceFetcher());
1053 ResourceResponse response = 1048 ResourceResponse response =
1054 resource ? resource->response() : ResourceResponse(); 1049 resource ? resource->response() : ResourceResponse();
1055 unsigned long identifier = resource 1050 unsigned long identifier = resource
1056 ? resource->identifier() 1051 ? resource->identifier()
1057 : std::numeric_limits<unsigned long>::max(); 1052 : std::numeric_limits<unsigned long>::max();
1058 ResourceError error = resource ? resource->resourceError() : ResourceError(); 1053 ResourceError error = resource ? resource->resourceError() : ResourceError();
1059 1054
1060 InspectorInstrumentation::documentThreadableLoaderStartedLoadingForClient( 1055 probe::documentThreadableLoaderStartedLoadingForClient(document(), identifier,
1061 document(), identifier, m_client); 1056 m_client);
1062 ThreadableLoaderClient* client = m_client; 1057 ThreadableLoaderClient* client = m_client;
1063 1058
1064 if (!resource) { 1059 if (!resource) {
1065 m_client = nullptr; 1060 m_client = nullptr;
1066 client->didFail(error); 1061 client->didFail(error);
1067 return; 1062 return;
1068 } 1063 }
1069 1064
1070 const KURL& requestURL = request.url(); 1065 const KURL& requestURL = request.url();
1071 1066
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 } 1148 }
1154 1149
1155 DEFINE_TRACE(DocumentThreadableLoader) { 1150 DEFINE_TRACE(DocumentThreadableLoader) {
1156 visitor->trace(m_resource); 1151 visitor->trace(m_resource);
1157 visitor->trace(m_loadingContext); 1152 visitor->trace(m_loadingContext);
1158 ThreadableLoader::trace(visitor); 1153 ThreadableLoader::trace(visitor);
1159 RawResourceClient::trace(visitor); 1154 RawResourceClient::trace(visitor);
1160 } 1155 }
1161 1156
1162 } // namespace blink 1157 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/DocumentLoader.cpp ('k') | third_party/WebKit/Source/core/loader/FrameFetchContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698