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

Unified Diff: components/metrics/file_metrics_provider.cc

Issue 1738063002: Refactor histogram_persistence to be a class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move some parameters up a line 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: components/metrics/file_metrics_provider.cc
diff --git a/components/metrics/file_metrics_provider.cc b/components/metrics/file_metrics_provider.cc
index 7fad01c03dd15651072ff25059f70aed7595ab6d..fcfb7acfb88a4bd772c4db3b9b1213a6a859a338 100644
--- a/components/metrics/file_metrics_provider.cc
+++ b/components/metrics/file_metrics_provider.cc
@@ -11,7 +11,7 @@
#include "base/logging.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/histogram_macros.h"
-#include "base/metrics/histogram_persistence.h"
+#include "base/metrics/persistent_histogram_allocator.h"
#include "base/metrics/persistent_memory_allocator.h"
#include "base/task_runner.h"
#include "base/time/time.h"
@@ -47,7 +47,7 @@ struct FileMetricsProvider::FileInfo {
// "active", it remains mapped and nothing is copied to local memory.
std::vector<uint8_t> data;
scoped_ptr<base::MemoryMappedFile> mapped;
- scoped_ptr<base::PersistentMemoryAllocator> allocator;
+ scoped_ptr<base::PersistentHistogramAllocator> allocator;
private:
DISALLOW_COPY_AND_ASSIGN(FileInfo);
@@ -174,13 +174,13 @@ void FileMetricsProvider::RecordHistogramSnapshotsFromFile(
base::HistogramSnapshotManager* snapshot_manager,
FileInfo* file) {
DCHECK(thread_checker_.CalledOnValidThread());
- base::PersistentMemoryAllocator::Iterator hist_iter;
- file->allocator->CreateIterator(&hist_iter);
+ base::PersistentHistogramAllocator::Iterator histogram_iter;
+ file->allocator->CreateIterator(&histogram_iter);
int histogram_count = 0;
while (true) {
- scoped_ptr<base::HistogramBase> histogram(
- base::GetNextPersistentHistogram(file->allocator.get(), &hist_iter));
+ scoped_ptr<base::HistogramBase> histogram =
+ file->allocator->GetNextHistogram(&histogram_iter);
if (!histogram)
break;
if (file->type == FILE_HISTOGRAMS_ATOMIC)
@@ -204,12 +204,14 @@ void FileMetricsProvider::CreateAllocatorForFile(FileInfo* file) {
if (file->mapped) {
DCHECK(file->data.empty());
// TODO(bcwhite): Make this do read/write when supported for "active".
- file->allocator.reset(new base::FilePersistentMemoryAllocator(
- std::move(file->mapped), 0, std::string()));
+ file->allocator.reset(new base::PersistentHistogramAllocator(
+ make_scoped_ptr(new base::FilePersistentMemoryAllocator(
+ std::move(file->mapped), 0, ""))));
} else {
DCHECK(!file->mapped);
- file->allocator.reset(new base::PersistentMemoryAllocator(
- &file->data[0], file->data.size(), 0, 0, "", true));
+ file->allocator.reset(new base::PersistentHistogramAllocator(
+ make_scoped_ptr(new base::PersistentMemoryAllocator(
+ &file->data[0], file->data.size(), 0, 0, "", true))));
}
}

Powered by Google App Engine
This is Rietveld 408576698