| Index: base/trace_event/memory_profiler_allocation_register.cc
|
| diff --git a/base/trace_event/memory_profiler_allocation_register.cc b/base/trace_event/memory_profiler_allocation_register.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8d5fa7c8b957781c31244bde9a8dc5f839d5476d
|
| --- /dev/null
|
| +++ b/base/trace_event/memory_profiler_allocation_register.cc
|
| @@ -0,0 +1,40 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "base/trace_event/memory_profiler_allocation_register.h"
|
| +
|
| +namespace base {
|
| +namespace trace_event {
|
| +
|
| +size_t RoundUpToPageSize(size_t size) {
|
| + size_t page_size = GetSystemPageSize();
|
| + return ((size + page_size - 1) / page_size) * page_size;
|
| +}
|
| +
|
| +AllocationRegister::AllocationRegister() {}
|
| +AllocationRegister::~AllocationRegister() {}
|
| +
|
| +void AllocationRegister::Insert(void* address,
|
| + size_t size,
|
| + AllocationContext context) {
|
| + Allocation* alloc = allocations_.Insert(reinterpret_cast<uintptr_t>(address));
|
| + alloc->size = size;
|
| + alloc->context = context;
|
| +}
|
| +
|
| +void AllocationRegister::Remove(void* address) {
|
| + allocations_.Remove(reinterpret_cast<uintptr_t>(address));
|
| +}
|
| +
|
| +AllocationRegister::AllocationRef AllocationRegister::ConstIterator::operator*()
|
| + const {
|
| + AllocationRef alloc_ref;
|
| + alloc_ref.address = reinterpret_cast<void*>((*iterator_).first);
|
| + alloc_ref.size = (*iterator_).second->size;
|
| + alloc_ref.context = &(*iterator_).second->context;
|
| + return alloc_ref;
|
| +}
|
| +
|
| +} // namespace trace_event
|
| +} // namespace base
|
|
|