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

Unified Diff: chrome/browser/chrome_browser_field_trials.cc

Issue 1891913002: Support saving browser metrics to disk and reading them during next run. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed some build problems 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: chrome/browser/chrome_browser_field_trials.cc
diff --git a/chrome/browser/chrome_browser_field_trials.cc b/chrome/browser/chrome_browser_field_trials.cc
index 648167695f6b70b9ca8b5c986e7c773d7d08c2ca..cc913f874073ab51febfacd1b2ee9f82e80d8287 100644
--- a/chrome/browser/chrome_browser_field_trials.cc
+++ b/chrome/browser/chrome_browser_field_trials.cc
@@ -8,12 +8,15 @@
#include "base/command_line.h"
#include "base/feature_list.h"
+#include "base/files/file_path.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram_base.h"
#include "base/metrics/persistent_histogram_allocator.h"
+#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "build/build_config.h"
+#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "components/metrics/metrics_pref_names.h"
@@ -39,6 +42,20 @@ void InstantiatePersistentHistograms() {
kAllocatorName);
base::GlobalHistogramAllocator::Get()->CreateTrackingHistograms(
kAllocatorName);
+
+ // Set the destination for where these will be persistent. This shouldn't
Ilya Sherman 2016/04/19 00:57:46 nit: s/persistent/persisted
bcwhite 2016/04/19 16:33:38 Done.
+ // be necessary because it's done in chrome_metrics_service_client.cc where
+ // the reading of this file is configured but field trials don't get done
+ // until after that point so there is no global allocator to configure
+ // when that code runs. This won't be a problem when this (eventually)
+ // becomes standard and is enabled during early startup.
+ base::FilePath metrics_file;
+ if (base::PathService::Get(chrome::DIR_USER_DATA, &metrics_file)) {
+ metrics_file = metrics_file.AppendASCII(kAllocatorName)
+ .AddExtension(FILE_PATH_LITERAL(".pma"));
+ base::GlobalHistogramAllocator::Get()
+ ->SetPersistentLocation(metrics_file);
+ }
Ilya Sherman 2016/04/19 00:57:46 I think I'd prefer to always set the location from
bcwhite 2016/04/19 16:33:38 I could add Disable/Enable methods to the GlobalHi
}
}

Powered by Google App Engine
This is Rietveld 408576698