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

Side by Side Diff: chrome/browser/chrome_browser_field_trials.cc

Issue 2907543003: Support persistent system profiles. (Closed)
Patch Set: addressed review comments by asvitkine Created 3 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chrome_browser_field_trials.h" 5 #include "chrome/browser/chrome_browser_field_trials.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/metrics/histogram_base.h" 13 #include "base/metrics/histogram_base.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/metrics/persistent_histogram_allocator.h" 15 #include "base/metrics/persistent_histogram_allocator.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "chrome/browser/metrics/chrome_metrics_service_client.h" 20 #include "chrome/browser/metrics/chrome_metrics_service_client.h"
21 #include "chrome/browser/metrics/chrome_metrics_services_manager_client.h" 21 #include "chrome/browser/metrics/chrome_metrics_services_manager_client.h"
22 #include "chrome/browser/tracing/background_tracing_field_trial.h" 22 #include "chrome/browser/tracing/background_tracing_field_trial.h"
23 #include "chrome/common/channel_info.h" 23 #include "chrome/common/channel_info.h"
24 #include "chrome/common/chrome_paths.h" 24 #include "chrome/common/chrome_paths.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "components/metrics/metrics_pref_names.h" 26 #include "components/metrics/metrics_pref_names.h"
27 #include "components/metrics/persistent_system_profile.h"
27 #include "components/variations/variations_associated_data.h" 28 #include "components/variations/variations_associated_data.h"
28 29
29 #if defined(OS_ANDROID) 30 #if defined(OS_ANDROID)
30 #include "chrome/browser/chrome_browser_field_trials_mobile.h" 31 #include "chrome/browser/chrome_browser_field_trials_mobile.h"
31 #else 32 #else
32 #include "chrome/browser/chrome_browser_field_trials_desktop.h" 33 #include "chrome/browser/chrome_browser_field_trials_desktop.h"
33 #endif 34 #endif
34 35
35 namespace { 36 namespace {
36 37
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // Get the allocator that was just created and report result. Exit if the 114 // Get the allocator that was just created and report result. Exit if the
114 // allocator could not be created. 115 // allocator could not be created.
115 UMA_HISTOGRAM_ENUMERATION("UMA.PersistentHistograms.InitResult", result, 116 UMA_HISTOGRAM_ENUMERATION("UMA.PersistentHistograms.InitResult", result,
116 INIT_RESULT_MAX); 117 INIT_RESULT_MAX);
117 118
118 base::GlobalHistogramAllocator* allocator = 119 base::GlobalHistogramAllocator* allocator =
119 base::GlobalHistogramAllocator::Get(); 120 base::GlobalHistogramAllocator::Get();
120 if (!allocator) 121 if (!allocator)
121 return; 122 return;
122 123
124 // Store a copy of the system profile in this allocator.
125 metrics::GlobalPersistentSystemProfile::GetInstance()
126 ->RegisterPersistentAllocator(allocator->memory_allocator());
127
123 // Create tracking histograms for the allocator and record storage file. 128 // Create tracking histograms for the allocator and record storage file.
124 allocator->CreateTrackingHistograms( 129 allocator->CreateTrackingHistograms(
125 ChromeMetricsServiceClient::kBrowserMetricsName); 130 ChromeMetricsServiceClient::kBrowserMetricsName);
126 } 131 }
127 132
128 // Create a field trial to control metrics/crash sampling for Stable on 133 // Create a field trial to control metrics/crash sampling for Stable on
129 // Windows/Android if no variations seed was applied. 134 // Windows/Android if no variations seed was applied.
130 void CreateFallbackSamplingTrialIfNeeded(bool has_seed, 135 void CreateFallbackSamplingTrialIfNeeded(bool has_seed,
131 base::FeatureList* feature_list) { 136 base::FeatureList* feature_list) {
132 #if defined(OS_WIN) || defined(OS_ANDROID) 137 #if defined(OS_WIN) || defined(OS_ANDROID)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 bool has_seed, 170 bool has_seed,
166 base::FeatureList* feature_list) { 171 base::FeatureList* feature_list) {
167 CreateFallbackSamplingTrialIfNeeded(has_seed, feature_list); 172 CreateFallbackSamplingTrialIfNeeded(has_seed, feature_list);
168 } 173 }
169 174
170 void ChromeBrowserFieldTrials::InstantiateDynamicTrials() { 175 void ChromeBrowserFieldTrials::InstantiateDynamicTrials() {
171 // Persistent histograms must be enabled as soon as possible. 176 // Persistent histograms must be enabled as soon as possible.
172 InstantiatePersistentHistograms(); 177 InstantiatePersistentHistograms();
173 tracing::SetupBackgroundTracingFieldTrial(); 178 tracing::SetupBackgroundTracingFieldTrial();
174 } 179 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698