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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 #include "core/html/HTMLFrameOwnerElement.h" | 44 #include "core/html/HTMLFrameOwnerElement.h" |
| 45 #include "core/html/imports/HTMLImportsController.h" | 45 #include "core/html/imports/HTMLImportsController.h" |
| 46 #include "core/inspector/ConsoleMessage.h" | 46 #include "core/inspector/ConsoleMessage.h" |
| 47 #include "core/inspector/IdentifiersFactory.h" | 47 #include "core/inspector/IdentifiersFactory.h" |
| 48 #include "core/inspector/InspectorInstrumentation.h" | 48 #include "core/inspector/InspectorInstrumentation.h" |
| 49 #include "core/inspector/InspectorNetworkAgent.h" | 49 #include "core/inspector/InspectorNetworkAgent.h" |
| 50 #include "core/inspector/InspectorTraceEvents.h" | 50 #include "core/inspector/InspectorTraceEvents.h" |
| 51 #include "core/loader/DocumentLoader.h" | 51 #include "core/loader/DocumentLoader.h" |
| 52 #include "core/loader/FrameLoader.h" | 52 #include "core/loader/FrameLoader.h" |
| 53 #include "core/loader/FrameLoaderClient.h" | 53 #include "core/loader/FrameLoaderClient.h" |
| 54 #include "core/loader/LinkLoader.h" | |
| 55 #include "core/loader/MixedContentChecker.h" | 54 #include "core/loader/MixedContentChecker.h" |
| 56 #include "core/loader/NetworkHintsInterface.h" | 55 #include "core/loader/NetworkHintsInterface.h" |
| 57 #include "core/loader/PingLoader.h" | 56 #include "core/loader/PingLoader.h" |
| 58 #include "core/loader/ProgressTracker.h" | 57 #include "core/loader/ProgressTracker.h" |
| 59 #include "core/loader/appcache/ApplicationCacheHost.h" | 58 #include "core/loader/appcache/ApplicationCacheHost.h" |
| 60 #include "core/page/NetworkStateNotifier.h" | 59 #include "core/page/NetworkStateNotifier.h" |
| 61 #include "core/page/Page.h" | 60 #include "core/page/Page.h" |
| 62 #include "core/svg/graphics/SVGImageChromeClient.h" | 61 #include "core/svg/graphics/SVGImageChromeClient.h" |
| 63 #include "core/timing/DOMWindowPerformance.h" | 62 #include "core/timing/DOMWindowPerformance.h" |
| 64 #include "core/timing/Performance.h" | 63 #include "core/timing/Performance.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 if (!redirectResponse.isNull()) | 312 if (!redirectResponse.isNull()) |
| 314 prepareRequest(identifier, request, redirectResponse); | 313 prepareRequest(identifier, request, redirectResponse); |
| 315 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceSendRequest", TRACE_EVENT _SCOPE_THREAD, "data", InspectorSendRequestEvent::data(identifier, frame(), requ est)); | 314 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceSendRequest", TRACE_EVENT _SCOPE_THREAD, "data", InspectorSendRequestEvent::data(identifier, frame(), requ est)); |
| 316 InspectorInstrumentation::willSendRequest(frame(), identifier, masterDocumen tLoader(), request, redirectResponse, initiatorInfo); | 315 InspectorInstrumentation::willSendRequest(frame(), identifier, masterDocumen tLoader(), request, redirectResponse, initiatorInfo); |
| 317 if (frame()->frameScheduler()) | 316 if (frame()->frameScheduler()) |
| 318 frame()->frameScheduler()->didStartLoading(identifier); | 317 frame()->frameScheduler()->didStartLoading(identifier); |
| 319 } | 318 } |
| 320 | 319 |
| 321 void FrameFetchContext::dispatchDidReceiveResponse(unsigned long identifier, con st ResourceResponse& response, WebURLRequest::FrameType frameType, WebURLRequest ::RequestContext requestContext, Resource* resource) | 320 void FrameFetchContext::dispatchDidReceiveResponse(unsigned long identifier, con st ResourceResponse& response, WebURLRequest::FrameType frameType, WebURLRequest ::RequestContext requestContext, Resource* resource) |
| 322 { | 321 { |
| 323 LinkLoader::CanLoadResources resourceLoadingPolicy = LinkLoader::LoadResourc esAndPreconnect; | 322 dispatchDidReceiveResponseInternal(identifier, response, frameType, requestC ontext, resource, LinkLoader::LoadResourcesAndPreconnect); |
| 324 MixedContentChecker::checkMixedPrivatePublic(frame(), response.remoteIPAddre ss()); | |
| 325 if (m_documentLoader == frame()->loader().provisionalDocumentLoader()) { | |
| 326 ResourceFetcher* fetcher = nullptr; | |
| 327 if (frame()->document()) | |
| 328 fetcher = frame()->document()->fetcher(); | |
| 329 m_documentLoader->clientHintsPreferences().updateFromAcceptClientHintsHe ader(response.httpHeaderField(HTTPNames::Accept_CH), fetcher); | |
| 330 // When response is received with a provisional docloader, the resource haven't committed yet, and we cannot load resources, only preconnect. | |
| 331 resourceLoadingPolicy = LinkLoader::DoNotLoadResources; | |
| 332 } | |
| 333 LinkLoader::loadLinksFromHeader(response.httpHeaderField(HTTPNames::Link), r esponse.url(), frame()->document(), NetworkHintsInterfaceImpl(), resourceLoading Policy, nullptr); | |
| 334 | |
| 335 if (response.hasMajorCertificateErrors()) | |
| 336 MixedContentChecker::handleCertificateError(frame(), response, frameType , requestContext); | |
| 337 | |
| 338 frame()->loader().progress().incrementProgress(identifier, response); | |
| 339 frame()->loader().client()->dispatchDidReceiveResponse(m_documentLoader, ide ntifier, response); | |
| 340 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceReceiveResponse", TRACE_E VENT_SCOPE_THREAD, "data", InspectorReceiveResponseEvent::data(identifier, frame (), response)); | |
| 341 DocumentLoader* documentLoader = masterDocumentLoader(); | |
| 342 InspectorInstrumentation::didReceiveResourceResponse(frame(), identifier, do cumentLoader, response, resource); | |
| 343 // It is essential that inspector gets resource response BEFORE console. | |
| 344 frame()->console().reportResourceResponseReceived(documentLoader, identifier , response); | |
| 345 } | 323 } |
| 346 | 324 |
| 347 void FrameFetchContext::dispatchDidReceiveData(unsigned long identifier, const c har* data, int dataLength, int encodedDataLength) | 325 void FrameFetchContext::dispatchDidReceiveData(unsigned long identifier, const c har* data, int dataLength, int encodedDataLength) |
| 348 { | 326 { |
| 349 frame()->loader().progress().incrementProgress(identifier, dataLength); | 327 frame()->loader().progress().incrementProgress(identifier, dataLength); |
| 350 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceReceivedData", TRACE_EVEN T_SCOPE_THREAD, "data", InspectorReceiveDataEvent::data(identifier, frame(), enc odedDataLength)); | 328 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceReceivedData", TRACE_EVEN T_SCOPE_THREAD, "data", InspectorReceiveDataEvent::data(identifier, frame(), enc odedDataLength)); |
| 351 InspectorInstrumentation::didReceiveData(frame(), identifier, data, dataLeng th, encodedDataLength); | 329 InspectorInstrumentation::didReceiveData(frame(), identifier, data, dataLeng th, encodedDataLength); |
| 352 } | 330 } |
| 353 | 331 |
| 354 void FrameFetchContext::dispatchDidDownloadData(unsigned long identifier, int da taLength, int encodedDataLength) | 332 void FrameFetchContext::dispatchDidDownloadData(unsigned long identifier, int da taLength, int encodedDataLength) |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 383 } | 361 } |
| 384 | 362 |
| 385 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache(unsigned long ide ntifier, Resource* resource, WebURLRequest::FrameType frameType, WebURLRequest:: RequestContext requestContext) | 363 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache(unsigned long ide ntifier, Resource* resource, WebURLRequest::FrameType frameType, WebURLRequest:: RequestContext requestContext) |
| 386 { | 364 { |
| 387 ResourceRequest request(resource->url()); | 365 ResourceRequest request(resource->url()); |
| 388 frame()->loader().client()->dispatchDidLoadResourceFromMemoryCache(request, resource->response()); | 366 frame()->loader().client()->dispatchDidLoadResourceFromMemoryCache(request, resource->response()); |
| 389 dispatchWillSendRequest(identifier, request, ResourceResponse(), resource->o ptions().initiatorInfo); | 367 dispatchWillSendRequest(identifier, request, ResourceResponse(), resource->o ptions().initiatorInfo); |
| 390 | 368 |
| 391 InspectorInstrumentation::markResourceAsCached(frame(), identifier); | 369 InspectorInstrumentation::markResourceAsCached(frame(), identifier); |
| 392 if (!resource->response().isNull()) | 370 if (!resource->response().isNull()) |
| 393 dispatchDidReceiveResponse(identifier, resource->response(), frameType, requestContext, resource); | 371 dispatchDidReceiveResponseInternal(identifier, resource->response(), fra meType, requestContext, resource, LinkLoader::DoNotLoadResources); |
|
Charlie Harrison
2016/07/19 21:35:39
To answer your last comment: This line is the func
Yoav Weiss
2016/07/19 21:43:02
OK, so that's what I missed! :)
| |
| 394 | 372 |
| 395 if (resource->encodedSize() > 0) | 373 if (resource->encodedSize() > 0) |
| 396 dispatchDidReceiveData(identifier, 0, resource->encodedSize(), 0); | 374 dispatchDidReceiveData(identifier, 0, resource->encodedSize(), 0); |
| 397 | 375 |
| 398 dispatchDidFinishLoading(identifier, 0, 0); | 376 dispatchDidFinishLoading(identifier, 0, 0); |
| 399 } | 377 } |
| 400 | 378 |
| 401 bool FrameFetchContext::shouldLoadNewResource(Resource::Type type) const | 379 bool FrameFetchContext::shouldLoadNewResource(Resource::Type type) const |
| 402 { | 380 { |
| 403 if (!m_documentLoader) | 381 if (!m_documentLoader) |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 801 return ResourceLoadPriorityVeryLow; | 779 return ResourceLoadPriorityVeryLow; |
| 802 | 780 |
| 803 return priority; | 781 return priority; |
| 804 } | 782 } |
| 805 | 783 |
| 806 WebTaskRunner* FrameFetchContext::loadingTaskRunner() const | 784 WebTaskRunner* FrameFetchContext::loadingTaskRunner() const |
| 807 { | 785 { |
| 808 return frame()->frameScheduler()->loadingTaskRunner(); | 786 return frame()->frameScheduler()->loadingTaskRunner(); |
| 809 } | 787 } |
| 810 | 788 |
| 789 void FrameFetchContext::dispatchDidReceiveResponseInternal(unsigned long identif ier, const ResourceResponse& response, WebURLRequest::FrameType frameType, WebUR LRequest::RequestContext requestContext, Resource* resource, LinkLoader::CanLoad Resources resourceLoadingPolicy) | |
|
Yoav Weiss
2016/07/19 21:04:03
Is there a functional change here? Or is this just
Charlie Harrison
2016/07/19 21:11:02
No functional change, except to pull resourceLoadi
Yoav Weiss
2016/07/19 21:14:21
I'm totally fine with this refactoring, just wasn'
| |
| 790 { | |
| 791 MixedContentChecker::checkMixedPrivatePublic(frame(), response.remoteIPAddre ss()); | |
| 792 if (m_documentLoader == frame()->loader().provisionalDocumentLoader()) { | |
| 793 ResourceFetcher* fetcher = nullptr; | |
| 794 if (frame()->document()) | |
| 795 fetcher = frame()->document()->fetcher(); | |
| 796 m_documentLoader->clientHintsPreferences().updateFromAcceptClientHintsHe ader(response.httpHeaderField(HTTPNames::Accept_CH), fetcher); | |
| 797 // When response is received with a provisional docloader, the resource haven't committed yet, and we cannot load resources, only preconnect. | |
| 798 resourceLoadingPolicy = LinkLoader::DoNotLoadResources; | |
| 799 } | |
| 800 LinkLoader::loadLinksFromHeader(response.httpHeaderField(HTTPNames::Link), r esponse.url(), frame()->document(), NetworkHintsInterfaceImpl(), resourceLoading Policy, nullptr); | |
| 801 | |
| 802 if (response.hasMajorCertificateErrors()) | |
| 803 MixedContentChecker::handleCertificateError(frame(), response, frameType , requestContext); | |
| 804 | |
| 805 frame()->loader().progress().incrementProgress(identifier, response); | |
| 806 frame()->loader().client()->dispatchDidReceiveResponse(m_documentLoader, ide ntifier, response); | |
| 807 TRACE_EVENT_INSTANT1("devtools.timeline", "ResourceReceiveResponse", TRACE_E VENT_SCOPE_THREAD, "data", InspectorReceiveResponseEvent::data(identifier, frame (), response)); | |
| 808 DocumentLoader* documentLoader = masterDocumentLoader(); | |
| 809 InspectorInstrumentation::didReceiveResourceResponse(frame(), identifier, do cumentLoader, response, resource); | |
| 810 // It is essential that inspector gets resource response BEFORE console. | |
| 811 frame()->console().reportResourceResponseReceived(documentLoader, identifier , response); | |
| 812 } | |
| 813 | |
| 811 DEFINE_TRACE(FrameFetchContext) | 814 DEFINE_TRACE(FrameFetchContext) |
| 812 { | 815 { |
| 813 visitor->trace(m_document); | 816 visitor->trace(m_document); |
| 814 visitor->trace(m_documentLoader); | 817 visitor->trace(m_documentLoader); |
| 815 FetchContext::trace(visitor); | 818 FetchContext::trace(visitor); |
| 816 } | 819 } |
| 817 | 820 |
| 818 } // namespace blink | 821 } // namespace blink |
| OLD | NEW |