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

Unified Diff: chrome/installer/setup/installer_metrics.cc

Issue 1738063002: Refactor histogram_persistence to be a class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed review comments by Alexi and temporarily re-order methods for easier review 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: chrome/installer/setup/installer_metrics.cc
diff --git a/chrome/installer/setup/installer_metrics.cc b/chrome/installer/setup/installer_metrics.cc
index 8e5f0443e437f7589493be0818c56ef397cf2b17..33d039b8516d4371b329598ded4e65a498eda280 100644
--- a/chrome/installer/setup/installer_metrics.cc
+++ b/chrome/installer/setup/installer_metrics.cc
@@ -8,29 +8,32 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/metrics/histogram_base.h"
-#include "base/metrics/histogram_persistence.h"
+#include "base/metrics/persistent_histogram_allocator.h"
#include "base/metrics/persistent_memory_allocator.h"
#include "chrome/installer/util/util_constants.h"
namespace installer {
void BeginPersistentHistogramStorage() {
- base::SetPersistentHistogramMemoryAllocator(
- new base::LocalPersistentMemoryAllocator(
- 1 << 20, 0, // 1 MiB
- installer::kSetupHistogramAllocatorName));
- base::GetPersistentHistogramMemoryAllocator()->CreateTrackingHistograms(
- installer::kSetupHistogramAllocatorName);
+ base::PersistentHistogramAllocator::SetGlobalAllocator(
+ make_scoped_ptr(new base::PersistentHistogramAllocator(
+ make_scoped_ptr(new base::LocalPersistentMemoryAllocator(
+ 1 << 20, 0, // 1 MiB
+ installer::kSetupHistogramAllocatorName)))));
+ base::PersistentHistogramAllocator::GetGlobalAllocator()
+ ->CreateTrackingHistograms(installer::kSetupHistogramAllocatorName);
}
void EndPersistentHistogramStorage(const base::FilePath& target_path) {
+ base::PersistentHistogramAllocator::GetGlobalAllocator()
Alexei Svitkine (slow) 2016/03/07 16:40:43 Nit: Save a pointer to base::PersistentHistogramAl
bcwhite 2016/03/08 00:24:04 Done. Hmmm... Perhaps it's better to export the
Alexei Svitkine (slow) 2016/03/08 19:58:28 Exporting them looks good.
+ ->UpdateTrackingHistograms();
+ base::PersistentMemoryAllocator* allocator =
+ base::PersistentHistogramAllocator::GetGlobalAllocator()
+ ->memory_allocator();
+
// For atomicity, first write to a temporary file and then rename it.
// The ImportantFileWriter would be good for this except it supports only
// std::string for its data.
- base::PersistentMemoryAllocator* allocator =
- base::GetPersistentHistogramMemoryAllocator();
- allocator->UpdateTrackingHistograms();
-
base::FilePath file_path = target_path
.AppendASCII(allocator->Name())
.AddExtension(L".pma");

Powered by Google App Engine
This is Rietveld 408576698