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

Unified Diff: base/metrics/persistent_histogram_allocator.cc

Issue 1671933002: Create and pass shared-histogram-allocator from browser to renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hsm-merge
Patch Set: addressed review comments by Alexei; fixed test on some builds Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
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)))));

Powered by Google App Engine
This is Rietveld 408576698