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

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 // Defer to the browser process cache for Vary header handling.
576 if (existingResource->hasVaryHeader())
577 return Reload;
578
579 // CachePolicyHistoryBuffer uses the cache no matter what. 575 // CachePolicyHistoryBuffer uses the cache no matter what.
580 CachePolicy cachePolicy = context().cachePolicy(); 576 CachePolicy cachePolicy = context().cachePolicy();
581 if (cachePolicy == CachePolicyHistoryBuffer) 577 if (cachePolicy == CachePolicyHistoryBuffer)
582 return Use; 578 return Use;
583 579
584 // Don't reuse resources with Cache-control: no-store. 580 // Don't reuse resources with Cache-control: no-store.
585 if (existingResource->hasCacheControlNoStoreHeader()) { 581 if (existingResource->hasCacheControlNoStoreHeader()) {
586 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to Cache-control: no-store."); 582 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to Cache-control: no-store.");
587 return Reload; 583 return Reload;
588 } 584 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 if (existingResource->errorOccurred()) { 626 if (existingResource->errorOccurred()) {
631 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicye reloading due to resource being in the error state"); 627 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicye reloading due to resource being in the error state");
632 return Reload; 628 return Reload;
633 } 629 }
634 630
635 // List of available images logic allows images to be re-used without cache validation. We restrict this only to images 631 // 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. 632 // 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())) 633 if (type == Resource::Image && existingResource == cachedResource(request.ur l()))
638 return Use; 634 return Use;
639 635
636 // Defer to the browser process cache for Vary header handling.
637 if (existingResource->hasVaryHeader())
638 return Reload;
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