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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 redirectResponse, initiatorInfo); | 480 redirectResponse, initiatorInfo); |
481 if (frame()->frameScheduler()) | 481 if (frame()->frameScheduler()) |
482 frame()->frameScheduler()->didStartLoading(identifier); | 482 frame()->frameScheduler()->didStartLoading(identifier); |
483 } | 483 } |
484 | 484 |
485 void FrameFetchContext::dispatchDidReceiveResponse( | 485 void FrameFetchContext::dispatchDidReceiveResponse( |
486 unsigned long identifier, | 486 unsigned long identifier, |
487 const ResourceResponse& response, | 487 const ResourceResponse& response, |
488 WebURLRequest::FrameType frameType, | 488 WebURLRequest::FrameType frameType, |
489 WebURLRequest::RequestContext requestContext, | 489 WebURLRequest::RequestContext requestContext, |
490 Resource* resource) { | 490 Resource* resource, |
491 dispatchDidReceiveResponseInternal(identifier, response, frameType, | 491 ResourceResponseType responseType) { |
492 requestContext, resource, | 492 if (responseType == ResourceResponseType::kFromMemoryCache) { |
493 LinkLoader::LoadResourcesAndPreconnect); | 493 // Note: probe::willSendRequest needs to precede before this probe method. |
| 494 probe::markResourceAsCached(frame(), identifier); |
| 495 if (response.isNull()) |
| 496 return; |
| 497 } |
| 498 |
| 499 MixedContentChecker::checkMixedPrivatePublic(frame(), |
| 500 response.remoteIPAddress()); |
| 501 LinkLoader::CanLoadResources resourceLoadingPolicy = |
| 502 responseType == ResourceResponseType::kFromMemoryCache |
| 503 ? LinkLoader::DoNotLoadResources |
| 504 : LinkLoader::LoadResourcesAndPreconnect; |
| 505 if (m_documentLoader && |
| 506 m_documentLoader == |
| 507 m_documentLoader->frame()->loader().provisionalDocumentLoader()) { |
| 508 FrameClientHintsPreferencesContext hintsContext(frame()); |
| 509 m_documentLoader->clientHintsPreferences() |
| 510 .updateFromAcceptClientHintsHeader( |
| 511 response.httpHeaderField(HTTPNames::Accept_CH), &hintsContext); |
| 512 // When response is received with a provisional docloader, the resource |
| 513 // haven't committed yet, and we cannot load resources, only preconnect. |
| 514 resourceLoadingPolicy = LinkLoader::DoNotLoadResources; |
| 515 } |
| 516 LinkLoader::loadLinksFromHeader( |
| 517 response.httpHeaderField(HTTPNames::Link), response.url(), |
| 518 frame()->document(), NetworkHintsInterfaceImpl(), resourceLoadingPolicy, |
| 519 LinkLoader::LoadAll, nullptr); |
| 520 |
| 521 if (response.hasMajorCertificateErrors()) { |
| 522 MixedContentChecker::handleCertificateError(frame(), response, frameType, |
| 523 requestContext); |
| 524 } |
| 525 |
| 526 frame()->loader().progress().incrementProgress(identifier, response); |
| 527 localFrameClient()->dispatchDidReceiveResponse(response); |
| 528 DocumentLoader* documentLoader = masterDocumentLoader(); |
| 529 probe::didReceiveResourceResponse(frame(), identifier, documentLoader, |
| 530 response, resource); |
| 531 // It is essential that inspector gets resource response BEFORE console. |
| 532 frame()->console().reportResourceResponseReceived(documentLoader, identifier, |
| 533 response); |
494 } | 534 } |
495 | 535 |
496 void FrameFetchContext::dispatchDidReceiveData(unsigned long identifier, | 536 void FrameFetchContext::dispatchDidReceiveData(unsigned long identifier, |
497 const char* data, | 537 const char* data, |
498 int dataLength) { | 538 int dataLength) { |
499 frame()->loader().progress().incrementProgress(identifier, dataLength); | 539 frame()->loader().progress().incrementProgress(identifier, dataLength); |
500 probe::didReceiveData(frame(), identifier, data, dataLength); | 540 probe::didReceiveData(frame(), identifier, data, dataLength); |
501 } | 541 } |
502 | 542 |
503 void FrameFetchContext::dispatchDidReceiveEncodedData(unsigned long identifier, | 543 void FrameFetchContext::dispatchDidReceiveEncodedData(unsigned long identifier, |
(...skipping 29 matching lines...) Expand all Loading... |
533 // Notification to FrameConsole should come AFTER InspectorInstrumentation | 573 // Notification to FrameConsole should come AFTER InspectorInstrumentation |
534 // call, DevTools front-end relies on this. | 574 // call, DevTools front-end relies on this. |
535 if (!isInternalRequest) | 575 if (!isInternalRequest) |
536 frame()->console().didFailLoading(identifier, error); | 576 frame()->console().didFailLoading(identifier, error); |
537 if (frame()->frameScheduler()) | 577 if (frame()->frameScheduler()) |
538 frame()->frameScheduler()->didStopLoading(identifier); | 578 frame()->frameScheduler()->didStopLoading(identifier); |
539 } | 579 } |
540 | 580 |
541 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache( | 581 void FrameFetchContext::dispatchDidLoadResourceFromMemoryCache( |
542 unsigned long identifier, | 582 unsigned long identifier, |
543 Resource* resource, | 583 const ResourceRequest& resourceRequest, |
544 WebURLRequest::FrameType frameType, | 584 const ResourceResponse& resourceResponse) { |
545 WebURLRequest::RequestContext requestContext) { | 585 localFrameClient()->dispatchDidLoadResourceFromMemoryCache(resourceRequest, |
546 ResourceRequest request(resource->url()); | 586 resourceResponse); |
547 request.setFrameType(frameType); | |
548 request.setRequestContext(requestContext); | |
549 localFrameClient()->dispatchDidLoadResourceFromMemoryCache( | |
550 request, resource->response()); | |
551 dispatchWillSendRequest(identifier, request, ResourceResponse(), | |
552 resource->options().initiatorInfo); | |
553 probe::markResourceAsCached(frame(), identifier); | |
554 if (!resource->response().isNull()) { | |
555 dispatchDidReceiveResponseInternal(identifier, resource->response(), | |
556 frameType, requestContext, resource, | |
557 LinkLoader::DoNotLoadResources); | |
558 } | |
559 | |
560 if (resource->encodedSize() > 0) | |
561 dispatchDidReceiveData(identifier, 0, resource->encodedSize()); | |
562 | |
563 dispatchDidFinishLoading(identifier, 0, 0, | |
564 resource->response().decodedBodyLength()); | |
565 } | 587 } |
566 | 588 |
567 bool FrameFetchContext::shouldLoadNewResource(Resource::Type type) const { | 589 bool FrameFetchContext::shouldLoadNewResource(Resource::Type type) const { |
568 if (!m_documentLoader) | 590 if (!m_documentLoader) |
569 return true; | 591 return true; |
570 | 592 |
571 FrameLoader& loader = m_documentLoader->frame()->loader(); | 593 FrameLoader& loader = m_documentLoader->frame()->loader(); |
572 if (type == Resource::MainResource) | 594 if (type == Resource::MainResource) |
573 return m_documentLoader == loader.provisionalDocumentLoader(); | 595 return m_documentLoader == loader.provisionalDocumentLoader(); |
574 return m_documentLoader == loader.documentLoader(); | 596 return m_documentLoader == loader.documentLoader(); |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 if (frame()->settings()->getLowPriorityIframes() && !frame()->isMainFrame()) | 1049 if (frame()->settings()->getLowPriorityIframes() && !frame()->isMainFrame()) |
1028 return ResourceLoadPriorityVeryLow; | 1050 return ResourceLoadPriorityVeryLow; |
1029 | 1051 |
1030 return priority; | 1052 return priority; |
1031 } | 1053 } |
1032 | 1054 |
1033 RefPtr<WebTaskRunner> FrameFetchContext::loadingTaskRunner() const { | 1055 RefPtr<WebTaskRunner> FrameFetchContext::loadingTaskRunner() const { |
1034 return frame()->frameScheduler()->loadingTaskRunner(); | 1056 return frame()->frameScheduler()->loadingTaskRunner(); |
1035 } | 1057 } |
1036 | 1058 |
1037 void FrameFetchContext::dispatchDidReceiveResponseInternal( | |
1038 unsigned long identifier, | |
1039 const ResourceResponse& response, | |
1040 WebURLRequest::FrameType frameType, | |
1041 WebURLRequest::RequestContext requestContext, | |
1042 Resource* resource, | |
1043 LinkLoader::CanLoadResources resourceLoadingPolicy) { | |
1044 MixedContentChecker::checkMixedPrivatePublic(frame(), | |
1045 response.remoteIPAddress()); | |
1046 if (m_documentLoader && | |
1047 m_documentLoader == | |
1048 m_documentLoader->frame()->loader().provisionalDocumentLoader()) { | |
1049 FrameClientHintsPreferencesContext hintsContext(frame()); | |
1050 m_documentLoader->clientHintsPreferences() | |
1051 .updateFromAcceptClientHintsHeader( | |
1052 response.httpHeaderField(HTTPNames::Accept_CH), &hintsContext); | |
1053 // When response is received with a provisional docloader, the resource | |
1054 // haven't committed yet, and we cannot load resources, only preconnect. | |
1055 resourceLoadingPolicy = LinkLoader::DoNotLoadResources; | |
1056 } | |
1057 LinkLoader::loadLinksFromHeader( | |
1058 response.httpHeaderField(HTTPNames::Link), response.url(), | |
1059 frame()->document(), NetworkHintsInterfaceImpl(), resourceLoadingPolicy, | |
1060 LinkLoader::LoadAll, nullptr); | |
1061 | |
1062 if (response.hasMajorCertificateErrors()) { | |
1063 MixedContentChecker::handleCertificateError(frame(), response, frameType, | |
1064 requestContext); | |
1065 } | |
1066 | |
1067 frame()->loader().progress().incrementProgress(identifier, response); | |
1068 localFrameClient()->dispatchDidReceiveResponse(response); | |
1069 DocumentLoader* documentLoader = masterDocumentLoader(); | |
1070 probe::didReceiveResourceResponse(frame(), identifier, documentLoader, | |
1071 response, resource); | |
1072 // It is essential that inspector gets resource response BEFORE console. | |
1073 frame()->console().reportResourceResponseReceived(documentLoader, identifier, | |
1074 response); | |
1075 } | |
1076 | |
1077 DEFINE_TRACE(FrameFetchContext) { | 1059 DEFINE_TRACE(FrameFetchContext) { |
1078 visitor->trace(m_document); | 1060 visitor->trace(m_document); |
1079 visitor->trace(m_documentLoader); | 1061 visitor->trace(m_documentLoader); |
1080 FetchContext::trace(visitor); | 1062 FetchContext::trace(visitor); |
1081 } | 1063 } |
1082 | 1064 |
1083 } // namespace blink | 1065 } // namespace blink |
OLD | NEW |