OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/common/discardable_shared_memory_heap.h" | 5 #include "content/common/discardable_shared_memory_heap.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/memory/discardable_shared_memory.h" | 10 #include "base/memory/discardable_shared_memory.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 | 67 |
68 base::trace_event::MemoryAllocatorDump* | 68 base::trace_event::MemoryAllocatorDump* |
69 DiscardableSharedMemoryHeap::ScopedMemorySegment::CreateMemoryAllocatorDump( | 69 DiscardableSharedMemoryHeap::ScopedMemorySegment::CreateMemoryAllocatorDump( |
70 Span* span, | 70 Span* span, |
71 const char* name, | 71 const char* name, |
72 base::trace_event::ProcessMemoryDump* pmd) const { | 72 base::trace_event::ProcessMemoryDump* pmd) const { |
73 DCHECK_EQ(shared_memory_, span->shared_memory()); | 73 DCHECK_EQ(shared_memory_, span->shared_memory()); |
74 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(name); | 74 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(name); |
75 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 75 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
76 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 76 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
77 static_cast<uint64_t>(span->length())); | 77 static_cast<uint64_t>(span->shared_memory()->mapped_size())); |
reveman
2015/08/26 15:56:18
hm, mapped_size is the total size of the segment b
ssid
2015/08/26 16:00:35
Ah yes, I got confused here because of the host si
| |
78 | 78 |
79 pmd->AddSuballocation(dump->guid(), | 79 pmd->AddSuballocation( |
80 base::StringPrintf("discardable/segment_%d", id_)); | 80 dump->guid(), |
81 base::StringPrintf("discardable/segment_%d/allocated_objects", id_)); | |
81 return dump; | 82 return dump; |
82 } | 83 } |
83 | 84 |
84 void DiscardableSharedMemoryHeap::ScopedMemorySegment::OnMemoryDump( | 85 void DiscardableSharedMemoryHeap::ScopedMemorySegment::OnMemoryDump( |
85 base::trace_event::ProcessMemoryDump* pmd) const { | 86 base::trace_event::ProcessMemoryDump* pmd) const { |
86 heap_->OnMemoryDump(shared_memory_.get(), size_, id_, pmd); | 87 heap_->OnMemoryDump(shared_memory_.get(), size_, id_, pmd); |
87 } | 88 } |
88 | 89 |
89 DiscardableSharedMemoryHeap::DiscardableSharedMemoryHeap(size_t block_size) | 90 DiscardableSharedMemoryHeap::DiscardableSharedMemoryHeap(size_t block_size) |
90 : block_size_(block_size), num_blocks_(0), num_free_blocks_(0) { | 91 : block_size_(block_size), num_blocks_(0), num_free_blocks_(0) { |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
435 ScopedVector<ScopedMemorySegment>::const_iterator it = | 436 ScopedVector<ScopedMemorySegment>::const_iterator it = |
436 std::find_if(memory_segments_.begin(), memory_segments_.end(), | 437 std::find_if(memory_segments_.begin(), memory_segments_.end(), |
437 [span](const ScopedMemorySegment* segment) { | 438 [span](const ScopedMemorySegment* segment) { |
438 return segment->ContainsSpan(span); | 439 return segment->ContainsSpan(span); |
439 }); | 440 }); |
440 DCHECK(it != memory_segments_.end()); | 441 DCHECK(it != memory_segments_.end()); |
441 return (*it)->CreateMemoryAllocatorDump(span, name, pmd); | 442 return (*it)->CreateMemoryAllocatorDump(span, name, pmd); |
442 } | 443 } |
443 | 444 |
444 } // namespace content | 445 } // namespace content |
OLD | NEW |