Chromium Code Reviews| Index: base/metrics/persistent_histogram_allocator.cc |
| diff --git a/base/metrics/persistent_histogram_allocator.cc b/base/metrics/persistent_histogram_allocator.cc |
| index 6006d31fbee70031acb901fb6a0f04a944f5ff04..efa4fa8e436aa53ea8070eb93f24a3c2b7049466 100644 |
| --- a/base/metrics/persistent_histogram_allocator.cc |
| +++ b/base/metrics/persistent_histogram_allocator.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/lazy_instance.h" |
| #include "base/logging.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/memory/shared_memory.h" |
| #include "base/metrics/histogram.h" |
| #include "base/metrics/histogram_base.h" |
| #include "base/metrics/histogram_samples.h" |
| @@ -255,14 +256,34 @@ void PersistentHistogramAllocator::CreateGlobalAllocatorOnLocalMemory( |
| // static |
| void PersistentHistogramAllocator::CreateGlobalAllocatorOnSharedMemory( |
| + scoped_ptr<SharedMemory> memory, |
| size_t size, |
| - const SharedMemoryHandle& handle) { |
| + uint64_t id, |
| + StringPiece name) { |
| + if (!memory->memory()) { |
| + if (!memory->Map(size)) |
|
Alexei Svitkine (slow)
2016/03/29 17:51:24
Nit: Combine with the above if and then remove {}'
bcwhite
2016/03/30 21:25:55
Done.
|
| + NOTREACHED(); |
| + } |
| + |
| + if (memory->memory()) { |
| + DCHECK_LE(memory->mapped_size(), size); |
| + SetGlobalAllocator(make_scoped_ptr(new PersistentHistogramAllocator( |
| + make_scoped_ptr(new SharedPersistentMemoryAllocator( |
| + std::move(memory), id, name, /*readonly=*/false))))); |
| + } |
| +} |
| + |
| +// static |
| +void PersistentHistogramAllocator::CreateGlobalAllocatorOnSharedMemoryHandle( |
| + const SharedMemoryHandle& handle, |
| + size_t size) { |
| scoped_ptr<SharedMemory> shm(new SharedMemory(handle, /*readonly=*/false)); |
| if (!shm->Map(size)) { |
| NOTREACHED(); |
| return; |
| } |
| + DCHECK_LE(shm->mapped_size(), size); |
| SetGlobalAllocator(make_scoped_ptr(new PersistentHistogramAllocator( |
| make_scoped_ptr(new SharedPersistentMemoryAllocator( |
| std::move(shm), 0, StringPiece(), /*readonly=*/false))))); |