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

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

Issue 1030503003: Metrics log modification to handle external components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: newlinewq Created 5 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 unified diff | Download patch
« no previous file with comments | « components/metrics/metrics_service.h ('k') | components/metrics/metrics_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 } 346 }
347 347
348 std::string MetricsService::GetClientId() { 348 std::string MetricsService::GetClientId() {
349 return state_manager_->client_id(); 349 return state_manager_->client_id();
350 } 350 }
351 351
352 int64 MetricsService::GetInstallDate() { 352 int64 MetricsService::GetInstallDate() {
353 return local_state_->GetInt64(prefs::kInstallDate); 353 return local_state_->GetInt64(prefs::kInstallDate);
354 } 354 }
355 355
356 int64 MetricsService::GetMetricsReportingEnabledDate() {
357 return local_state_->GetInt64(prefs::kMetricsReportingEnabledTimestamp);
358 }
359
356 scoped_ptr<const base::FieldTrial::EntropyProvider> 360 scoped_ptr<const base::FieldTrial::EntropyProvider>
357 MetricsService::CreateEntropyProvider() { 361 MetricsService::CreateEntropyProvider() {
358 // TODO(asvitkine): Refactor the code so that MetricsService does not expose 362 // TODO(asvitkine): Refactor the code so that MetricsService does not expose
359 // this method. 363 // this method.
360 return state_manager_->CreateEntropyProvider(); 364 return state_manager_->CreateEntropyProvider();
361 } 365 }
362 366
363 void MetricsService::EnableRecording() { 367 void MetricsService::EnableRecording() {
364 DCHECK(IsSingleThreaded()); 368 DCHECK(IsSingleThreaded());
365 369
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 515
512 // Reset the prefs that are managed by MetricsService/MetricsLog directly. 516 // Reset the prefs that are managed by MetricsService/MetricsLog directly.
513 local_state_->SetInteger(prefs::kStabilityCrashCount, 0); 517 local_state_->SetInteger(prefs::kStabilityCrashCount, 0);
514 local_state_->SetInteger(prefs::kStabilityExecutionPhase, 518 local_state_->SetInteger(prefs::kStabilityExecutionPhase,
515 UNINITIALIZED_PHASE); 519 UNINITIALIZED_PHASE);
516 local_state_->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0); 520 local_state_->SetInteger(prefs::kStabilityIncompleteSessionEndCount, 0);
517 local_state_->SetInteger(prefs::kStabilityLaunchCount, 0); 521 local_state_->SetInteger(prefs::kStabilityLaunchCount, 0);
518 local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, true); 522 local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, true);
519 } 523 }
520 524
525 void MetricsService::PushExternalLog(const std::string& log) {
526 log_manager_.StoreLog(log, MetricsLog::ONGOING_LOG);
527 }
528
521 //------------------------------------------------------------------------------ 529 //------------------------------------------------------------------------------
522 // private methods 530 // private methods
523 //------------------------------------------------------------------------------ 531 //------------------------------------------------------------------------------
524 532
525 533
526 //------------------------------------------------------------------------------ 534 //------------------------------------------------------------------------------
527 // Initialization methods 535 // Initialization methods
528 536
529 void MetricsService::InitializeMetricsState() { 537 void MetricsService::InitializeMetricsState() {
530 const int64 buildtime = MetricsLog::GetBuildTime(); 538 const int64 buildtime = MetricsLog::GetBuildTime();
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 session_id_, 1087 session_id_,
1080 log_type, 1088 log_type,
1081 client_, 1089 client_,
1082 local_state_)); 1090 local_state_));
1083 } 1091 }
1084 1092
1085 void MetricsService::RecordCurrentEnvironment(MetricsLog* log) { 1093 void MetricsService::RecordCurrentEnvironment(MetricsLog* log) {
1086 std::vector<variations::ActiveGroupId> synthetic_trials; 1094 std::vector<variations::ActiveGroupId> synthetic_trials;
1087 GetCurrentSyntheticFieldTrials(&synthetic_trials); 1095 GetCurrentSyntheticFieldTrials(&synthetic_trials);
1088 log->RecordEnvironment(metrics_providers_.get(), synthetic_trials, 1096 log->RecordEnvironment(metrics_providers_.get(), synthetic_trials,
1089 GetInstallDate()); 1097 GetInstallDate(), GetMetricsReportingEnabledDate());
1090 UMA_HISTOGRAM_COUNTS_100("UMA.SyntheticTrials.Count", 1098 UMA_HISTOGRAM_COUNTS_100("UMA.SyntheticTrials.Count",
1091 synthetic_trials.size()); 1099 synthetic_trials.size());
1092 } 1100 }
1093 1101
1094 void MetricsService::RecordCurrentHistograms() { 1102 void MetricsService::RecordCurrentHistograms() {
1095 DCHECK(log_manager_.current_log()); 1103 DCHECK(log_manager_.current_log());
1096 histogram_snapshot_manager_.PrepareDeltas( 1104 histogram_snapshot_manager_.PrepareDeltas(
1097 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag); 1105 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag);
1098 } 1106 }
1099 1107
(...skipping 29 matching lines...) Expand all
1129 local_state_->SetBoolean(path, value); 1137 local_state_->SetBoolean(path, value);
1130 RecordCurrentState(local_state_); 1138 RecordCurrentState(local_state_);
1131 } 1139 }
1132 1140
1133 void MetricsService::RecordCurrentState(PrefService* pref) { 1141 void MetricsService::RecordCurrentState(PrefService* pref) {
1134 pref->SetInt64(prefs::kStabilityLastTimestampSec, 1142 pref->SetInt64(prefs::kStabilityLastTimestampSec,
1135 base::Time::Now().ToTimeT()); 1143 base::Time::Now().ToTimeT());
1136 } 1144 }
1137 1145
1138 } // namespace metrics 1146 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/metrics_service.h ('k') | components/metrics/metrics_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698