Chromium Code Reviews

Side by Side Diff: third_party/WebKit/Source/core/fetch/Resource.cpp

Issue 2393113002: ImageResource: Reset the encoded image size after receiving all data (Closed)
Patch Set: Remove unnecessary change Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « third_party/WebKit/Source/core/fetch/Resource.h ('k') | 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) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
7 rights reserved. 7 rights reserved.
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 285 matching lines...)
296 for (const auto& resource : resources) 296 for (const auto& resource : resources)
297 resource->finishPendingClients(); 297 resource->finishPendingClients();
298 } 298 }
299 299
300 Resource::Resource(const ResourceRequest& request, 300 Resource::Resource(const ResourceRequest& request,
301 Type type, 301 Type type,
302 const ResourceLoaderOptions& options) 302 const ResourceLoaderOptions& options)
303 : m_loadFinishTime(0), 303 : m_loadFinishTime(0),
304 m_identifier(0), 304 m_identifier(0),
305 m_encodedSize(0), 305 m_encodedSize(0),
306 m_encodedSizeMemoryUsage(0),
306 m_decodedSize(0), 307 m_decodedSize(0),
307 m_overheadSize(calculateOverheadSize()), 308 m_overheadSize(calculateOverheadSize()),
308 m_preloadCount(0), 309 m_preloadCount(0),
309 m_preloadDiscoveryTime(0.0), 310 m_preloadDiscoveryTime(0.0),
310 m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()), 311 m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()),
311 m_preloadResult(PreloadNotReferenced), 312 m_preloadResult(PreloadNotReferenced),
312 m_type(type), 313 m_type(type),
313 m_status(NotStarted), 314 m_status(NotStarted),
314 m_needsSynchronousCacheHit(false), 315 m_needsSynchronousCacheHit(false),
315 m_linkPreload(false), 316 m_linkPreload(false),
(...skipping 468 matching lines...)
784 void Resource::setDecodedSize(size_t decodedSize) { 785 void Resource::setDecodedSize(size_t decodedSize) {
785 if (decodedSize == m_decodedSize) 786 if (decodedSize == m_decodedSize)
786 return; 787 return;
787 size_t oldSize = size(); 788 size_t oldSize = size();
788 m_decodedSize = decodedSize; 789 m_decodedSize = decodedSize;
789 memoryCache()->update(this, oldSize, size()); 790 memoryCache()->update(this, oldSize, size());
790 memoryCache()->updateDecodedResource(this, UpdateForPropertyChange); 791 memoryCache()->updateDecodedResource(this, UpdateForPropertyChange);
791 } 792 }
792 793
793 void Resource::setEncodedSize(size_t encodedSize) { 794 void Resource::setEncodedSize(size_t encodedSize) {
794 if (encodedSize == m_encodedSize) 795 if (encodedSize == m_encodedSize && encodedSize == m_encodedSizeMemoryUsage)
795 return; 796 return;
796 size_t oldSize = size(); 797 size_t oldSize = size();
797 m_encodedSize = encodedSize; 798 m_encodedSize = encodedSize;
799 m_encodedSizeMemoryUsage = encodedSize;
798 memoryCache()->update(this, oldSize, size()); 800 memoryCache()->update(this, oldSize, size());
799 } 801 }
800 802
803 void Resource::setEncodedSizeMemoryUsage(size_t encodedSize) {
yhirano 2016/10/14 09:20:00 Can you remove this function, and set m_encodedSiz
hajimehoshi 2016/10/14 09:29:51 Hmm, your suggestion would affect other resources
804 if (encodedSize == m_encodedSizeMemoryUsage)
805 return;
806 size_t oldSize = size();
807 m_encodedSizeMemoryUsage = encodedSize;
808 memoryCache()->update(this, oldSize, size());
yhirano 2016/10/14 09:20:00 This is now not needed, right?
hajimehoshi 2016/10/14 09:29:51 Done.
809 }
810
801 void Resource::didAccessDecodedData() { 811 void Resource::didAccessDecodedData() {
802 memoryCache()->updateDecodedResource(this, UpdateForAccess); 812 memoryCache()->updateDecodedResource(this, UpdateForAccess);
803 memoryCache()->prune(); 813 memoryCache()->prune();
804 } 814 }
805 815
806 void Resource::finishPendingClients() { 816 void Resource::finishPendingClients() {
807 // We're going to notify clients one by one. It is simple if the client does 817 // We're going to notify clients one by one. It is simple if the client does
808 // nothing. However there are a couple other things that can happen. 818 // nothing. However there are a couple other things that can happen.
809 // 819 //
810 // 1. Clients can be added during the loop. Make sure they are not processed. 820 // 1. Clients can be added during the loop. Make sure they are not processed.
(...skipping 41 matching lines...)
852 } 862 }
853 863
854 void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, 864 void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail,
855 WebProcessMemoryDump* memoryDump) const { 865 WebProcessMemoryDump* memoryDump) const {
856 static const size_t kMaxURLReportLength = 128; 866 static const size_t kMaxURLReportLength = 128;
857 static const int kMaxResourceClientToShowInMemoryInfra = 10; 867 static const int kMaxResourceClientToShowInMemoryInfra = 10;
858 868
859 const String dumpName = getMemoryDumpName(); 869 const String dumpName = getMemoryDumpName();
860 WebMemoryAllocatorDump* dump = 870 WebMemoryAllocatorDump* dump =
861 memoryDump->createMemoryAllocatorDump(dumpName); 871 memoryDump->createMemoryAllocatorDump(dumpName);
862 dump->addScalar("encoded_size", "bytes", m_encodedSize); 872 dump->addScalar("encoded_size", "bytes", m_encodedSizeMemoryUsage);
863 if (hasClientsOrObservers()) 873 if (hasClientsOrObservers())
864 dump->addScalar("live_size", "bytes", m_encodedSize); 874 dump->addScalar("live_size", "bytes", m_encodedSizeMemoryUsage);
865 else 875 else
866 dump->addScalar("dead_size", "bytes", m_encodedSize); 876 dump->addScalar("dead_size", "bytes", m_encodedSizeMemoryUsage);
867 877
868 if (m_data) 878 if (m_data)
869 m_data->onMemoryDump(dumpName, memoryDump); 879 m_data->onMemoryDump(dumpName, memoryDump);
870 880
871 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) { 881 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) {
872 String urlToReport = url().getString(); 882 String urlToReport = url().getString();
873 if (urlToReport.length() > kMaxURLReportLength) { 883 if (urlToReport.length() > kMaxURLReportLength) {
874 urlToReport.truncate(kMaxURLReportLength); 884 urlToReport.truncate(kMaxURLReportLength);
875 urlToReport = urlToReport + "..."; 885 urlToReport = urlToReport + "...";
876 } 886 }
(...skipping 219 matching lines...)
1096 case Resource::TextTrack: 1106 case Resource::TextTrack:
1097 case Resource::Media: 1107 case Resource::Media:
1098 case Resource::Manifest: 1108 case Resource::Manifest:
1099 return false; 1109 return false;
1100 } 1110 }
1101 NOTREACHED(); 1111 NOTREACHED();
1102 return false; 1112 return false;
1103 } 1113 }
1104 1114
1105 } // namespace blink 1115 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/Resource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine