Chromium Code Reviews| Index: third_party/WebKit/Source/core/fetch/Resource.cpp |
| diff --git a/third_party/WebKit/Source/core/fetch/Resource.cpp b/third_party/WebKit/Source/core/fetch/Resource.cpp |
| index f1aaf35ded75c5e9d21ed0548344ec9bd3c24798..b6417f2b8e2b310d800b928052340fc7205a7091 100644 |
| --- a/third_party/WebKit/Source/core/fetch/Resource.cpp |
| +++ b/third_party/WebKit/Source/core/fetch/Resource.cpp |
| @@ -39,6 +39,7 @@ |
| #include "platform/TraceEvent.h" |
| #include "platform/weborigin/KURL.h" |
| #include "public/platform/Platform.h" |
| +#include "public/platform/WebProcessMemoryDump.h" |
| #include "wtf/CurrentTime.h" |
| #include "wtf/MathExtras.h" |
| #include "wtf/StdLibExtras.h" |
| @@ -717,6 +718,37 @@ void Resource::prune() |
| unlock(); |
| } |
| +void Resource::onMemoryDump(WebProcessMemoryDump* memoryDump) const |
| +{ |
| + const String dumpName = getMemoryDumpName(); |
| + WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpName); |
| + dump->AddScalar("encoded_size", "bytes", m_encodedSize); |
| + dump->AddScalar("decoded_size", "bytes", m_decodedSize); |
| + 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
|
| + dump->AddScalar("live_size", "bytes", m_encodedSize); |
| + } else { |
| + dump->AddScalar("dead_size", "bytes", m_encodedSize); |
| + } |
| + |
| + size_t totalSize = encodedSize() + overheadSize(); |
| + dump->AddScalar("purged_size", "bytes", wasPurged() ? totalSize : 0); |
| + if (m_data) { |
| + 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
|
| + dump->AddScalar("purgeable_size", "bytes", purgeable ? 0 : totalSize); |
| + m_data->onMemoryDump(dumpName, memoryDump); |
| + } |
| + |
| + const String overheadName = dumpName + "/overhead"; |
| + WebMemoryAllocatorDump* overheadDump = memoryDump->createMemoryAllocatorDump(overheadName); |
| + overheadDump->AddScalar("size", "bytes", overheadSize()); |
| + memoryDump->AddSuballocation(overheadDump->guid(), String(WTF::Partitions::allocatorPoolNameForTracing())); |
| +} |
| + |
| +String Resource::getMemoryDumpName() const |
| +{ |
| + return String::format("web_cache/%s_resources/%ld", resourceTypeToString(type(), options().initiatorInfo), m_identifier); |
| +} |
| + |
| void Resource::setResourceToRevalidate(Resource* resource) |
| { |
| ASSERT(resource); |