Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "platform/PartitionAllocMemoryDumpProvider.h" | 6 #include "platform/PartitionAllocMemoryDumpProvider.h" |
| 7 | 7 |
| 8 #include "public/platform/WebMemoryAllocatorDump.h" | 8 #include "public/platform/WebMemoryAllocatorDump.h" |
| 9 #include "public/platform/WebProcessMemoryDump.h" | 9 #include "public/platform/WebProcessMemoryDump.h" |
| 10 #include "wtf/Partitions.h" | 10 #include "wtf/Partitions.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 using namespace WTF; | 16 using namespace WTF; |
| 17 | 17 |
| 18 const char kPartitionAllocDumpName[] = "partition_alloc"; | 18 const char kPartitionAllocDumpName[] = "partition_alloc"; |
| 19 const char kPartitionAllocPoolName[] = "partition_alloc/allocated_objects"; | |
| 19 const char kPartitionsDumpName[] = "partitions"; | 20 const char kPartitionsDumpName[] = "partitions"; |
|
haraken
2015/09/29 16:20:17
How about just defining these constant strings in
| |
| 20 | 21 |
| 21 String getPartitionDumpName(const char* partitionName) | 22 String getPartitionDumpName(const char* partitionName) |
| 22 { | 23 { |
| 23 return String::format("%s/%s/%s", kPartitionAllocDumpName, kPartitionsDumpNa me, partitionName); | 24 return String::format("%s/%s/%s", kPartitionAllocDumpName, kPartitionsDumpNa me, partitionName); |
| 24 } | 25 } |
| 25 | 26 |
| 26 // This class is used to invert the dependency of PartitionAlloc on the | 27 // This class is used to invert the dependency of PartitionAlloc on the |
| 27 // PartitionAllocMemoryDumpProvider. This implements an interface that will | 28 // PartitionAllocMemoryDumpProvider. This implements an interface that will |
| 28 // be called with memory statistics for each bucket in the allocator. | 29 // be called with memory statistics for each bucket in the allocator. |
| 29 class PartitionStatsDumperImpl final : public PartitionStatsDumper { | 30 class PartitionStatsDumperImpl final : public PartitionStatsDumper { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 bool PartitionAllocMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail l evelOfDetail, WebProcessMemoryDump* memoryDump) | 94 bool PartitionAllocMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail l evelOfDetail, WebProcessMemoryDump* memoryDump) |
| 94 { | 95 { |
| 95 PartitionStatsDumperImpl partitionStatsDumper(memoryDump, levelOfDetail); | 96 PartitionStatsDumperImpl partitionStatsDumper(memoryDump, levelOfDetail); |
| 96 | 97 |
| 97 WebMemoryAllocatorDump* partitionsDump = memoryDump->createMemoryAllocatorDu mp( | 98 WebMemoryAllocatorDump* partitionsDump = memoryDump->createMemoryAllocatorDu mp( |
| 98 String::format("%s/%s", kPartitionAllocDumpName, kPartitionsDumpName)); | 99 String::format("%s/%s", kPartitionAllocDumpName, kPartitionsDumpName)); |
| 99 | 100 |
| 100 // This method calls memoryStats.partitionsDumpBucketStats with memory stati stics. | 101 // This method calls memoryStats.partitionsDumpBucketStats with memory stati stics. |
| 101 WTF::Partitions::dumpMemoryStats(levelOfDetail == WebMemoryDumpLevelOfDetail ::Light, &partitionStatsDumper); | 102 WTF::Partitions::dumpMemoryStats(levelOfDetail == WebMemoryDumpLevelOfDetail ::Light, &partitionStatsDumper); |
| 102 | 103 |
| 103 WebMemoryAllocatorDump* allocatedObjectsDump = memoryDump->createMemoryAlloc atorDump( | 104 WebMemoryAllocatorDump* allocatedObjectsDump = memoryDump->createMemoryAlloc atorDump(kPartitionAllocPoolName); |
| 104 String::format("%s/allocated_objects", kPartitionAllocDumpName)); | |
| 105 allocatedObjectsDump->AddScalar("size", "bytes", partitionStatsDumper.totalA ctiveBytes()); | 105 allocatedObjectsDump->AddScalar("size", "bytes", partitionStatsDumper.totalA ctiveBytes()); |
| 106 memoryDump->AddOwnershipEdge(allocatedObjectsDump->guid(), partitionsDump->g uid()); | 106 memoryDump->AddOwnershipEdge(allocatedObjectsDump->guid(), partitionsDump->g uid()); |
| 107 | 107 |
| 108 return true; | 108 return true; |
| 109 } | 109 } |
| 110 | 110 |
| 111 PartitionAllocMemoryDumpProvider::PartitionAllocMemoryDumpProvider() | 111 PartitionAllocMemoryDumpProvider::PartitionAllocMemoryDumpProvider() |
| 112 { | 112 { |
| 113 Partitions::setAllocatorPoolNameForTracing(kPartitionAllocPoolName); | |
| 113 } | 114 } |
| 114 | 115 |
| 115 PartitionAllocMemoryDumpProvider::~PartitionAllocMemoryDumpProvider() | 116 PartitionAllocMemoryDumpProvider::~PartitionAllocMemoryDumpProvider() |
| 116 { | 117 { |
| 117 } | 118 } |
| 118 | 119 |
| 119 } // namespace blink | 120 } // namespace blink |
| OLD | NEW |