Chromium Code Reviews| 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 rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
| 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 21 matching lines...) Expand all Loading... | |
| 32 #include "core/fetch/ResourceClientWalker.h" | 32 #include "core/fetch/ResourceClientWalker.h" |
| 33 #include "core/fetch/ResourceFetcher.h" | 33 #include "core/fetch/ResourceFetcher.h" |
| 34 #include "core/fetch/ResourceLoader.h" | 34 #include "core/fetch/ResourceLoader.h" |
| 35 #include "core/fetch/ResourcePtr.h" | 35 #include "core/fetch/ResourcePtr.h" |
| 36 #include "core/inspector/InspectorInstrumentation.h" | 36 #include "core/inspector/InspectorInstrumentation.h" |
| 37 #include "platform/Logging.h" | 37 #include "platform/Logging.h" |
| 38 #include "platform/SharedBuffer.h" | 38 #include "platform/SharedBuffer.h" |
| 39 #include "platform/TraceEvent.h" | 39 #include "platform/TraceEvent.h" |
| 40 #include "platform/weborigin/KURL.h" | 40 #include "platform/weborigin/KURL.h" |
| 41 #include "public/platform/Platform.h" | 41 #include "public/platform/Platform.h" |
| 42 #include "public/platform/WebProcessMemoryDump.h" | |
| 42 #include "wtf/CurrentTime.h" | 43 #include "wtf/CurrentTime.h" |
| 43 #include "wtf/MathExtras.h" | 44 #include "wtf/MathExtras.h" |
| 44 #include "wtf/StdLibExtras.h" | 45 #include "wtf/StdLibExtras.h" |
| 45 #include "wtf/Vector.h" | 46 #include "wtf/Vector.h" |
| 46 #include "wtf/text/CString.h" | 47 #include "wtf/text/CString.h" |
| 47 | 48 |
| 48 using namespace WTF; | 49 using namespace WTF; |
| 49 | 50 |
| 50 namespace blink { | 51 namespace blink { |
| 51 | 52 |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 710 // Prevent the case when there are clients waiting but no callback scheduled . | 711 // Prevent the case when there are clients waiting but no callback scheduled . |
| 711 ASSERT(m_clientsAwaitingCallback.isEmpty() || scheduled); | 712 ASSERT(m_clientsAwaitingCallback.isEmpty() || scheduled); |
| 712 } | 713 } |
| 713 | 714 |
| 714 void Resource::prune() | 715 void Resource::prune() |
| 715 { | 716 { |
| 716 destroyDecodedDataIfPossible(); | 717 destroyDecodedDataIfPossible(); |
| 717 unlock(); | 718 unlock(); |
| 718 } | 719 } |
| 719 | 720 |
| 721 void Resource::onMemoryDump(WebProcessMemoryDump* memoryDump) const | |
| 722 { | |
| 723 const String dumpName = getMemoryDumpName(); | |
| 724 WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpNam e); | |
| 725 dump->AddScalar("encoded_size", "bytes", m_encodedSize); | |
| 726 dump->AddScalar("decoded_size", "bytes", m_decodedSize); | |
| 727 if (hasClients()) { | |
|
haraken
2015/09/28 14:54:02
This condition is not quite right. Even if the Res
ssid
2015/09/28 16:24:38
Yes I had checked the MemoryCache::pruneDeadResour
| |
| 728 dump->AddScalar("live_size", "bytes", m_encodedSize); | |
| 729 } else { | |
| 730 dump->AddScalar("dead_size", "bytes", m_encodedSize); | |
| 731 } | |
| 732 | |
| 733 size_t totalSize = encodedSize() + overheadSize(); | |
| 734 dump->AddScalar("purged_size", "bytes", wasPurged() ? totalSize : 0); | |
| 735 if (m_data) { | |
| 736 const bool purgeable = m_data->isLocked() && !wasPurged(); | |
|
haraken
2015/09/28 14:54:02
Can't we just use isPurgeable()?
ssid
2015/09/28 16:24:38
Sorry didn't know this existed. There are so many
| |
| 737 dump->AddScalar("purgeable_size", "bytes", purgeable ? 0 : totalSize); | |
| 738 m_data->onMemoryDump(dumpName, memoryDump); | |
| 739 } | |
| 740 | |
| 741 const String overheadName = dumpName + "/overhead"; | |
| 742 WebMemoryAllocatorDump* overheadDump = memoryDump->createMemoryAllocatorDump (overheadName); | |
| 743 overheadDump->AddScalar("size", "bytes", overheadSize()); | |
| 744 memoryDump->AddSuballocation(overheadDump->guid(), String(WTF::Partitions::a llocatorPoolNameForTracing())); | |
| 745 } | |
| 746 | |
| 747 String Resource::getMemoryDumpName() const | |
| 748 { | |
| 749 return String::format("web_cache/%s_resources/%ld", resourceTypeToString(typ e(), options().initiatorInfo), m_identifier); | |
| 750 } | |
| 751 | |
| 720 void Resource::setResourceToRevalidate(Resource* resource) | 752 void Resource::setResourceToRevalidate(Resource* resource) |
| 721 { | 753 { |
| 722 ASSERT(resource); | 754 ASSERT(resource); |
| 723 ASSERT(!m_resourceToRevalidate); | 755 ASSERT(!m_resourceToRevalidate); |
| 724 ASSERT(resource != this); | 756 ASSERT(resource != this); |
| 725 ASSERT(m_handlesToRevalidate.isEmpty()); | 757 ASSERT(m_handlesToRevalidate.isEmpty()); |
| 726 ASSERT(resource->type() == type()); | 758 ASSERT(resource->type() == type()); |
| 727 | 759 |
| 728 WTF_LOG(ResourceLoading, "Resource %p setResourceToRevalidate %p", this, res ource); | 760 WTF_LOG(ResourceLoading, "Resource %p setResourceToRevalidate %p", this, res ource); |
| 729 | 761 |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1093 return "ImportResource"; | 1125 return "ImportResource"; |
| 1094 case Resource::Media: | 1126 case Resource::Media: |
| 1095 return "Media"; | 1127 return "Media"; |
| 1096 } | 1128 } |
| 1097 ASSERT_NOT_REACHED(); | 1129 ASSERT_NOT_REACHED(); |
| 1098 return "Unknown"; | 1130 return "Unknown"; |
| 1099 } | 1131 } |
| 1100 #endif // !LOG_DISABLED | 1132 #endif // !LOG_DISABLED |
| 1101 | 1133 |
| 1102 } // namespace blink | 1134 } // namespace blink |
| OLD | NEW |