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

Side by Side Diff: Source/core/fetch/ResourceFetcher.cpp

Issue 1287073007: Reuse images already loaded in the current document more aggressively (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/fetch/ResourceFetcherTest.cpp » ('j') | 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 rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 if (request.cachePolicy() == ResourceRequestCachePolicy::ReloadBypassingCach e) 565 if (request.cachePolicy() == ResourceRequestCachePolicy::ReloadBypassingCach e)
566 return Reload; 566 return Reload;
567 567
568 if (!fetchRequest.options().canReuseRequest(existingResource->options())) 568 if (!fetchRequest.options().canReuseRequest(existingResource->options()))
569 return Reload; 569 return Reload;
570 570
571 // Always use preloads. 571 // Always use preloads.
572 if (existingResource->isPreloaded()) 572 if (existingResource->isPreloaded())
573 return Use; 573 return Use;
574 574
575 // List of available images logic allows images to be re-used without cache validation. We restrict this only to images
576 // from memory cache which are the same as the version in the current docume nt.
577 if (type == Resource::Image && existingResource == cachedResource(request.ur l()))
Nate Chapin 2015/08/14 23:33:39 Moved here to make it equivalent to preloading. I'
578 return Use;
579
575 // Defer to the browser process cache for Vary header handling. 580 // Defer to the browser process cache for Vary header handling.
576 if (existingResource->hasVaryHeader()) 581 if (existingResource->hasVaryHeader())
577 return Reload; 582 return Reload;
578 583
579 // CachePolicyHistoryBuffer uses the cache no matter what. 584 // CachePolicyHistoryBuffer uses the cache no matter what.
580 CachePolicy cachePolicy = context().cachePolicy(); 585 CachePolicy cachePolicy = context().cachePolicy();
581 if (cachePolicy == CachePolicyHistoryBuffer) 586 if (cachePolicy == CachePolicyHistoryBuffer)
582 return Use; 587 return Use;
583 588
584 // Don't reuse resources with Cache-control: no-store. 589 // Don't reuse resources with Cache-control: no-store.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to CachePolicyReload."); 630 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to CachePolicyReload.");
626 return Reload; 631 return Reload;
627 } 632 }
628 633
629 // We'll try to reload the resource if it failed last time. 634 // We'll try to reload the resource if it failed last time.
630 if (existingResource->errorOccurred()) { 635 if (existingResource->errorOccurred()) {
631 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicye reloading due to resource being in the error state"); 636 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicye reloading due to resource being in the error state");
632 return Reload; 637 return Reload;
633 } 638 }
634 639
635 // List of available images logic allows images to be re-used without cache validation. We restrict this only to images
636 // from memory cache which are the same as the version in the current docume nt.
637 if (type == Resource::Image && existingResource == cachedResource(request.ur l()))
638 return Use;
639
640 // If any of the redirects in the chain to loading the resource were not cac heable, we cannot reuse our cached resource. 640 // If any of the redirects in the chain to loading the resource were not cac heable, we cannot reuse our cached resource.
641 if (!existingResource->canReuseRedirectChain()) { 641 if (!existingResource->canReuseRedirectChain()) {
642 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to an uncacheable redirect"); 642 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to an uncacheable redirect");
643 return Reload; 643 return Reload;
644 } 644 }
645 645
646 // Check if the cache headers requires us to revalidate (cache expiration fo r example). 646 // Check if the cache headers requires us to revalidate (cache expiration fo r example).
647 if (cachePolicy == CachePolicyRevalidate || existingResource->mustRevalidate DueToCacheHeaders() 647 if (cachePolicy == CachePolicyRevalidate || existingResource->mustRevalidate DueToCacheHeaders()
648 || request.cacheControlContainsNoCache()) { 648 || request.cacheControlContainsNoCache()) {
649 // See if the resource has usable ETag or Last-modified headers. 649 // See if the resource has usable ETag or Last-modified headers.
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 visitor->trace(m_archiveResourceCollection); 1103 visitor->trace(m_archiveResourceCollection);
1104 visitor->trace(m_loaders); 1104 visitor->trace(m_loaders);
1105 visitor->trace(m_nonBlockingLoaders); 1105 visitor->trace(m_nonBlockingLoaders);
1106 #if ENABLE(OILPAN) 1106 #if ENABLE(OILPAN)
1107 visitor->trace(m_preloads); 1107 visitor->trace(m_preloads);
1108 visitor->trace(m_resourceTimingInfoMap); 1108 visitor->trace(m_resourceTimingInfoMap);
1109 #endif 1109 #endif
1110 } 1110 }
1111 1111
1112 } 1112 }
OLDNEW
« no previous file with comments | « no previous file | Source/core/fetch/ResourceFetcherTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698