Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(652)

Unified Diff: content/common/discardable_shared_memory_heap.cc

Issue 1306243003: Add support to create memory allocator dump in base::DiscardableMemory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix html_viewer. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/discardable_shared_memory_heap.cc
diff --git a/content/common/discardable_shared_memory_heap.cc b/content/common/discardable_shared_memory_heap.cc
index 958fa82554efecf5d9c4dee25bb6206cf7e891c9..8996979a730afc1e252de45557bf3acf0574e038 100644
--- a/content/common/discardable_shared_memory_heap.cc
+++ b/content/common/discardable_shared_memory_heap.cc
@@ -60,6 +60,27 @@ bool DiscardableSharedMemoryHeap::ScopedMemorySegment::IsResident() const {
return heap_->IsMemoryResident(shared_memory_.get());
}
+bool DiscardableSharedMemoryHeap::ScopedMemorySegment::ContainsSpan(
+ Span* span) const {
+ return shared_memory_ == span->shared_memory();
+}
+
+base::trace_event::MemoryAllocatorDump*
+DiscardableSharedMemoryHeap::ScopedMemorySegment::CreateMemoryAllocatorDump(
+ Span* span,
+ const char* name,
+ base::trace_event::ProcessMemoryDump* pmd) const {
+ DCHECK_EQ(shared_memory_, span->shared_memory());
+ base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(name);
+ dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ static_cast<uint64_t>(span->length()));
+
+ pmd->AddSuballocation(dump->guid(),
+ base::StringPrintf("discardable/segment_%d", id_));
+ return dump;
+}
+
void DiscardableSharedMemoryHeap::ScopedMemorySegment::OnMemoryDump(
base::trace_event::ProcessMemoryDump* pmd) const {
heap_->OnMemoryDump(shared_memory_.get(), size_, id_, pmd);
@@ -398,4 +419,26 @@ DiscardableSharedMemoryHeap::GetSegmentGUIDForTracing(uint64 tracing_process_id,
"discardable-x-process/%" PRIx64 "/%d", tracing_process_id, segment_id));
}
+base::trace_event::MemoryAllocatorDump*
+DiscardableSharedMemoryHeap::CreateMemoryAllocatorDump(
+ Span* span,
+ const char* name,
+ base::trace_event::ProcessMemoryDump* pmd) const {
+ if (!span->shared_memory()) {
+ base::trace_event::MemoryAllocatorDump* dump =
+ pmd->CreateAllocatorDump(name);
+ dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes, 0u);
+ return dump;
+ }
+
+ ScopedVector<ScopedMemorySegment>::const_iterator it =
+ std::find_if(memory_segments_.begin(), memory_segments_.end(),
+ [span](const ScopedMemorySegment* segment) {
+ return segment->ContainsSpan(span);
+ });
+ DCHECK(it != memory_segments_.end());
+ return (*it)->CreateMemoryAllocatorDump(span, name, pmd);
+}
+
} // namespace content
« no previous file with comments | « content/common/discardable_shared_memory_heap.h ('k') | content/common/discardable_shared_memory_heap_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698