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

Side by Side Diff: content/common/discardable_shared_memory_heap.cc

Issue 1308213005: Fix the size dumped by child discardable manager for tracing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@discardable
Patch Set: Change to block size. Created 5 years, 3 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 unified diff | Download patch
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 62
63 bool DiscardableSharedMemoryHeap::ScopedMemorySegment::ContainsSpan( 63 bool DiscardableSharedMemoryHeap::ScopedMemorySegment::ContainsSpan(
64 Span* span) const { 64 Span* span) const {
65 return shared_memory_ == span->shared_memory(); 65 return shared_memory_ == span->shared_memory();
66 } 66 }
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 size_t block_size,
71 const char* name, 72 const char* name,
72 base::trace_event::ProcessMemoryDump* pmd) const { 73 base::trace_event::ProcessMemoryDump* pmd) const {
73 DCHECK_EQ(shared_memory_, span->shared_memory()); 74 DCHECK_EQ(shared_memory_, span->shared_memory());
74 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(name); 75 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(name);
75 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 76 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
76 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 77 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
77 static_cast<uint64_t>(span->length())); 78 static_cast<uint64_t>(span->length() * block_size));
78 79
79 pmd->AddSuballocation(dump->guid(), 80 pmd->AddSuballocation(
80 base::StringPrintf("discardable/segment_%d", id_)); 81 dump->guid(),
82 base::StringPrintf("discardable/segment_%d/allocated_objects", id_));
reveman 2015/08/26 16:02:09 why are you adding /allocated_objects here?
ssid 2015/08/26 16:05:57 The sub-allocations are usually added under "alloc
reveman 2015/08/26 16:21:04 Ack.
81 return dump; 83 return dump;
82 } 84 }
83 85
84 void DiscardableSharedMemoryHeap::ScopedMemorySegment::OnMemoryDump( 86 void DiscardableSharedMemoryHeap::ScopedMemorySegment::OnMemoryDump(
85 base::trace_event::ProcessMemoryDump* pmd) const { 87 base::trace_event::ProcessMemoryDump* pmd) const {
86 heap_->OnMemoryDump(shared_memory_.get(), size_, id_, pmd); 88 heap_->OnMemoryDump(shared_memory_.get(), size_, id_, pmd);
87 } 89 }
88 90
89 DiscardableSharedMemoryHeap::DiscardableSharedMemoryHeap(size_t block_size) 91 DiscardableSharedMemoryHeap::DiscardableSharedMemoryHeap(size_t block_size)
90 : block_size_(block_size), num_blocks_(0), num_free_blocks_(0) { 92 : block_size_(block_size), num_blocks_(0), num_free_blocks_(0) {
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 0u); 433 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 0u);
432 return dump; 434 return dump;
433 } 435 }
434 436
435 ScopedVector<ScopedMemorySegment>::const_iterator it = 437 ScopedVector<ScopedMemorySegment>::const_iterator it =
436 std::find_if(memory_segments_.begin(), memory_segments_.end(), 438 std::find_if(memory_segments_.begin(), memory_segments_.end(),
437 [span](const ScopedMemorySegment* segment) { 439 [span](const ScopedMemorySegment* segment) {
438 return segment->ContainsSpan(span); 440 return segment->ContainsSpan(span);
439 }); 441 });
440 DCHECK(it != memory_segments_.end()); 442 DCHECK(it != memory_segments_.end());
441 return (*it)->CreateMemoryAllocatorDump(span, name, pmd); 443 return (*it)->CreateMemoryAllocatorDump(span, block_size_, name, pmd);
442 } 444 }
443 445
444 } // namespace content 446 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698