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..e6d0dab65f4b651dab5ba2d33696d31371c0eee5 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" |
grt (UTC plus 2)
2016/04/01 14:22:48
remove these two -- already included in .h
bcwhite
2016/04/01 16:50:26
Done.
|
+#include "base/memory/shared_memory.h" |
#include "base/metrics/histogram.h" |
#include "base/metrics/histogram_base.h" |
grt (UTC plus 2)
2016/04/01 14:22:48
remove this -- already included in .h
bcwhite
2016/04/01 16:50:26
Done.
|
#include "base/metrics/histogram_samples.h" |
@@ -255,14 +256,32 @@ 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() && !memory->Map(size)) |
+ 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)); |
grt (UTC plus 2)
2016/04/01 14:22:48
iiuc, this effectively takes ownership of |handle|
bcwhite
2016/04/01 16:50:26
The passing convention matches that of the SharedM
|
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))))); |