| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
| 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
| 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
| 6 rights reserved. | 6 rights reserved. |
| 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
| 8 | 8 |
| 9 This library is free software; you can redistribute it and/or | 9 This library is free software; you can redistribute it and/or |
| 10 modify it under the terms of the GNU Library General Public | 10 modify it under the terms of the GNU Library General Public |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 return ResourceLoadPriorityUnresolved; | 150 return ResourceLoadPriorityUnresolved; |
| 151 } | 151 } |
| 152 | 152 |
| 153 } // namespace | 153 } // namespace |
| 154 | 154 |
| 155 ResourceLoadPriority ResourceFetcher::computeLoadPriority( | 155 ResourceLoadPriority ResourceFetcher::computeLoadPriority( |
| 156 Resource::Type type, | 156 Resource::Type type, |
| 157 const ResourceRequest& resourceRequest, | 157 const ResourceRequest& resourceRequest, |
| 158 ResourcePriority::VisibilityStatus visibility, | 158 ResourcePriority::VisibilityStatus visibility, |
| 159 FetchRequest::DeferOption deferOption, | 159 FetchRequest::DeferOption deferOption, |
| 160 bool forPreload) { | 160 bool speculativePreload) { |
| 161 ResourceLoadPriority priority = typeToPriority(type); | 161 ResourceLoadPriority priority = typeToPriority(type); |
| 162 | 162 |
| 163 // Visible resources (images in practice) get a boost to High priority. | 163 // Visible resources (images in practice) get a boost to High priority. |
| 164 if (visibility == ResourcePriority::Visible) | 164 if (visibility == ResourcePriority::Visible) |
| 165 priority = ResourceLoadPriorityHigh; | 165 priority = ResourceLoadPriorityHigh; |
| 166 | 166 |
| 167 // Resources before the first image are considered "early" in the document and | 167 // Resources before the first image are considered "early" in the document and |
| 168 // resources after the first image are "late" in the document. Important to | 168 // resources after the first image are "late" in the document. Important to |
| 169 // note that this is based on when the preload scanner discovers a resource | 169 // note that this is based on when the preload scanner discovers a resource |
| 170 // for the most part so the main parser may not have reached the image element | 170 // for the most part so the main parser may not have reached the image element |
| 171 // yet. | 171 // yet. |
| 172 if (type == Resource::Image) | 172 if (type == Resource::Image) |
| 173 m_imageFetched = true; | 173 m_imageFetched = true; |
| 174 | 174 |
| 175 if (FetchRequest::IdleLoad == deferOption) { | 175 if (FetchRequest::IdleLoad == deferOption) { |
| 176 priority = ResourceLoadPriorityVeryLow; | 176 priority = ResourceLoadPriorityVeryLow; |
| 177 } else if (type == Resource::Script) { | 177 } else if (type == Resource::Script) { |
| 178 // Special handling for scripts. | 178 // Special handling for scripts. |
| 179 // Default/Parser-Blocking/Preload early in document: High (set in | 179 // Default/Parser-Blocking/Preload early in document: High (set in |
| 180 // typeToPriority) | 180 // typeToPriority) |
| 181 // Async/Defer: Low Priority (applies to both preload and parser-inserted) | 181 // Async/Defer: Low Priority (applies to both preload and parser-inserted) |
| 182 // Preload late in document: Medium | 182 // Preload late in document: Medium |
| 183 if (FetchRequest::LazyLoad == deferOption) | 183 if (FetchRequest::LazyLoad == deferOption) { |
| 184 priority = ResourceLoadPriorityLow; | 184 priority = ResourceLoadPriorityLow; |
| 185 else if (forPreload && m_imageFetched) | 185 } else if (speculativePreload && m_imageFetched) { |
| 186 // Speculative preload is used as a signal for scripts at the bottom of |
| 187 // the document. |
| 186 priority = ResourceLoadPriorityMedium; | 188 priority = ResourceLoadPriorityMedium; |
| 189 } |
| 187 } else if (FetchRequest::LazyLoad == deferOption) { | 190 } else if (FetchRequest::LazyLoad == deferOption) { |
| 188 priority = ResourceLoadPriorityVeryLow; | 191 priority = ResourceLoadPriorityVeryLow; |
| 189 } | 192 } |
| 190 | 193 |
| 191 // A manually set priority acts as a floor. This is used to ensure that | 194 // A manually set priority acts as a floor. This is used to ensure that |
| 192 // synchronous requests are always given the highest possible priority, as | 195 // synchronous requests are always given the highest possible priority, as |
| 193 // well as to ensure that there isn't priority churn if images move in and out | 196 // well as to ensure that there isn't priority churn if images move in and out |
| 194 // of the viewport, or is displayed more than once, both in and out of the | 197 // of the viewport, or is displayed more than once, both in and out of the |
| 195 // viewport. | 198 // viewport. |
| 196 return std::max(context().modifyPriorityForExperiments(priority), | 199 return std::max(context().modifyPriorityForExperiments(priority), |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 return resource.get(); | 272 return resource.get(); |
| 270 } | 273 } |
| 271 | 274 |
| 272 bool ResourceFetcher::isControlledByServiceWorker() const { | 275 bool ResourceFetcher::isControlledByServiceWorker() const { |
| 273 return context().isControlledByServiceWorker(); | 276 return context().isControlledByServiceWorker(); |
| 274 } | 277 } |
| 275 | 278 |
| 276 bool ResourceFetcher::resourceNeedsLoad(Resource* resource, | 279 bool ResourceFetcher::resourceNeedsLoad(Resource* resource, |
| 277 const FetchRequest& request, | 280 const FetchRequest& request, |
| 278 RevalidationPolicy policy) { | 281 RevalidationPolicy policy) { |
| 279 // Defer a font load until it is actually needed unless this is a preload. | 282 // Defer a font load until it is actually needed unless this is a link |
| 280 if (resource->getType() == Resource::Font && !request.forPreload()) | 283 // preload. |
| 284 if (resource->getType() == Resource::Font && !request.isLinkPreload()) |
| 281 return false; | 285 return false; |
| 282 if (resource->isImage() && shouldDeferImageLoad(resource->url())) | 286 if (resource->isImage() && shouldDeferImageLoad(resource->url())) |
| 283 return false; | 287 return false; |
| 284 return policy != Use || resource->stillNeedsLoad(); | 288 return policy != Use || resource->stillNeedsLoad(); |
| 285 } | 289 } |
| 286 | 290 |
| 287 // Limit the number of URLs in m_validatedURLs to avoid memory bloat. | 291 // Limit the number of URLs in m_validatedURLs to avoid memory bloat. |
| 288 // http://crbug.com/52411 | 292 // http://crbug.com/52411 |
| 289 static const int kMaxValidatedURLsSize = 10000; | 293 static const int kMaxValidatedURLsSize = 10000; |
| 290 | 294 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 const FetchRequest& request, | 412 const FetchRequest& request, |
| 409 const ResourceFactory& factory, | 413 const ResourceFactory& factory, |
| 410 ResourceRequestBlockedReason blockedReason) { | 414 ResourceRequestBlockedReason blockedReason) { |
| 411 Resource* resource = factory.create(request.resourceRequest(), | 415 Resource* resource = factory.create(request.resourceRequest(), |
| 412 request.options(), request.charset()); | 416 request.options(), request.charset()); |
| 413 resource->error(ResourceError::cancelledDueToAccessCheckError(request.url(), | 417 resource->error(ResourceError::cancelledDueToAccessCheckError(request.url(), |
| 414 blockedReason)); | 418 blockedReason)); |
| 415 return resource; | 419 return resource; |
| 416 } | 420 } |
| 417 | 421 |
| 418 void ResourceFetcher::moveCachedNonBlockingResourceToBlocking( | 422 void ResourceFetcher::makePreloadedResourceBlockOnloadIfNeeded( |
| 419 Resource* resource, | 423 Resource* resource, |
| 420 const FetchRequest& request) { | 424 const FetchRequest& request) { |
| 421 // TODO(yoav): Test that non-blocking resources (video/audio/track) continue | 425 // TODO(yoav): Test that non-blocking resources (video/audio/track) continue |
| 422 // to not-block even after being preloaded and discovered. | 426 // to not-block even after being preloaded and discovered. |
| 423 if (resource && resource->loader() && | 427 if (resource && resource->loader() && |
| 424 resource->isLoadEventBlockingResourceType() && | 428 resource->isLoadEventBlockingResourceType() && |
| 425 m_nonBlockingLoaders.contains(resource->loader()) && | 429 resource->isLinkPreload() && !request.isLinkPreload() && |
| 426 resource->isLinkPreload() && !request.forPreload()) { | 430 m_nonBlockingLoaders.contains(resource->loader())) { |
| 427 m_nonBlockingLoaders.remove(resource->loader()); | 431 m_nonBlockingLoaders.remove(resource->loader()); |
| 428 m_loaders.insert(resource->loader()); | 432 m_loaders.insert(resource->loader()); |
| 429 } | 433 } |
| 430 } | 434 } |
| 431 | 435 |
| 432 void ResourceFetcher::updateMemoryCacheStats(Resource* resource, | 436 void ResourceFetcher::updateMemoryCacheStats(Resource* resource, |
| 433 RevalidationPolicy policy, | 437 RevalidationPolicy policy, |
| 434 const FetchRequest& request, | 438 const FetchRequest& request, |
| 435 const ResourceFactory& factory, | 439 const ResourceFactory& factory, |
| 436 bool isStaticData) const { | 440 bool isStaticData) const { |
| 437 if (isStaticData) | 441 if (isStaticData) |
| 438 return; | 442 return; |
| 439 | 443 |
| 440 if (request.forPreload()) { | 444 if (request.isSpeculativePreload() || request.isLinkPreload()) { |
| 441 DEFINE_RESOURCE_HISTOGRAM("Preload."); | 445 DEFINE_RESOURCE_HISTOGRAM("Preload."); |
| 442 } else { | 446 } else { |
| 443 DEFINE_RESOURCE_HISTOGRAM(""); | 447 DEFINE_RESOURCE_HISTOGRAM(""); |
| 444 } | 448 } |
| 445 | 449 |
| 446 // Aims to count Resource only referenced from MemoryCache (i.e. what would be | 450 // Aims to count Resource only referenced from MemoryCache (i.e. what would be |
| 447 // dead if MemoryCache holds weak references to Resource). Currently we check | 451 // dead if MemoryCache holds weak references to Resource). Currently we check |
| 448 // references to Resource from ResourceClient and |m_preloads| only, because | 452 // references to Resource from ResourceClient and |m_preloads| only, because |
| 449 // they are major sources of references. | 453 // they are major sources of references. |
| 450 if (resource && !resource->isAlive() && | 454 if (resource && !resource->isAlive() && |
| (...skipping 16 matching lines...) Expand all Loading... |
| 467 | 471 |
| 468 context().populateResourceRequest( | 472 context().populateResourceRequest( |
| 469 factory.type(), request.clientHintsPreferences(), | 473 factory.type(), request.clientHintsPreferences(), |
| 470 request.getResourceWidth(), resourceRequest); | 474 request.getResourceWidth(), resourceRequest); |
| 471 | 475 |
| 472 if (!request.url().isValid()) | 476 if (!request.url().isValid()) |
| 473 return Abort; | 477 return Abort; |
| 474 | 478 |
| 475 resourceRequest.setPriority(computeLoadPriority( | 479 resourceRequest.setPriority(computeLoadPriority( |
| 476 factory.type(), request.resourceRequest(), ResourcePriority::NotVisible, | 480 factory.type(), request.resourceRequest(), ResourcePriority::NotVisible, |
| 477 request.defer(), request.forPreload())); | 481 request.defer(), request.isSpeculativePreload())); |
| 478 initializeResourceRequest(resourceRequest, factory.type(), request.defer()); | 482 initializeResourceRequest(resourceRequest, factory.type(), request.defer()); |
| 479 network_instrumentation::resourcePrioritySet(identifier, | 483 network_instrumentation::resourcePrioritySet(identifier, |
| 480 resourceRequest.priority()); | 484 resourceRequest.priority()); |
| 481 | 485 |
| 482 blockedReason = context().canRequest( | 486 blockedReason = context().canRequest( |
| 483 factory.type(), resourceRequest, | 487 factory.type(), resourceRequest, |
| 484 MemoryCache::removeFragmentIdentifierIfNeeded(request.url()), | 488 MemoryCache::removeFragmentIdentifierIfNeeded(request.url()), |
| 485 request.options(), request.forPreload(), request.getOriginRestriction()); | 489 request.options(), |
| 490 /* Don't send security violation reports for speculative preloads */ |
| 491 request.isSpeculativePreload() |
| 492 ? FetchContext::SecurityViolationReportingPolicy::SuppressReporting |
| 493 : FetchContext::SecurityViolationReportingPolicy::Report, |
| 494 request.getOriginRestriction()); |
| 486 if (blockedReason != ResourceRequestBlockedReason::None) { | 495 if (blockedReason != ResourceRequestBlockedReason::None) { |
| 487 DCHECK(!substituteData.forceSynchronousLoad()); | 496 DCHECK(!substituteData.forceSynchronousLoad()); |
| 488 return Block; | 497 return Block; |
| 489 } | 498 } |
| 490 | 499 |
| 491 context().willStartLoadingResource( | 500 context().willStartLoadingResource( |
| 492 identifier, resourceRequest, factory.type(), | 501 identifier, resourceRequest, factory.type(), |
| 493 request.options().initiatorInfo.name, request.forPreload()); | 502 request.options().initiatorInfo.name, |
| 503 (request.isSpeculativePreload() |
| 504 ? FetchContext::V8ActivityLoggingPolicy::SuppressLogging |
| 505 : FetchContext::V8ActivityLoggingPolicy::Log)); |
| 494 if (!request.url().isValid()) | 506 if (!request.url().isValid()) |
| 495 return Abort; | 507 return Abort; |
| 496 | 508 |
| 497 resourceRequest.setAllowStoredCredentials( | 509 resourceRequest.setAllowStoredCredentials( |
| 498 request.options().allowCredentials == AllowStoredCredentials); | 510 request.options().allowCredentials == AllowStoredCredentials); |
| 499 return Continue; | 511 return Continue; |
| 500 } | 512 } |
| 501 | 513 |
| 502 Resource* ResourceFetcher::requestResource( | 514 Resource* ResourceFetcher::requestResource( |
| 503 FetchRequest& request, | 515 FetchRequest& request, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 532 // to be decoded only on demand. These data URLs are allowed to be | 544 // to be decoded only on demand. These data URLs are allowed to be |
| 533 // processed using the normal ResourceFetcher machinery. | 545 // processed using the normal ResourceFetcher machinery. |
| 534 if (!resource && !isDataUrl && m_archive) | 546 if (!resource && !isDataUrl && m_archive) |
| 535 return nullptr; | 547 return nullptr; |
| 536 } | 548 } |
| 537 if (!resource) { | 549 if (!resource) { |
| 538 resource = | 550 resource = |
| 539 memoryCache()->resourceForURL(request.url(), getCacheIdentifier()); | 551 memoryCache()->resourceForURL(request.url(), getCacheIdentifier()); |
| 540 } | 552 } |
| 541 | 553 |
| 542 // See if we can use an existing resource from the cache. If so, we need to | 554 // If we got a preloaded resource from the cache for a non-preload request, |
| 543 // move it to be load blocking. | 555 // we may need to make it block the onload event. |
| 544 moveCachedNonBlockingResourceToBlocking(resource, request); | 556 makePreloadedResourceBlockOnloadIfNeeded(resource, request); |
| 545 | 557 |
| 546 const RevalidationPolicy policy = determineRevalidationPolicy( | 558 const RevalidationPolicy policy = determineRevalidationPolicy( |
| 547 factory.type(), request, resource, isStaticData); | 559 factory.type(), request, resource, isStaticData); |
| 548 TRACE_EVENT_INSTANT1("blink", "ResourceFetcher::determineRevalidationPolicy", | 560 TRACE_EVENT_INSTANT1("blink", "ResourceFetcher::determineRevalidationPolicy", |
| 549 TRACE_EVENT_SCOPE_THREAD, "revalidationPolicy", policy); | 561 TRACE_EVENT_SCOPE_THREAD, "revalidationPolicy", policy); |
| 550 | 562 |
| 551 updateMemoryCacheStats(resource, policy, request, factory, isStaticData); | 563 updateMemoryCacheStats(resource, policy, request, factory, isStaticData); |
| 552 | 564 |
| 553 switch (policy) { | 565 switch (policy) { |
| 554 case Reload: | 566 case Reload: |
| 555 memoryCache()->remove(resource); | 567 memoryCache()->remove(resource); |
| 556 // Fall through | 568 // Fall through |
| 557 case Load: | 569 case Load: |
| 558 resource = createResourceForLoading(request, request.charset(), factory); | 570 resource = createResourceForLoading(request, request.charset(), factory); |
| 559 break; | 571 break; |
| 560 case Revalidate: | 572 case Revalidate: |
| 561 initializeRevalidation(resourceRequest, resource); | 573 initializeRevalidation(resourceRequest, resource); |
| 562 break; | 574 break; |
| 563 case Use: | 575 case Use: |
| 564 if (resource->isLinkPreload() && !request.isLinkPreload()) | 576 if (resource->isLinkPreload() && !request.isLinkPreload()) |
| 565 resource->setLinkPreload(false); | 577 resource->setLinkPreload(false); |
| 566 break; | 578 break; |
| 567 } | 579 } |
| 568 if (!resource) | 580 if (!resource) |
| 569 return nullptr; | 581 return nullptr; |
| 570 if (resource->getType() != factory.type()) { | 582 if (resource->getType() != factory.type()) { |
| 571 DCHECK(request.forPreload()); | 583 DCHECK(request.isSpeculativePreload() || request.isLinkPreload()); |
| 584 // TODO(yoav): What's the scenario where this can actually happen? |
| 572 return nullptr; | 585 return nullptr; |
| 573 } | 586 } |
| 574 | 587 |
| 575 if (!resource->isAlive()) | 588 if (!resource->isAlive()) |
| 576 m_deadStatsRecorder.update(policy); | 589 m_deadStatsRecorder.update(policy); |
| 577 | 590 |
| 578 if (policy != Use) | 591 if (policy != Use) |
| 579 resource->setIdentifier(identifier); | 592 resource->setIdentifier(identifier); |
| 580 | 593 |
| 581 if (!request.forPreload() || policy != Use) { | 594 // TODO(yoav): It is not clear why preloads are exempt from this check. Can we |
| 595 // remove the exemption? |
| 596 if (!request.isSpeculativePreload() || policy != Use) { |
| 582 // When issuing another request for a resource that is already in-flight | 597 // When issuing another request for a resource that is already in-flight |
| 583 // make sure to not demote the priority of the in-flight request. If the new | 598 // make sure to not demote the priority of the in-flight request. If the new |
| 584 // request isn't at the same priority as the in-flight request, only allow | 599 // request isn't at the same priority as the in-flight request, only allow |
| 585 // promotions. This can happen when a visible image's priority is increased | 600 // promotions. This can happen when a visible image's priority is increased |
| 586 // and then another reference to the image is parsed (which would be at a | 601 // and then another reference to the image is parsed (which would be at a |
| 587 // lower priority). | 602 // lower priority). |
| 588 if (resourceRequest.priority() > resource->resourceRequest().priority()) | 603 if (resourceRequest.priority() > resource->resourceRequest().priority()) |
| 589 resource->didChangePriority(resourceRequest.priority(), 0); | 604 resource->didChangePriority(resourceRequest.priority(), 0); |
| 605 // TODO(yoav): I'd expect the stated scenario to not go here, as its policy |
| 606 // would be Use. |
| 590 } | 607 } |
| 591 | 608 |
| 592 // If only the fragment identifiers differ, it is the same resource. | 609 // If only the fragment identifiers differ, it is the same resource. |
| 593 DCHECK(equalIgnoringFragmentIdentifier(resource->url(), request.url())); | 610 DCHECK(equalIgnoringFragmentIdentifier(resource->url(), request.url())); |
| 594 requestLoadStarted( | 611 requestLoadStarted( |
| 595 identifier, resource, request, | 612 identifier, resource, request, |
| 596 policy == Use ? ResourceLoadingFromCache : ResourceLoadingFromNetwork, | 613 policy == Use ? ResourceLoadingFromCache : ResourceLoadingFromNetwork, |
| 597 isStaticData); | 614 isStaticData); |
| 598 m_documentResources.set( | 615 m_documentResources.set( |
| 599 MemoryCache::removeFragmentIdentifierIfNeeded(request.url()), resource); | 616 MemoryCache::removeFragmentIdentifierIfNeeded(request.url()), resource); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 const String cacheIdentifier = getCacheIdentifier(); | 718 const String cacheIdentifier = getCacheIdentifier(); |
| 702 DCHECK(!memoryCache()->resourceForURL(request.resourceRequest().url(), | 719 DCHECK(!memoryCache()->resourceForURL(request.resourceRequest().url(), |
| 703 cacheIdentifier)); | 720 cacheIdentifier)); |
| 704 | 721 |
| 705 RESOURCE_LOADING_DVLOG(1) << "Loading Resource for " | 722 RESOURCE_LOADING_DVLOG(1) << "Loading Resource for " |
| 706 << request.resourceRequest().url().elidedString(); | 723 << request.resourceRequest().url().elidedString(); |
| 707 | 724 |
| 708 Resource* resource = | 725 Resource* resource = |
| 709 factory.create(request.resourceRequest(), request.options(), charset); | 726 factory.create(request.resourceRequest(), request.options(), charset); |
| 710 resource->setLinkPreload(request.isLinkPreload()); | 727 resource->setLinkPreload(request.isLinkPreload()); |
| 711 if (request.forPreload()) { | 728 if (request.isSpeculativePreload()) { |
| 712 resource->setPreloadDiscoveryTime(request.preloadDiscoveryTime()); | 729 resource->setPreloadDiscoveryTime(request.preloadDiscoveryTime()); |
| 713 } | 730 } |
| 714 resource->setCacheIdentifier(cacheIdentifier); | 731 resource->setCacheIdentifier(cacheIdentifier); |
| 715 | 732 |
| 716 // - Don't add main resource to cache to prevent reuse. | 733 // - Don't add main resource to cache to prevent reuse. |
| 717 // - Don't add the resource if its body will not be stored. | 734 // - Don't add the resource if its body will not be stored. |
| 718 if (factory.type() != Resource::MainResource && | 735 if (factory.type() != Resource::MainResource && |
| 719 request.options().dataBufferingPolicy != DoNotBufferData) { | 736 request.options().dataBufferingPolicy != DoNotBufferData) { |
| 720 memoryCache()->add(resource); | 737 memoryCache()->add(resource); |
| 721 } | 738 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 if (existingResource->mustRefetchDueToIntegrityMetadata(fetchRequest)) { | 821 if (existingResource->mustRefetchDueToIntegrityMetadata(fetchRequest)) { |
| 805 RecordSriResourceIntegrityMismatchEvent(RefetchDueToIntegrityMismatch); | 822 RecordSriResourceIntegrityMismatchEvent(RefetchDueToIntegrityMismatch); |
| 806 return Reload; | 823 return Reload; |
| 807 } | 824 } |
| 808 | 825 |
| 809 // Service Worker's CORS fallback message must not be cached. | 826 // Service Worker's CORS fallback message must not be cached. |
| 810 if (existingResource->response().wasFallbackRequiredByServiceWorker()) | 827 if (existingResource->response().wasFallbackRequiredByServiceWorker()) |
| 811 return Reload; | 828 return Reload; |
| 812 | 829 |
| 813 // We already have a preload going for this URL. | 830 // We already have a preload going for this URL. |
| 814 if (fetchRequest.forPreload() && existingResource->isPreloaded()) | 831 if (fetchRequest.isSpeculativePreload() && existingResource->isPreloaded()) |
| 815 return Use; | 832 return Use; |
| 816 | 833 |
| 817 // If the same URL has been loaded as a different type, we need to reload. | 834 // If the same URL has been loaded as a different type, we need to reload. |
| 818 if (existingResource->getType() != type) { | 835 if (existingResource->getType() != type) { |
| 819 // FIXME: If existingResource is a Preload and the new type is LinkPrefetch | 836 // FIXME: If existingResource is a Preload and the new type is LinkPrefetch |
| 820 // We really should discard the new prefetch since the preload has more | 837 // We really should discard the new prefetch since the preload has more |
| 821 // specific type information! crbug.com/379893 | 838 // specific type information! crbug.com/379893 |
| 822 // fast/dom/HTMLLinkElement/link-and-subresource-test hits this case. | 839 // fast/dom/HTMLLinkElement/link-and-subresource-test hits this case. |
| 823 RESOURCE_LOADING_DVLOG(1) << "ResourceFetcher::determineRevalidationPolicy " | 840 RESOURCE_LOADING_DVLOG(1) << "ResourceFetcher::determineRevalidationPolicy " |
| 824 "reloading due to type mismatch."; | 841 "reloading due to type mismatch."; |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1472 const KURL& url, | 1489 const KURL& url, |
| 1473 WebURLRequest::RequestContext requestContext, | 1490 WebURLRequest::RequestContext requestContext, |
| 1474 const AtomicString& initiatorName) { | 1491 const AtomicString& initiatorName) { |
| 1475 if (cachedResource(url)) | 1492 if (cachedResource(url)) |
| 1476 return; | 1493 return; |
| 1477 ResourceRequest resourceRequest(url); | 1494 ResourceRequest resourceRequest(url); |
| 1478 resourceRequest.setRequestContext(requestContext); | 1495 resourceRequest.setRequestContext(requestContext); |
| 1479 FetchRequest request(resourceRequest, initiatorName, resource->options()); | 1496 FetchRequest request(resourceRequest, initiatorName, resource->options()); |
| 1480 context().canRequest(resource->getType(), resource->lastResourceRequest(), | 1497 context().canRequest(resource->getType(), resource->lastResourceRequest(), |
| 1481 resource->lastResourceRequest().url(), request.options(), | 1498 resource->lastResourceRequest().url(), request.options(), |
| 1482 false, request.getOriginRestriction()); | 1499 FetchContext::SecurityViolationReportingPolicy::Report, |
| 1500 request.getOriginRestriction()); |
| 1483 requestLoadStarted(resource->identifier(), resource, request, | 1501 requestLoadStarted(resource->identifier(), resource, request, |
| 1484 ResourceLoadingFromCache); | 1502 ResourceLoadingFromCache); |
| 1485 } | 1503 } |
| 1486 | 1504 |
| 1487 ResourceFetcher::DeadResourceStatsRecorder::DeadResourceStatsRecorder() | 1505 ResourceFetcher::DeadResourceStatsRecorder::DeadResourceStatsRecorder() |
| 1488 : m_useCount(0), m_revalidateCount(0), m_loadCount(0) {} | 1506 : m_useCount(0), m_revalidateCount(0), m_loadCount(0) {} |
| 1489 | 1507 |
| 1490 ResourceFetcher::DeadResourceStatsRecorder::~DeadResourceStatsRecorder() { | 1508 ResourceFetcher::DeadResourceStatsRecorder::~DeadResourceStatsRecorder() { |
| 1491 DEFINE_THREAD_SAFE_STATIC_LOCAL( | 1509 DEFINE_THREAD_SAFE_STATIC_LOCAL( |
| 1492 CustomCountHistogram, hitCountHistogram, | 1510 CustomCountHistogram, hitCountHistogram, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 visitor->trace(m_context); | 1543 visitor->trace(m_context); |
| 1526 visitor->trace(m_archive); | 1544 visitor->trace(m_archive); |
| 1527 visitor->trace(m_loaders); | 1545 visitor->trace(m_loaders); |
| 1528 visitor->trace(m_nonBlockingLoaders); | 1546 visitor->trace(m_nonBlockingLoaders); |
| 1529 visitor->trace(m_documentResources); | 1547 visitor->trace(m_documentResources); |
| 1530 visitor->trace(m_preloads); | 1548 visitor->trace(m_preloads); |
| 1531 visitor->trace(m_resourceTimingInfoMap); | 1549 visitor->trace(m_resourceTimingInfoMap); |
| 1532 } | 1550 } |
| 1533 | 1551 |
| 1534 } // namespace blink | 1552 } // namespace blink |
| OLD | NEW |