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

Side by Side Diff: components/metrics/metrics_service.cc

Issue 370813003: Move kInstallDate from chrome/common/pref_names.h to components/metrics/metrics_pref_names.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review:isherman Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 //------------------------------------------------------------------------------ 5 //------------------------------------------------------------------------------
6 // Description of the life cycle of a instance of MetricsService. 6 // Description of the life cycle of a instance of MetricsService.
7 // 7 //
8 // OVERVIEW 8 // OVERVIEW
9 // 9 //
10 // A MetricsService instance is typically created at application startup. It is 10 // A MetricsService instance is typically created at application startup. It is
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 279
280 MetricsService::ExecutionPhase MetricsService::execution_phase_ = 280 MetricsService::ExecutionPhase MetricsService::execution_phase_ =
281 MetricsService::UNINITIALIZED_PHASE; 281 MetricsService::UNINITIALIZED_PHASE;
282 282
283 // static 283 // static
284 void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) { 284 void MetricsService::RegisterPrefs(PrefRegistrySimple* registry) {
285 DCHECK(IsSingleThreaded()); 285 DCHECK(IsSingleThreaded());
286 metrics::MetricsStateManager::RegisterPrefs(registry); 286 metrics::MetricsStateManager::RegisterPrefs(registry);
287 MetricsLog::RegisterPrefs(registry); 287 MetricsLog::RegisterPrefs(registry);
288 288
289 registry->RegisterInt64Pref(metrics::prefs::kInstallDate, 0);
290
289 registry->RegisterInt64Pref(metrics::prefs::kStabilityLaunchTimeSec, 0); 291 registry->RegisterInt64Pref(metrics::prefs::kStabilityLaunchTimeSec, 0);
290 registry->RegisterInt64Pref(metrics::prefs::kStabilityLastTimestampSec, 0); 292 registry->RegisterInt64Pref(metrics::prefs::kStabilityLastTimestampSec, 0);
291 registry->RegisterStringPref(metrics::prefs::kStabilityStatsVersion, 293 registry->RegisterStringPref(metrics::prefs::kStabilityStatsVersion,
292 std::string()); 294 std::string());
293 registry->RegisterInt64Pref(metrics::prefs::kStabilityStatsBuildTime, 0); 295 registry->RegisterInt64Pref(metrics::prefs::kStabilityStatsBuildTime, 0);
294 registry->RegisterBooleanPref(metrics::prefs::kStabilityExitedCleanly, true); 296 registry->RegisterBooleanPref(metrics::prefs::kStabilityExitedCleanly, true);
295 registry->RegisterIntegerPref(metrics::prefs::kStabilityExecutionPhase, 297 registry->RegisterIntegerPref(metrics::prefs::kStabilityExecutionPhase,
296 UNINITIALIZED_PHASE); 298 UNINITIALIZED_PHASE);
297 registry->RegisterBooleanPref(metrics::prefs::kStabilitySessionEndCompleted, 299 registry->RegisterBooleanPref(metrics::prefs::kStabilitySessionEndCompleted,
298 true); 300 true);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 } 378 }
377 379
378 void MetricsService::DisableReporting() { 380 void MetricsService::DisableReporting() {
379 reporting_active_ = false; 381 reporting_active_ = false;
380 } 382 }
381 383
382 std::string MetricsService::GetClientId() { 384 std::string MetricsService::GetClientId() {
383 return state_manager_->client_id(); 385 return state_manager_->client_id();
384 } 386 }
385 387
388 int64 MetricsService::GetInstallDate() {
389 return local_state_->GetInt64(metrics::prefs::kInstallDate);
390 }
391
386 scoped_ptr<const base::FieldTrial::EntropyProvider> 392 scoped_ptr<const base::FieldTrial::EntropyProvider>
387 MetricsService::CreateEntropyProvider() { 393 MetricsService::CreateEntropyProvider() {
388 // TODO(asvitkine): Refactor the code so that MetricsService does not expose 394 // TODO(asvitkine): Refactor the code so that MetricsService does not expose
389 // this method. 395 // this method.
390 return state_manager_->CreateEntropyProvider(); 396 return state_manager_->CreateEntropyProvider();
391 } 397 }
392 398
393 void MetricsService::EnableRecording() { 399 void MetricsService::EnableRecording() {
394 DCHECK(IsSingleThreaded()); 400 DCHECK(IsSingleThreaded());
395 401
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 739
734 // Put incremental data (histogram deltas, and realtime stats deltas) at the 740 // Put incremental data (histogram deltas, and realtime stats deltas) at the
735 // end of all log transmissions (initial log handles this separately). 741 // end of all log transmissions (initial log handles this separately).
736 // RecordIncrementalStabilityElements only exists on the derived 742 // RecordIncrementalStabilityElements only exists on the derived
737 // MetricsLog class. 743 // MetricsLog class.
738 MetricsLog* current_log = 744 MetricsLog* current_log =
739 static_cast<MetricsLog*>(log_manager_.current_log()); 745 static_cast<MetricsLog*>(log_manager_.current_log());
740 DCHECK(current_log); 746 DCHECK(current_log);
741 std::vector<variations::ActiveGroupId> synthetic_trials; 747 std::vector<variations::ActiveGroupId> synthetic_trials;
742 GetCurrentSyntheticFieldTrials(&synthetic_trials); 748 GetCurrentSyntheticFieldTrials(&synthetic_trials);
743 current_log->RecordEnvironment(metrics_providers_.get(), synthetic_trials); 749 current_log->RecordEnvironment(
750 metrics_providers_.get(), synthetic_trials, GetInstallDate());
744 base::TimeDelta incremental_uptime; 751 base::TimeDelta incremental_uptime;
745 base::TimeDelta uptime; 752 base::TimeDelta uptime;
746 GetUptimes(local_state_, &incremental_uptime, &uptime); 753 GetUptimes(local_state_, &incremental_uptime, &uptime);
747 current_log->RecordStabilityMetrics(metrics_providers_.get(), 754 current_log->RecordStabilityMetrics(metrics_providers_.get(),
748 incremental_uptime, uptime); 755 incremental_uptime, uptime);
749 756
750 RecordCurrentHistograms(); 757 RecordCurrentHistograms();
751 current_log->RecordGeneralMetrics(metrics_providers_.get()); 758 current_log->RecordGeneralMetrics(metrics_providers_.get());
752 759
753 log_manager_.FinishCurrentLog(); 760 log_manager_.FinishCurrentLog();
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 953
947 has_initial_stability_log_ = true; 954 has_initial_stability_log_ = true;
948 } 955 }
949 956
950 void MetricsService::PrepareInitialMetricsLog() { 957 void MetricsService::PrepareInitialMetricsLog() {
951 DCHECK(state_ == INIT_TASK_DONE || state_ == SENDING_INITIAL_STABILITY_LOG); 958 DCHECK(state_ == INIT_TASK_DONE || state_ == SENDING_INITIAL_STABILITY_LOG);
952 959
953 std::vector<variations::ActiveGroupId> synthetic_trials; 960 std::vector<variations::ActiveGroupId> synthetic_trials;
954 GetCurrentSyntheticFieldTrials(&synthetic_trials); 961 GetCurrentSyntheticFieldTrials(&synthetic_trials);
955 initial_metrics_log_->RecordEnvironment(metrics_providers_.get(), 962 initial_metrics_log_->RecordEnvironment(metrics_providers_.get(),
956 synthetic_trials); 963 synthetic_trials,
964 GetInstallDate());
957 base::TimeDelta incremental_uptime; 965 base::TimeDelta incremental_uptime;
958 base::TimeDelta uptime; 966 base::TimeDelta uptime;
959 GetUptimes(local_state_, &incremental_uptime, &uptime); 967 GetUptimes(local_state_, &incremental_uptime, &uptime);
960 968
961 // Histograms only get written to the current log, so make the new log current 969 // Histograms only get written to the current log, so make the new log current
962 // before writing them. 970 // before writing them.
963 log_manager_.PauseCurrentLog(); 971 log_manager_.PauseCurrentLog();
964 log_manager_.BeginLoggingWithLog(initial_metrics_log_.Pass()); 972 log_manager_.BeginLoggingWithLog(initial_metrics_log_.Pass());
965 973
966 // Note: Some stability providers may record stability stats via histograms, 974 // Note: Some stability providers may record stability stats via histograms,
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 RecordCurrentState(local_state_); 1205 RecordCurrentState(local_state_);
1198 } 1206 }
1199 1207
1200 void MetricsService::RecordCurrentState(PrefService* pref) { 1208 void MetricsService::RecordCurrentState(PrefService* pref) {
1201 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec, 1209 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec,
1202 Time::Now().ToTimeT()); 1210 Time::Now().ToTimeT());
1203 1211
1204 for (size_t i = 0; i < metrics_providers_.size(); ++i) 1212 for (size_t i = 0; i < metrics_providers_.size(); ++i)
1205 metrics_providers_[i]->RecordCurrentState(); 1213 metrics_providers_[i]->RecordCurrentState();
1206 } 1214 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698