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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 bool DiscardableSharedMemoryHeap::ScopedMemorySegment::IsUsed() const { | 57 bool DiscardableSharedMemoryHeap::ScopedMemorySegment::IsUsed() const { |
58 return heap_->IsMemoryUsed(shared_memory_.get(), size_); | 58 return heap_->IsMemoryUsed(shared_memory_.get(), size_); |
59 } | 59 } |
60 | 60 |
61 bool DiscardableSharedMemoryHeap::ScopedMemorySegment::IsResident() const { | 61 bool DiscardableSharedMemoryHeap::ScopedMemorySegment::IsResident() const { |
62 return heap_->IsMemoryResident(shared_memory_.get()); | 62 return heap_->IsMemoryResident(shared_memory_.get()); |
63 } | 63 } |
64 | 64 |
65 bool DiscardableSharedMemoryHeap::ScopedMemorySegment::ContainsSpan( | 65 bool DiscardableSharedMemoryHeap::ScopedMemorySegment::ContainsSpan( |
66 Span* span) const { | 66 Span* span) const { |
67 return shared_memory_ == span->shared_memory(); | 67 return shared_memory_.get() == span->shared_memory(); |
68 } | 68 } |
69 | 69 |
70 base::trace_event::MemoryAllocatorDump* | 70 base::trace_event::MemoryAllocatorDump* |
71 DiscardableSharedMemoryHeap::ScopedMemorySegment::CreateMemoryAllocatorDump( | 71 DiscardableSharedMemoryHeap::ScopedMemorySegment::CreateMemoryAllocatorDump( |
72 Span* span, | 72 Span* span, |
73 size_t block_size, | 73 size_t block_size, |
74 const char* name, | 74 const char* name, |
75 base::trace_event::ProcessMemoryDump* pmd) const { | 75 base::trace_event::ProcessMemoryDump* pmd) const { |
76 DCHECK_EQ(shared_memory_, span->shared_memory()); | 76 DCHECK_EQ(shared_memory_.get(), span->shared_memory()); |
77 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(name); | 77 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(name); |
78 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 78 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
79 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 79 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
80 static_cast<uint64_t>(span->length() * block_size)); | 80 static_cast<uint64_t>(span->length() * block_size)); |
81 | 81 |
82 pmd->AddSuballocation( | 82 pmd->AddSuballocation( |
83 dump->guid(), | 83 dump->guid(), |
84 base::StringPrintf("discardable/segment_%d/allocated_objects", id_)); | 84 base::StringPrintf("discardable/segment_%d/allocated_objects", id_)); |
85 return dump; | 85 return dump; |
86 } | 86 } |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 ScopedVector<ScopedMemorySegment>::const_iterator it = | 449 ScopedVector<ScopedMemorySegment>::const_iterator it = |
450 std::find_if(memory_segments_.begin(), memory_segments_.end(), | 450 std::find_if(memory_segments_.begin(), memory_segments_.end(), |
451 [span](const ScopedMemorySegment* segment) { | 451 [span](const ScopedMemorySegment* segment) { |
452 return segment->ContainsSpan(span); | 452 return segment->ContainsSpan(span); |
453 }); | 453 }); |
454 DCHECK(it != memory_segments_.end()); | 454 DCHECK(it != memory_segments_.end()); |
455 return (*it)->CreateMemoryAllocatorDump(span, block_size_, name, pmd); | 455 return (*it)->CreateMemoryAllocatorDump(span, block_size_, name, pmd); |
456 } | 456 } |
457 | 457 |
458 } // namespace content | 458 } // namespace content |
OLD | NEW |