| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "base/memory/shared_memory_tracker.h" | 5 #include "base/memory/shared_memory_tracker.h" |
| 6 | 6 |
| 7 #include "base/memory/shared_memory.h" | 7 #include "base/memory/shared_memory.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/trace_event/memory_dump_manager.h" | 9 #include "base/trace_event/memory_dump_manager.h" |
| 10 #include "base/trace_event/process_memory_dump.h" | 10 #include "base/trace_event/process_memory_dump.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // TODO(hajimehoshi): The size is not resident size but virtual size so far. | 66 // TODO(hajimehoshi): The size is not resident size but virtual size so far. |
| 67 // Fix this to record resident size. | 67 // Fix this to record resident size. |
| 68 local_dump->AddScalar(trace_event::MemoryAllocatorDump::kNameSize, | 68 local_dump->AddScalar(trace_event::MemoryAllocatorDump::kNameSize, |
| 69 trace_event::MemoryAllocatorDump::kUnitsBytes, | 69 trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 70 size.second); | 70 size.second); |
| 71 trace_event::MemoryAllocatorDump* global_dump = | 71 trace_event::MemoryAllocatorDump* global_dump = |
| 72 pmd->CreateSharedGlobalAllocatorDump(guid); | 72 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 73 global_dump->AddScalar(trace_event::MemoryAllocatorDump::kNameSize, | 73 global_dump->AddScalar(trace_event::MemoryAllocatorDump::kNameSize, |
| 74 trace_event::MemoryAllocatorDump::kUnitsBytes, | 74 trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 75 size.second); | 75 size.second); |
| 76 // TOOD(hajimehoshi): Detect which the shared memory comes from browser, | 76 // The edges will be overriden by the clients with correct importance. |
| 77 // renderer or GPU process. | 77 pmd->AddOverridableOwnershipEdge(local_dump->guid(), global_dump->guid(), |
| 78 // TODO(hajimehoshi): Shared memory reported by GPU and discardable is | 78 0 /* importance */); |
| 79 // currently double-counted. Add ownership edges to avoid this. | |
| 80 pmd->AddOwnershipEdge(local_dump->guid(), global_dump->guid()); | |
| 81 } | 79 } |
| 82 return true; | 80 return true; |
| 83 } | 81 } |
| 84 | 82 |
| 85 SharedMemoryTracker::SharedMemoryTracker() { | 83 SharedMemoryTracker::SharedMemoryTracker() { |
| 86 trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( | 84 trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( |
| 87 this, "SharedMemoryTracker", nullptr); | 85 this, "SharedMemoryTracker", nullptr); |
| 88 } | 86 } |
| 89 | 87 |
| 90 SharedMemoryTracker::~SharedMemoryTracker() = default; | 88 SharedMemoryTracker::~SharedMemoryTracker() = default; |
| 91 | 89 |
| 92 } // namespace | 90 } // namespace |
| OLD | NEW |