Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/loader/FrameFetchContext.h" | 31 #include "core/loader/FrameFetchContext.h" |
| 32 | 32 |
| 33 #include <algorithm> | |
| 34 #include <memory> | |
|
caseq
2017/02/21 22:53:30
add blank line
alph
2017/02/22 00:31:32
Done.
| |
| 33 #include "bindings/core/v8/ScriptController.h" | 35 #include "bindings/core/v8/ScriptController.h" |
| 34 #include "bindings/core/v8/V8DOMActivityLogger.h" | 36 #include "bindings/core/v8/V8DOMActivityLogger.h" |
| 35 #include "core/dom/Document.h" | 37 #include "core/dom/Document.h" |
| 36 #include "core/frame/Deprecation.h" | 38 #include "core/frame/Deprecation.h" |
| 37 #include "core/frame/FrameConsole.h" | 39 #include "core/frame/FrameConsole.h" |
| 38 #include "core/frame/FrameHost.h" | 40 #include "core/frame/FrameHost.h" |
| 39 #include "core/frame/FrameView.h" | 41 #include "core/frame/FrameView.h" |
| 40 #include "core/frame/LocalDOMWindow.h" | 42 #include "core/frame/LocalDOMWindow.h" |
| 41 #include "core/frame/LocalFrame.h" | 43 #include "core/frame/LocalFrame.h" |
| 42 #include "core/frame/Settings.h" | 44 #include "core/frame/Settings.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 57 #include "core/loader/PingLoader.h" | 59 #include "core/loader/PingLoader.h" |
| 58 #include "core/loader/ProgressTracker.h" | 60 #include "core/loader/ProgressTracker.h" |
| 59 #include "core/loader/appcache/ApplicationCacheHost.h" | 61 #include "core/loader/appcache/ApplicationCacheHost.h" |
| 60 #include "core/page/NetworkStateNotifier.h" | 62 #include "core/page/NetworkStateNotifier.h" |
| 61 #include "core/page/Page.h" | 63 #include "core/page/Page.h" |
| 62 #include "core/paint/FirstMeaningfulPaintDetector.h" | 64 #include "core/paint/FirstMeaningfulPaintDetector.h" |
| 63 #include "core/svg/graphics/SVGImageChromeClient.h" | 65 #include "core/svg/graphics/SVGImageChromeClient.h" |
| 64 #include "core/timing/DOMWindowPerformance.h" | 66 #include "core/timing/DOMWindowPerformance.h" |
| 65 #include "core/timing/Performance.h" | 67 #include "core/timing/Performance.h" |
| 66 #include "platform/WebFrameScheduler.h" | 68 #include "platform/WebFrameScheduler.h" |
| 69 #include "platform/instrumentation/inspector/PlatformInspectorTraceEvents.h" | |
| 67 #include "platform/instrumentation/tracing/TracedValue.h" | 70 #include "platform/instrumentation/tracing/TracedValue.h" |
| 68 #include "platform/loader/fetch/ClientHintsPreferences.h" | 71 #include "platform/loader/fetch/ClientHintsPreferences.h" |
| 69 #include "platform/loader/fetch/FetchInitiatorTypeNames.h" | 72 #include "platform/loader/fetch/FetchInitiatorTypeNames.h" |
| 70 #include "platform/loader/fetch/Resource.h" | 73 #include "platform/loader/fetch/Resource.h" |
| 71 #include "platform/loader/fetch/ResourceLoadingLog.h" | 74 #include "platform/loader/fetch/ResourceLoadingLog.h" |
| 72 #include "platform/loader/fetch/UniqueIdentifier.h" | 75 #include "platform/loader/fetch/UniqueIdentifier.h" |
| 73 #include "platform/mhtml/MHTMLArchive.h" | 76 #include "platform/mhtml/MHTMLArchive.h" |
| 74 #include "platform/network/NetworkUtils.h" | 77 #include "platform/network/NetworkUtils.h" |
| 75 #include "platform/network/ResourceLoadPriority.h" | 78 #include "platform/network/ResourceLoadPriority.h" |
| 76 #include "platform/network/ResourceTimingInfo.h" | 79 #include "platform/network/ResourceTimingInfo.h" |
| 77 #include "platform/weborigin/SchemeRegistry.h" | 80 #include "platform/weborigin/SchemeRegistry.h" |
| 78 #include "platform/weborigin/SecurityPolicy.h" | 81 #include "platform/weborigin/SecurityPolicy.h" |
| 79 #include "public/platform/WebCachePolicy.h" | 82 #include "public/platform/WebCachePolicy.h" |
| 80 #include "public/platform/WebDocumentSubresourceFilter.h" | 83 #include "public/platform/WebDocumentSubresourceFilter.h" |
| 81 #include "public/platform/WebInsecureRequestPolicy.h" | 84 #include "public/platform/WebInsecureRequestPolicy.h" |
| 82 #include "public/platform/WebViewScheduler.h" | 85 #include "public/platform/WebViewScheduler.h" |
| 83 #include "wtf/Vector.h" | 86 #include "wtf/Vector.h" |
| 84 #include <algorithm> | |
| 85 #include <memory> | |
| 86 | 87 |
| 87 namespace blink { | 88 namespace blink { |
| 88 | 89 |
| 89 namespace { | 90 namespace { |
| 90 | 91 |
| 91 void emitWarningForDocWriteScripts(const String& url, Document& document) { | 92 void emitWarningForDocWriteScripts(const String& url, Document& document) { |
| 92 String message = | 93 String message = |
| 93 "A Parser-blocking, cross site (i.e. different eTLD+1) script, " + url + | 94 "A Parser-blocking, cross site (i.e. different eTLD+1) script, " + url + |
| 94 ", is invoked via document.write. This MAY be blocked by " | 95 ", is invoked via document.write. This MAY be blocked by " |
| 95 "the browser in this or a future page load due to poor network " | 96 "the browser in this or a future page load due to poor network " |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 void FrameFetchContext::dispatchDidReceiveData(unsigned long identifier, | 464 void FrameFetchContext::dispatchDidReceiveData(unsigned long identifier, |
| 464 const char* data, | 465 const char* data, |
| 465 int dataLength) { | 466 int dataLength) { |
| 466 frame()->loader().progress().incrementProgress(identifier, dataLength); | 467 frame()->loader().progress().incrementProgress(identifier, dataLength); |
| 467 InspectorInstrumentation::didReceiveData(frame(), identifier, data, | 468 InspectorInstrumentation::didReceiveData(frame(), identifier, data, |
| 468 dataLength); | 469 dataLength); |
| 469 } | 470 } |
| 470 | 471 |
| 471 void FrameFetchContext::dispatchDidReceiveEncodedData(unsigned long identifier, | 472 void FrameFetchContext::dispatchDidReceiveEncodedData(unsigned long identifier, |
| 472 int encodedDataLength) { | 473 int encodedDataLength) { |
| 473 TRACE_EVENT1( | 474 TRACE_EVENT1("devtools.timeline", "ResourceReceivedData", "data", |
| 474 "devtools.timeline", "ResourceReceivedData", "data", | 475 InspectorReceiveDataEvent::data(identifier, encodedDataLength)); |
| 475 InspectorReceiveDataEvent::data(identifier, frame(), encodedDataLength)); | |
| 476 InspectorInstrumentation::didReceiveEncodedDataLength(frame(), identifier, | 476 InspectorInstrumentation::didReceiveEncodedDataLength(frame(), identifier, |
| 477 encodedDataLength); | 477 encodedDataLength); |
| 478 } | 478 } |
| 479 | 479 |
| 480 void FrameFetchContext::dispatchDidDownloadData(unsigned long identifier, | 480 void FrameFetchContext::dispatchDidDownloadData(unsigned long identifier, |
| 481 int dataLength, | 481 int dataLength, |
| 482 int encodedDataLength) { | 482 int encodedDataLength) { |
| 483 TRACE_EVENT1( | 483 TRACE_EVENT1("devtools.timeline", "ResourceReceivedData", "data", |
| 484 "devtools.timeline", "ResourceReceivedData", "data", | 484 InspectorReceiveDataEvent::data(identifier, encodedDataLength)); |
| 485 InspectorReceiveDataEvent::data(identifier, frame(), encodedDataLength)); | |
| 486 frame()->loader().progress().incrementProgress(identifier, dataLength); | 485 frame()->loader().progress().incrementProgress(identifier, dataLength); |
| 487 InspectorInstrumentation::didReceiveData(frame(), identifier, 0, dataLength); | 486 InspectorInstrumentation::didReceiveData(frame(), identifier, 0, dataLength); |
| 488 InspectorInstrumentation::didReceiveEncodedDataLength(frame(), identifier, | 487 InspectorInstrumentation::didReceiveEncodedDataLength(frame(), identifier, |
| 489 encodedDataLength); | 488 encodedDataLength); |
| 490 } | 489 } |
| 491 | 490 |
| 492 void FrameFetchContext::dispatchDidFinishLoading(unsigned long identifier, | 491 void FrameFetchContext::dispatchDidFinishLoading(unsigned long identifier, |
| 493 double finishTime, | 492 double finishTime, |
| 494 int64_t encodedDataLength) { | 493 int64_t encodedDataLength) { |
| 495 TRACE_EVENT1("devtools.timeline", "ResourceFinish", "data", | |
| 496 InspectorResourceFinishEvent::data(identifier, finishTime, false, | |
| 497 encodedDataLength)); | |
| 498 frame()->loader().progress().completeProgress(identifier); | 494 frame()->loader().progress().completeProgress(identifier); |
| 499 InspectorInstrumentation::didFinishLoading(frame(), identifier, finishTime, | 495 InspectorInstrumentation::didFinishLoading(frame(), identifier, finishTime, |
| 500 encodedDataLength); | 496 encodedDataLength); |
| 501 if (frame()->frameScheduler()) | 497 if (frame()->frameScheduler()) |
| 502 frame()->frameScheduler()->didStopLoading(identifier); | 498 frame()->frameScheduler()->didStopLoading(identifier); |
| 503 } | 499 } |
| 504 | 500 |
| 505 void FrameFetchContext::dispatchDidFail(unsigned long identifier, | 501 void FrameFetchContext::dispatchDidFail(unsigned long identifier, |
| 506 const ResourceError& error, | 502 const ResourceError& error, |
| 507 int64_t encodedDataLength, | 503 int64_t encodedDataLength, |
| 508 bool isInternalRequest) { | 504 bool isInternalRequest) { |
| 509 TRACE_EVENT1("devtools.timeline", "ResourceFinish", "data", | |
| 510 InspectorResourceFinishEvent::data(identifier, 0, true, | |
| 511 encodedDataLength)); | |
| 512 frame()->loader().progress().completeProgress(identifier); | 505 frame()->loader().progress().completeProgress(identifier); |
| 513 InspectorInstrumentation::didFailLoading(frame(), identifier, error); | 506 InspectorInstrumentation::didFailLoading(frame(), identifier, error); |
| 514 // Notification to FrameConsole should come AFTER InspectorInstrumentation | 507 // Notification to FrameConsole should come AFTER InspectorInstrumentation |
| 515 // call, DevTools front-end relies on this. | 508 // call, DevTools front-end relies on this. |
| 516 if (!isInternalRequest) | 509 if (!isInternalRequest) |
| 517 frame()->console().didFailLoading(identifier, error); | 510 frame()->console().didFailLoading(identifier, error); |
| 518 if (frame()->frameScheduler()) | 511 if (frame()->frameScheduler()) |
| 519 frame()->frameScheduler()->didStopLoading(identifier); | 512 frame()->frameScheduler()->didStopLoading(identifier); |
| 520 } | 513 } |
| 521 | 514 |
| 522 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache( | 515 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache( |
| 523 unsigned long identifier, | 516 unsigned long identifier, |
| 524 Resource* resource, | 517 Resource* resource, |
| 525 WebURLRequest::FrameType frameType, | 518 WebURLRequest::FrameType frameType, |
| 526 WebURLRequest::RequestContext requestContext) { | 519 WebURLRequest::RequestContext requestContext) { |
| 527 ResourceRequest request(resource->url()); | 520 ResourceRequest request(resource->url()); |
| 528 request.setFrameType(frameType); | 521 request.setFrameType(frameType); |
| 529 request.setRequestContext(requestContext); | 522 request.setRequestContext(requestContext); |
| 530 frameLoaderClient()->dispatchDidLoadResourceFromMemoryCache( | 523 frameLoaderClient()->dispatchDidLoadResourceFromMemoryCache( |
| 531 request, resource->response()); | 524 request, resource->response()); |
| 532 dispatchWillSendRequest(identifier, request, ResourceResponse(), | 525 dispatchWillSendRequest(identifier, request, ResourceResponse(), |
| 533 resource->options().initiatorInfo); | 526 resource->options().initiatorInfo); |
| 534 | 527 |
| 535 InspectorInstrumentation::markResourceAsCached(frame(), identifier); | 528 InspectorInstrumentation::markResourceAsCached(frame(), identifier); |
| 536 if (!resource->response().isNull()) { | 529 if (!resource->response().isNull()) { |
| 530 TRACE_EVENT1( | |
| 531 "devtools.timeline", "ResourceReceiveResponse", "data", | |
| 532 InspectorReceiveResponseEvent::data(identifier, resource->response())); | |
| 537 dispatchDidReceiveResponseInternal(identifier, resource->response(), | 533 dispatchDidReceiveResponseInternal(identifier, resource->response(), |
| 538 frameType, requestContext, resource, | 534 frameType, requestContext, resource, |
| 539 LinkLoader::DoNotLoadResources); | 535 LinkLoader::DoNotLoadResources); |
| 540 } | 536 } |
| 541 | 537 |
| 542 if (resource->encodedSize() > 0) | 538 if (resource->encodedSize() > 0) |
| 543 dispatchDidReceiveData(identifier, 0, resource->encodedSize()); | 539 dispatchDidReceiveData(identifier, 0, resource->encodedSize()); |
| 544 | 540 |
| 541 TRACE_EVENT1("devtools.timeline", "ResourceFinish", "data", | |
| 542 InspectorResourceFinishEvent::data(identifier, 0, false, 0)); | |
| 545 dispatchDidFinishLoading(identifier, 0, 0); | 543 dispatchDidFinishLoading(identifier, 0, 0); |
| 546 } | 544 } |
| 547 | 545 |
| 548 bool FrameFetchContext::shouldLoadNewResource(Resource::Type type) const { | 546 bool FrameFetchContext::shouldLoadNewResource(Resource::Type type) const { |
| 549 if (!m_documentLoader) | 547 if (!m_documentLoader) |
| 550 return true; | 548 return true; |
| 551 | 549 |
| 552 FrameLoader& loader = m_documentLoader->frame()->loader(); | 550 FrameLoader& loader = m_documentLoader->frame()->loader(); |
| 553 if (type == Resource::MainResource) | 551 if (type == Resource::MainResource) |
| 554 return m_documentLoader == loader.provisionalDocumentLoader(); | 552 return m_documentLoader == loader.provisionalDocumentLoader(); |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1062 return frame()->frameScheduler()->loadingTaskRunner(); | 1060 return frame()->frameScheduler()->loadingTaskRunner(); |
| 1063 } | 1061 } |
| 1064 | 1062 |
| 1065 void FrameFetchContext::dispatchDidReceiveResponseInternal( | 1063 void FrameFetchContext::dispatchDidReceiveResponseInternal( |
| 1066 unsigned long identifier, | 1064 unsigned long identifier, |
| 1067 const ResourceResponse& response, | 1065 const ResourceResponse& response, |
| 1068 WebURLRequest::FrameType frameType, | 1066 WebURLRequest::FrameType frameType, |
| 1069 WebURLRequest::RequestContext requestContext, | 1067 WebURLRequest::RequestContext requestContext, |
| 1070 Resource* resource, | 1068 Resource* resource, |
| 1071 LinkLoader::CanLoadResources resourceLoadingPolicy) { | 1069 LinkLoader::CanLoadResources resourceLoadingPolicy) { |
| 1072 TRACE_EVENT1( | |
| 1073 "devtools.timeline", "ResourceReceiveResponse", "data", | |
| 1074 InspectorReceiveResponseEvent::data(identifier, frame(), response)); | |
| 1075 MixedContentChecker::checkMixedPrivatePublic(frame(), | 1070 MixedContentChecker::checkMixedPrivatePublic(frame(), |
| 1076 response.remoteIPAddress()); | 1071 response.remoteIPAddress()); |
| 1077 if (m_documentLoader && | 1072 if (m_documentLoader && |
| 1078 m_documentLoader == | 1073 m_documentLoader == |
| 1079 m_documentLoader->frame()->loader().provisionalDocumentLoader()) { | 1074 m_documentLoader->frame()->loader().provisionalDocumentLoader()) { |
| 1080 FrameClientHintsPreferencesContext hintsContext(frame()); | 1075 FrameClientHintsPreferencesContext hintsContext(frame()); |
| 1081 m_documentLoader->clientHintsPreferences() | 1076 m_documentLoader->clientHintsPreferences() |
| 1082 .updateFromAcceptClientHintsHeader( | 1077 .updateFromAcceptClientHintsHeader( |
| 1083 response.httpHeaderField(HTTPNames::Accept_CH), &hintsContext); | 1078 response.httpHeaderField(HTTPNames::Accept_CH), &hintsContext); |
| 1084 // When response is received with a provisional docloader, the resource | 1079 // When response is received with a provisional docloader, the resource |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1105 response); | 1100 response); |
| 1106 } | 1101 } |
| 1107 | 1102 |
| 1108 DEFINE_TRACE(FrameFetchContext) { | 1103 DEFINE_TRACE(FrameFetchContext) { |
| 1109 visitor->trace(m_document); | 1104 visitor->trace(m_document); |
| 1110 visitor->trace(m_documentLoader); | 1105 visitor->trace(m_documentLoader); |
| 1111 FetchContext::trace(visitor); | 1106 FetchContext::trace(visitor); |
| 1112 } | 1107 } |
| 1113 | 1108 |
| 1114 } // namespace blink | 1109 } // namespace blink |
| OLD | NEW |