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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/metrics/persistent_histogram_allocator.h" 5 #include "base/metrics/persistent_histogram_allocator.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 Set(WrapUnique(new GlobalHistogramAllocator( 473 Set(WrapUnique(new GlobalHistogramAllocator(
474 WrapUnique(new LocalPersistentMemoryAllocator(size, id, name))))); 474 WrapUnique(new LocalPersistentMemoryAllocator(size, id, name)))));
475 } 475 }
476 476
477 // static 477 // static
478 void GlobalHistogramAllocator::CreateWithSharedMemory( 478 void GlobalHistogramAllocator::CreateWithSharedMemory(
479 std::unique_ptr<SharedMemory> memory, 479 std::unique_ptr<SharedMemory> memory,
480 size_t size, 480 size_t size,
481 uint64_t id, 481 uint64_t id,
482 StringPiece name) { 482 StringPiece name) {
483 if (!memory->memory() && !memory->Map(size)) 483 if ((!memory->memory() && !memory->Map(size)) ||
484 !SharedPersistentMemoryAllocator::IsSharedMemoryAcceptable(*memory)) {
484 NOTREACHED(); 485 NOTREACHED();
486 return;
487 }
485 488
486 if (memory->memory()) { 489 DCHECK_LE(memory->mapped_size(), size);
487 DCHECK_LE(memory->mapped_size(), size); 490 Set(WrapUnique(new GlobalHistogramAllocator(
488 Set(WrapUnique(new GlobalHistogramAllocator( 491 WrapUnique(new SharedPersistentMemoryAllocator(
489 WrapUnique(new SharedPersistentMemoryAllocator( 492 std::move(memory), 0, StringPiece(), /*readonly=*/false)))));
490 std::move(memory), 0, StringPiece(), /*readonly=*/false)))));
491 }
492 } 493 }
493 494
494 // static 495 // static
495 void GlobalHistogramAllocator::CreateWithSharedMemoryHandle( 496 void GlobalHistogramAllocator::CreateWithSharedMemoryHandle(
496 const SharedMemoryHandle& handle, 497 const SharedMemoryHandle& handle,
497 size_t size) { 498 size_t size) {
498 std::unique_ptr<SharedMemory> shm( 499 std::unique_ptr<SharedMemory> shm(
499 new SharedMemory(handle, /*readonly=*/false)); 500 new SharedMemory(handle, /*readonly=*/false));
500 if (!shm->Map(size)) { 501 if (!shm->Map(size) ||
502 !SharedPersistentMemoryAllocator::IsSharedMemoryAcceptable(*shm)) {
501 NOTREACHED(); 503 NOTREACHED();
502 return; 504 return;
503 } 505 }
504 506
505 Set(WrapUnique(new GlobalHistogramAllocator( 507 Set(WrapUnique(new GlobalHistogramAllocator(
506 WrapUnique(new SharedPersistentMemoryAllocator( 508 WrapUnique(new SharedPersistentMemoryAllocator(
507 std::move(shm), 0, StringPiece(), /*readonly=*/false))))); 509 std::move(shm), 0, StringPiece(), /*readonly=*/false)))));
508 } 510 }
509 511
510 // static 512 // static
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 while (true) { 582 while (true) {
581 std::unique_ptr<HistogramBase> histogram = 583 std::unique_ptr<HistogramBase> histogram =
582 import_iterator_.GetNextWithIgnore(record_to_ignore); 584 import_iterator_.GetNextWithIgnore(record_to_ignore);
583 if (!histogram) 585 if (!histogram)
584 break; 586 break;
585 StatisticsRecorder::RegisterOrDeleteDuplicate(histogram.release()); 587 StatisticsRecorder::RegisterOrDeleteDuplicate(histogram.release());
586 } 588 }
587 } 589 }
588 590
589 } // namespace base 591 } // namespace base
OLDNEW
« 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