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

Unified Diff: base/metrics/histogram_persistence.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: cleanup on RenderProcessHostDestroyed instead of RenderProcessExited; use existing ScopedObserver c… Created 4 years, 10 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/histogram_persistence.cc
diff --git a/base/metrics/histogram_persistence.cc b/base/metrics/histogram_persistence.cc
index f18d17528354329cd4995615d2451f6a52c59302..4a6b5dc4caf98957089c7dae5ec38d5340c4e80b 100644
--- a/base/metrics/histogram_persistence.cc
+++ b/base/metrics/histogram_persistence.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"
@@ -189,6 +190,28 @@ void SetPersistentHistogramMemoryAllocator(
g_allocator = allocator;
}
+SharedPersistentMemoryAllocator* CreateSharedPersistentHistogramMemoryAllocator(
+ size_t size,
+ StringPiece name,
+ uint64_t id) {
+ scoped_ptr<SharedMemory> shm(new SharedMemory());
+ shm->CreateAndMapAnonymous(size);
+ return new SharedPersistentMemoryAllocator(std::move(shm), id, name, false);
+}
+
+SharedPersistentMemoryAllocator* CreateSharedPersistentHistogramMemoryAllocator(
+ size_t size,
+ const SharedMemoryHandle& handle,
+ bool readonly) {
+ scoped_ptr<SharedMemory> shm(new SharedMemory(handle, readonly));
+ if (!shm->Map(size)) {
+ NOTREACHED();
+ return nullptr;
+ }
+ return new SharedPersistentMemoryAllocator(std::move(shm), 0, StringPiece(),
+ readonly);
+}
+
PersistentMemoryAllocator* GetPersistentHistogramMemoryAllocator() {
return g_allocator;
}

Powered by Google App Engine
This is Rietveld 408576698