| 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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 for (const auto& resource : resources) | 297 for (const auto& resource : resources) |
| 298 resource->finishPendingClients(); | 298 resource->finishPendingClients(); |
| 299 } | 299 } |
| 300 | 300 |
| 301 Resource::Resource(const ResourceRequest& request, | 301 Resource::Resource(const ResourceRequest& request, |
| 302 Type type, | 302 Type type, |
| 303 const ResourceLoaderOptions& options) | 303 const ResourceLoaderOptions& options) |
| 304 : m_loadFinishTime(0), | 304 : m_loadFinishTime(0), |
| 305 m_identifier(0), | 305 m_identifier(0), |
| 306 m_encodedSize(0), | 306 m_encodedSize(0), |
| 307 m_encodedSizeMemoryUsage(0), |
| 307 m_decodedSize(0), | 308 m_decodedSize(0), |
| 308 m_overheadSize(calculateOverheadSize()), | 309 m_overheadSize(calculateOverheadSize()), |
| 309 m_preloadCount(0), | 310 m_preloadCount(0), |
| 310 m_preloadDiscoveryTime(0.0), | 311 m_preloadDiscoveryTime(0.0), |
| 311 m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()), | 312 m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()), |
| 312 m_preloadResult(PreloadNotReferenced), | 313 m_preloadResult(PreloadNotReferenced), |
| 313 m_type(type), | 314 m_type(type), |
| 314 m_status(NotStarted), | 315 m_status(NotStarted), |
| 315 m_needsSynchronousCacheHit(false), | 316 m_needsSynchronousCacheHit(false), |
| 316 m_linkPreload(false), | 317 m_linkPreload(false), |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 void Resource::setDecodedSize(size_t decodedSize) { | 787 void Resource::setDecodedSize(size_t decodedSize) { |
| 787 if (decodedSize == m_decodedSize) | 788 if (decodedSize == m_decodedSize) |
| 788 return; | 789 return; |
| 789 size_t oldSize = size(); | 790 size_t oldSize = size(); |
| 790 m_decodedSize = decodedSize; | 791 m_decodedSize = decodedSize; |
| 791 memoryCache()->update(this, oldSize, size()); | 792 memoryCache()->update(this, oldSize, size()); |
| 792 memoryCache()->updateDecodedResource(this, UpdateForPropertyChange); | 793 memoryCache()->updateDecodedResource(this, UpdateForPropertyChange); |
| 793 } | 794 } |
| 794 | 795 |
| 795 void Resource::setEncodedSize(size_t encodedSize) { | 796 void Resource::setEncodedSize(size_t encodedSize) { |
| 796 if (encodedSize == m_encodedSize) | 797 if (encodedSize == m_encodedSize && encodedSize == m_encodedSizeMemoryUsage) |
| 797 return; | 798 return; |
| 798 size_t oldSize = size(); | 799 size_t oldSize = size(); |
| 799 m_encodedSize = encodedSize; | 800 m_encodedSize = encodedSize; |
| 801 m_encodedSizeMemoryUsage = encodedSize; |
| 800 memoryCache()->update(this, oldSize, size()); | 802 memoryCache()->update(this, oldSize, size()); |
| 801 } | 803 } |
| 802 | 804 |
| 805 void Resource::setEncodedSizeMemoryUsage(size_t encodedSize) { |
| 806 m_encodedSizeMemoryUsage = encodedSize; |
| 807 } |
| 808 |
| 803 void Resource::didAccessDecodedData() { | 809 void Resource::didAccessDecodedData() { |
| 804 memoryCache()->updateDecodedResource(this, UpdateForAccess); | 810 memoryCache()->updateDecodedResource(this, UpdateForAccess); |
| 805 memoryCache()->prune(); | 811 memoryCache()->prune(); |
| 806 } | 812 } |
| 807 | 813 |
| 808 void Resource::finishPendingClients() { | 814 void Resource::finishPendingClients() { |
| 809 // We're going to notify clients one by one. It is simple if the client does | 815 // We're going to notify clients one by one. It is simple if the client does |
| 810 // nothing. However there are a couple other things that can happen. | 816 // nothing. However there are a couple other things that can happen. |
| 811 // | 817 // |
| 812 // 1. Clients can be added during the loop. Make sure they are not processed. | 818 // 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... |
| 854 } | 860 } |
| 855 | 861 |
| 856 void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, | 862 void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, |
| 857 WebProcessMemoryDump* memoryDump) const { | 863 WebProcessMemoryDump* memoryDump) const { |
| 858 static const size_t kMaxURLReportLength = 128; | 864 static const size_t kMaxURLReportLength = 128; |
| 859 static const int kMaxResourceClientToShowInMemoryInfra = 10; | 865 static const int kMaxResourceClientToShowInMemoryInfra = 10; |
| 860 | 866 |
| 861 const String dumpName = getMemoryDumpName(); | 867 const String dumpName = getMemoryDumpName(); |
| 862 WebMemoryAllocatorDump* dump = | 868 WebMemoryAllocatorDump* dump = |
| 863 memoryDump->createMemoryAllocatorDump(dumpName); | 869 memoryDump->createMemoryAllocatorDump(dumpName); |
| 864 dump->addScalar("encoded_size", "bytes", m_encodedSize); | 870 dump->addScalar("encoded_size", "bytes", m_encodedSizeMemoryUsage); |
| 865 if (hasClientsOrObservers()) | 871 if (hasClientsOrObservers()) |
| 866 dump->addScalar("live_size", "bytes", m_encodedSize); | 872 dump->addScalar("live_size", "bytes", m_encodedSizeMemoryUsage); |
| 867 else | 873 else |
| 868 dump->addScalar("dead_size", "bytes", m_encodedSize); | 874 dump->addScalar("dead_size", "bytes", m_encodedSizeMemoryUsage); |
| 869 | 875 |
| 870 if (m_data) | 876 if (m_data) |
| 871 m_data->onMemoryDump(dumpName, memoryDump); | 877 m_data->onMemoryDump(dumpName, memoryDump); |
| 872 | 878 |
| 873 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) { | 879 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) { |
| 874 String urlToReport = url().getString(); | 880 String urlToReport = url().getString(); |
| 875 if (urlToReport.length() > kMaxURLReportLength) { | 881 if (urlToReport.length() > kMaxURLReportLength) { |
| 876 urlToReport.truncate(kMaxURLReportLength); | 882 urlToReport.truncate(kMaxURLReportLength); |
| 877 urlToReport = urlToReport + "..."; | 883 urlToReport = urlToReport + "..."; |
| 878 } | 884 } |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 case Resource::TextTrack: | 1104 case Resource::TextTrack: |
| 1099 case Resource::Media: | 1105 case Resource::Media: |
| 1100 case Resource::Manifest: | 1106 case Resource::Manifest: |
| 1101 return false; | 1107 return false; |
| 1102 } | 1108 } |
| 1103 NOTREACHED(); | 1109 NOTREACHED(); |
| 1104 return false; | 1110 return false; |
| 1105 } | 1111 } |
| 1106 | 1112 |
| 1107 } // namespace blink | 1113 } // namespace blink |
| OLD | NEW |