| OLD | NEW |
| 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...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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) { |
| 804 m_encodedSizeMemoryUsage = encodedSize; |
| 805 } |
| 806 |
| 801 void Resource::didAccessDecodedData() { | 807 void Resource::didAccessDecodedData() { |
| 802 memoryCache()->updateDecodedResource(this, UpdateForAccess); | 808 memoryCache()->updateDecodedResource(this, UpdateForAccess); |
| 803 memoryCache()->prune(); | 809 memoryCache()->prune(); |
| 804 } | 810 } |
| 805 | 811 |
| 806 void Resource::finishPendingClients() { | 812 void Resource::finishPendingClients() { |
| 807 // We're going to notify clients one by one. It is simple if the client does | 813 // 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. | 814 // nothing. However there are a couple other things that can happen. |
| 809 // | 815 // |
| 810 // 1. Clients can be added during the loop. Make sure they are not processed. | 816 // 1. Clients can be added during the loop. Make sure they are not processed. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 } | 858 } |
| 853 | 859 |
| 854 void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, | 860 void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, |
| 855 WebProcessMemoryDump* memoryDump) const { | 861 WebProcessMemoryDump* memoryDump) const { |
| 856 static const size_t kMaxURLReportLength = 128; | 862 static const size_t kMaxURLReportLength = 128; |
| 857 static const int kMaxResourceClientToShowInMemoryInfra = 10; | 863 static const int kMaxResourceClientToShowInMemoryInfra = 10; |
| 858 | 864 |
| 859 const String dumpName = getMemoryDumpName(); | 865 const String dumpName = getMemoryDumpName(); |
| 860 WebMemoryAllocatorDump* dump = | 866 WebMemoryAllocatorDump* dump = |
| 861 memoryDump->createMemoryAllocatorDump(dumpName); | 867 memoryDump->createMemoryAllocatorDump(dumpName); |
| 862 dump->addScalar("encoded_size", "bytes", m_encodedSize); | 868 dump->addScalar("encoded_size", "bytes", m_encodedSizeMemoryUsage); |
| 863 if (hasClientsOrObservers()) | 869 if (hasClientsOrObservers()) |
| 864 dump->addScalar("live_size", "bytes", m_encodedSize); | 870 dump->addScalar("live_size", "bytes", m_encodedSizeMemoryUsage); |
| 865 else | 871 else |
| 866 dump->addScalar("dead_size", "bytes", m_encodedSize); | 872 dump->addScalar("dead_size", "bytes", m_encodedSizeMemoryUsage); |
| 867 | 873 |
| 868 if (m_data) | 874 if (m_data) |
| 869 m_data->onMemoryDump(dumpName, memoryDump); | 875 m_data->onMemoryDump(dumpName, memoryDump); |
| 870 | 876 |
| 871 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) { | 877 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) { |
| 872 String urlToReport = url().getString(); | 878 String urlToReport = url().getString(); |
| 873 if (urlToReport.length() > kMaxURLReportLength) { | 879 if (urlToReport.length() > kMaxURLReportLength) { |
| 874 urlToReport.truncate(kMaxURLReportLength); | 880 urlToReport.truncate(kMaxURLReportLength); |
| 875 urlToReport = urlToReport + "..."; | 881 urlToReport = urlToReport + "..."; |
| 876 } | 882 } |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 case Resource::TextTrack: | 1102 case Resource::TextTrack: |
| 1097 case Resource::Media: | 1103 case Resource::Media: |
| 1098 case Resource::Manifest: | 1104 case Resource::Manifest: |
| 1099 return false; | 1105 return false; |
| 1100 } | 1106 } |
| 1101 NOTREACHED(); | 1107 NOTREACHED(); |
| 1102 return false; | 1108 return false; |
| 1103 } | 1109 } |
| 1104 | 1110 |
| 1105 } // namespace blink | 1111 } // namespace blink |
| OLD | NEW |