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 1267783003: Reload All Images Using Load Image on Lo-Fi Image (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 2 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 | « Source/core/fetch/ResourceFetcher.h ('k') | Source/web/WebLocalFrameImpl.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 13 matching lines...) Expand all
24 pages from the web. It has a memory cache for these objects. 24 pages from the web. It has a memory cache for these objects.
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/fetch/ResourceFetcher.h" 28 #include "core/fetch/ResourceFetcher.h"
29 29
30 #include "bindings/core/v8/V8DOMActivityLogger.h" 30 #include "bindings/core/v8/V8DOMActivityLogger.h"
31 #include "core/fetch/CrossOriginAccessControl.h" 31 #include "core/fetch/CrossOriginAccessControl.h"
32 #include "core/fetch/FetchContext.h" 32 #include "core/fetch/FetchContext.h"
33 #include "core/fetch/FetchInitiatorTypeNames.h" 33 #include "core/fetch/FetchInitiatorTypeNames.h"
34 #include "core/fetch/ImageResource.h"
34 #include "core/fetch/MemoryCache.h" 35 #include "core/fetch/MemoryCache.h"
35 #include "core/fetch/ResourceLoader.h" 36 #include "core/fetch/ResourceLoader.h"
36 #include "core/fetch/ResourceLoaderSet.h" 37 #include "core/fetch/ResourceLoaderSet.h"
37 #include "core/fetch/UniqueIdentifier.h" 38 #include "core/fetch/UniqueIdentifier.h"
38 #include "platform/Logging.h" 39 #include "platform/Logging.h"
39 #include "platform/RuntimeEnabledFeatures.h" 40 #include "platform/RuntimeEnabledFeatures.h"
40 #include "platform/TraceEvent.h" 41 #include "platform/TraceEvent.h"
41 #include "platform/TracedValue.h" 42 #include "platform/TracedValue.h"
42 #include "platform/mhtml/ArchiveResource.h" 43 #include "platform/mhtml/ArchiveResource.h"
43 #include "platform/mhtml/ArchiveResourceCollection.h" 44 #include "platform/mhtml/ArchiveResourceCollection.h"
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 bool ResourceFetcher::clientDefersImage(const KURL& url) const 700 bool ResourceFetcher::clientDefersImage(const KURL& url) const
700 { 701 {
701 return !context().allowImage(m_imagesEnabled, url); 702 return !context().allowImage(m_imagesEnabled, url);
702 } 703 }
703 704
704 bool ResourceFetcher::shouldDeferImageLoad(const KURL& url) const 705 bool ResourceFetcher::shouldDeferImageLoad(const KURL& url) const
705 { 706 {
706 return clientDefersImage(url) || !m_autoLoadImages; 707 return clientDefersImage(url) || !m_autoLoadImages;
707 } 708 }
708 709
710 void ResourceFetcher::reloadLoFiImages()
711 {
712 for (const auto& documentResource : m_documentResources) {
713 Resource* resource = documentResource.value.get();
714 if (resource->isImage() && resource->response().httpHeaderField("chrome- proxy").contains("q=low")) {
715 ImageResource* imageResource = toImageResource(resource);
716 imageResource->mutableResourceRequest().setCachePolicy(ResourceReque stCachePolicy::ReloadBypassingCache);
717 imageResource->clearLoader();
718 imageResource->cacheHandler()->clearCachedMetadata();
719 imageResource->load(this, defaultResourceOptions());
720 }
721 }
722 }
723
709 void ResourceFetcher::reloadImagesIfNotDeferred() 724 void ResourceFetcher::reloadImagesIfNotDeferred()
710 { 725 {
711 for (const auto& documentResource : m_documentResources) { 726 for (const auto& documentResource : m_documentResources) {
712 Resource* resource = documentResource.value.get(); 727 Resource* resource = documentResource.value.get();
713 if (resource->type() == Resource::Image && resource->stillNeedsLoad() && !clientDefersImage(resource->url())) 728 if (resource->type() == Resource::Image && resource->stillNeedsLoad() && !clientDefersImage(resource->url()))
714 const_cast<Resource*>(resource)->load(this, defaultResourceOptions() ); 729 const_cast<Resource*>(resource)->load(this, defaultResourceOptions() );
715 } 730 }
716 } 731 }
717 732
718 void ResourceFetcher::redirectReceived(Resource* resource, const ResourceRespons e& redirectResponse) 733 void ResourceFetcher::redirectReceived(Resource* resource, const ResourceRespons e& redirectResponse)
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 visitor->trace(m_archiveResourceCollection); 1116 visitor->trace(m_archiveResourceCollection);
1102 visitor->trace(m_loaders); 1117 visitor->trace(m_loaders);
1103 visitor->trace(m_nonBlockingLoaders); 1118 visitor->trace(m_nonBlockingLoaders);
1104 #if ENABLE(OILPAN) 1119 #if ENABLE(OILPAN)
1105 visitor->trace(m_preloads); 1120 visitor->trace(m_preloads);
1106 visitor->trace(m_resourceTimingInfoMap); 1121 visitor->trace(m_resourceTimingInfoMap);
1107 #endif 1122 #endif
1108 } 1123 }
1109 1124
1110 } 1125 }
OLDNEW
« no previous file with comments | « Source/core/fetch/ResourceFetcher.h ('k') | Source/web/WebLocalFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698