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

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: fixed test to not use SharedMemory which doesn't work on all builds (and rebased) Created 4 years, 8 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 864753bab5d3413c46252320657b0d1d4b5e79cd..fe2fdef01ce601d0484e44d48cf394bc507aed0d 100644
--- a/base/metrics/persistent_histogram_allocator.cc
+++ b/base/metrics/persistent_histogram_allocator.cc
@@ -480,15 +480,16 @@ void GlobalHistogramAllocator::CreateWithSharedMemory(
size_t size,
uint64_t id,
StringPiece name) {
- if (!memory->memory() && !memory->Map(size))
+ if ((!memory->memory() && !memory->Map(size)) ||
+ !SharedPersistentMemoryAllocator::IsSharedMemoryAcceptable(*memory)) {
NOTREACHED();
-
- if (memory->memory()) {
- DCHECK_LE(memory->mapped_size(), size);
- Set(WrapUnique(new GlobalHistogramAllocator(
- WrapUnique(new SharedPersistentMemoryAllocator(
- std::move(memory), 0, StringPiece(), /*readonly=*/false)))));
+ return;
}
+
+ DCHECK_LE(memory->mapped_size(), size);
+ Set(WrapUnique(new GlobalHistogramAllocator(
+ WrapUnique(new SharedPersistentMemoryAllocator(
+ std::move(memory), 0, StringPiece(), /*readonly=*/false)))));
}
// static
@@ -497,7 +498,8 @@ void GlobalHistogramAllocator::CreateWithSharedMemoryHandle(
size_t size) {
std::unique_ptr<SharedMemory> shm(
new SharedMemory(handle, /*readonly=*/false));
- if (!shm->Map(size)) {
+ if (!shm->Map(size) ||
+ !SharedPersistentMemoryAllocator::IsSharedMemoryAcceptable(*shm)) {
NOTREACHED();
return;
}
« no previous file with comments | « base/metrics/persistent_histogram_allocator.h ('k') | chrome/browser/metrics/chrome_metrics_service_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698