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

Side by Side Diff: third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp

Issue 2686533005: Remove type mismatch condition in requestResource (Closed)
Patch Set: Fix determineRevaliationPolicy Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 case Revalidate: 572 case Revalidate:
573 initializeRevalidation(resourceRequest, resource); 573 initializeRevalidation(resourceRequest, resource);
574 break; 574 break;
575 case Use: 575 case Use:
576 if (resource->isLinkPreload() && !request.isLinkPreload()) 576 if (resource->isLinkPreload() && !request.isLinkPreload())
577 resource->setLinkPreload(false); 577 resource->setLinkPreload(false);
578 break; 578 break;
579 } 579 }
580 if (!resource) 580 if (!resource)
581 return nullptr; 581 return nullptr;
582 if (resource->getType() != factory.type()) { 582
583 DCHECK(request.isSpeculativePreload() || request.isLinkPreload()); 583 // TODO(yoav): turn to a DCHECK. See https://crbug.com/690632
584 // TODO(yoav): What's the scenario where this can actually happen? 584 CHECK_EQ(resource->getType(), factory.type());
585 return nullptr;
586 }
587 585
588 if (!resource->isAlive()) 586 if (!resource->isAlive())
589 m_deadStatsRecorder.update(policy); 587 m_deadStatsRecorder.update(policy);
590 588
591 if (policy != Use) 589 if (policy != Use)
592 resource->setIdentifier(identifier); 590 resource->setIdentifier(identifier);
593 591
594 // TODO(yoav): It is not clear why preloads are exempt from this check. Can we 592 // TODO(yoav): It is not clear why preloads are exempt from this check. Can we
595 // remove the exemption? 593 // remove the exemption?
596 if (!request.isSpeculativePreload() || policy != Use) { 594 if (!request.isSpeculativePreload() || policy != Use) {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 RecordSriResourceIntegrityMismatchEvent(CheckingForIntegrityMismatch); 818 RecordSriResourceIntegrityMismatchEvent(CheckingForIntegrityMismatch);
821 if (existingResource->mustRefetchDueToIntegrityMetadata(fetchRequest)) { 819 if (existingResource->mustRefetchDueToIntegrityMetadata(fetchRequest)) {
822 RecordSriResourceIntegrityMismatchEvent(RefetchDueToIntegrityMismatch); 820 RecordSriResourceIntegrityMismatchEvent(RefetchDueToIntegrityMismatch);
823 return Reload; 821 return Reload;
824 } 822 }
825 823
826 // Service Worker's CORS fallback message must not be cached. 824 // Service Worker's CORS fallback message must not be cached.
827 if (existingResource->response().wasFallbackRequiredByServiceWorker()) 825 if (existingResource->response().wasFallbackRequiredByServiceWorker())
828 return Reload; 826 return Reload;
829 827
830 // We already have a preload going for this URL.
831 if (fetchRequest.isSpeculativePreload() && existingResource->isPreloaded())
832 return Use;
833
834 // If the same URL has been loaded as a different type, we need to reload. 828 // If the same URL has been loaded as a different type, we need to reload.
835 if (existingResource->getType() != type) { 829 if (existingResource->getType() != type) {
836 // FIXME: If existingResource is a Preload and the new type is LinkPrefetch 830 // FIXME: If existingResource is a Preload and the new type is LinkPrefetch
837 // We really should discard the new prefetch since the preload has more 831 // We really should discard the new prefetch since the preload has more
838 // specific type information! crbug.com/379893 832 // specific type information! crbug.com/379893
839 // fast/dom/HTMLLinkElement/link-and-subresource-test hits this case. 833 // fast/dom/HTMLLinkElement/link-and-subresource-test hits this case.
840 RESOURCE_LOADING_DVLOG(1) << "ResourceFetcher::determineRevalidationPolicy " 834 RESOURCE_LOADING_DVLOG(1) << "ResourceFetcher::determineRevalidationPolicy "
841 "reloading due to type mismatch."; 835 "reloading due to type mismatch.";
842 return Reload; 836 return Reload;
843 } 837 }
844 838
839 // We already have a preload going for this URL.
840 if (fetchRequest.isSpeculativePreload() && existingResource->isPreloaded())
841 return Use;
842
845 // Do not load from cache if images are not enabled. There are two general 843 // Do not load from cache if images are not enabled. There are two general
846 // cases: 844 // cases:
847 // 845 //
848 // 1. Images are disabled. Don't ever load images, even if the image is cached 846 // 1. Images are disabled. Don't ever load images, even if the image is cached
849 // or it is a data: url. In this case, we "Reload" the image, then defer it 847 // or it is a data: url. In this case, we "Reload" the image, then defer it
850 // with resourceNeedsLoad() so that it never actually goes to the network. 848 // with resourceNeedsLoad() so that it never actually goes to the network.
851 // 849 //
852 // 2. Images are enabled, but not loaded automatically. In this case, we will 850 // 2. Images are enabled, but not loaded automatically. In this case, we will
853 // Use cached resources or data: urls, but will similarly fall back to a 851 // Use cached resources or data: urls, but will similarly fall back to a
854 // deferred network load if we don't have the data available without a network 852 // deferred network load if we don't have the data available without a network
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 visitor->trace(m_context); 1541 visitor->trace(m_context);
1544 visitor->trace(m_archive); 1542 visitor->trace(m_archive);
1545 visitor->trace(m_loaders); 1543 visitor->trace(m_loaders);
1546 visitor->trace(m_nonBlockingLoaders); 1544 visitor->trace(m_nonBlockingLoaders);
1547 visitor->trace(m_documentResources); 1545 visitor->trace(m_documentResources);
1548 visitor->trace(m_preloads); 1546 visitor->trace(m_preloads);
1549 visitor->trace(m_resourceTimingInfoMap); 1547 visitor->trace(m_resourceTimingInfoMap);
1550 } 1548 }
1551 1549
1552 } // namespace blink 1550 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698