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

Unified Diff: chrome/browser/metrics/metrics_log.cc

Issue 282093012: Remove dependencies of Metrics{Service,Log} on g_browser_process->local_state() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Android compile fix Created 6 years, 7 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
« no previous file with comments | « chrome/browser/metrics/metrics_log.h ('k') | chrome/browser/metrics/metrics_log_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/metrics/metrics_log.cc
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc
index d647bac58eecefd220f273e960c407be7a6eb992..d9e11a823270879c13c0527925ce68a7118c38eb 100644
--- a/chrome/browser/metrics/metrics_log.cc
+++ b/chrome/browser/metrics/metrics_log.cc
@@ -181,13 +181,15 @@ int64 RoundSecondsToHour(int64 time_in_seconds) {
MetricsLog::MetricsLog(const std::string& client_id,
int session_id,
LogType log_type,
- metrics::MetricsServiceClient* client)
+ metrics::MetricsServiceClient* client,
+ PrefService* local_state)
: MetricsLogBase(client_id,
session_id,
log_type,
client->GetVersionString()),
client_(client),
- creation_time_(base::TimeTicks::Now()) {
+ creation_time_(base::TimeTicks::Now()),
+ local_state_(local_state) {
uma_proto()->mutable_system_profile()->set_channel(client_->GetChannel());
}
@@ -201,7 +203,7 @@ void MetricsLog::RecordStabilityMetrics(
DCHECK(HasEnvironment());
DCHECK(!HasStabilityMetrics());
- PrefService* pref = GetPrefService();
+ PrefService* pref = local_state_;
DCHECK(pref);
// Get stability attributes out of Local State, zeroing out stored values.
@@ -259,10 +261,6 @@ void MetricsLog::RecordGeneralMetrics(
metrics_providers[i]->ProvideGeneralMetrics(uma_proto());
}
-PrefService* MetricsLog::GetPrefService() {
- return g_browser_process->local_state();
-}
-
void MetricsLog::GetFieldTrialIds(
std::vector<ActiveGroupId>* field_trial_ids) const {
variations::GetFieldTrialActiveGroupIds(field_trial_ids);
@@ -329,14 +327,14 @@ void MetricsLog::RecordEnvironment(
system_profile->set_brand_code(brand_code);
int enabled_date;
- bool success = base::StringToInt(GetMetricsEnabledDate(GetPrefService()),
- &enabled_date);
+ bool success =
+ base::StringToInt(GetMetricsEnabledDate(local_state_), &enabled_date);
DCHECK(success);
// Reduce granularity of the enabled_date field to nearest hour.
system_profile->set_uma_enabled_date(RoundSecondsToHour(enabled_date));
- int64 install_date = GetPrefService()->GetInt64(prefs::kInstallDate);
+ int64 install_date = local_state_->GetInt64(prefs::kInstallDate);
// Reduce granularity of the install_date field to nearest hour.
system_profile->set_install_date(RoundSecondsToHour(install_date));
@@ -385,7 +383,7 @@ void MetricsLog::RecordEnvironment(
std::string base64_system_profile;
if (system_profile->SerializeToString(&serialied_system_profile)) {
base::Base64Encode(serialied_system_profile, &base64_system_profile);
- PrefService* local_state = GetPrefService();
+ PrefService* local_state = local_state_;
local_state->SetString(prefs::kStabilitySavedSystemProfile,
base64_system_profile);
local_state->SetString(prefs::kStabilitySavedSystemProfileHash,
@@ -394,7 +392,7 @@ void MetricsLog::RecordEnvironment(
}
bool MetricsLog::LoadSavedEnvironmentFromPrefs() {
- PrefService* local_state = GetPrefService();
+ PrefService* local_state = local_state_;
const std::string base64_system_profile =
local_state->GetString(prefs::kStabilitySavedSystemProfile);
if (base64_system_profile.empty())
« no previous file with comments | « chrome/browser/metrics/metrics_log.h ('k') | chrome/browser/metrics/metrics_log_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698