OLD | NEW |
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 #include "base/strings/string_number_conversions.h" | 142 #include "base/strings/string_number_conversions.h" |
143 #include "base/strings/utf_string_conversions.h" | 143 #include "base/strings/utf_string_conversions.h" |
144 #include "base/thread_task_runner_handle.h" | 144 #include "base/thread_task_runner_handle.h" |
145 #include "base/threading/platform_thread.h" | 145 #include "base/threading/platform_thread.h" |
146 #include "base/threading/thread.h" | 146 #include "base/threading/thread.h" |
147 #include "base/threading/thread_restrictions.h" | 147 #include "base/threading/thread_restrictions.h" |
148 #include "base/time/time.h" | 148 #include "base/time/time.h" |
149 #include "base/tracked_objects.h" | 149 #include "base/tracked_objects.h" |
150 #include "base/values.h" | 150 #include "base/values.h" |
151 #include "build/build_config.h" | 151 #include "build/build_config.h" |
| 152 #include "components/metrics/metrics_data_use_measurements.h" |
152 #include "components/metrics/metrics_log.h" | 153 #include "components/metrics/metrics_log.h" |
153 #include "components/metrics/metrics_log_manager.h" | 154 #include "components/metrics/metrics_log_manager.h" |
154 #include "components/metrics/metrics_log_uploader.h" | 155 #include "components/metrics/metrics_log_uploader.h" |
155 #include "components/metrics/metrics_pref_names.h" | 156 #include "components/metrics/metrics_pref_names.h" |
156 #include "components/metrics/metrics_reporting_scheduler.h" | 157 #include "components/metrics/metrics_reporting_scheduler.h" |
157 #include "components/metrics/metrics_service_client.h" | 158 #include "components/metrics/metrics_service_client.h" |
158 #include "components/metrics/metrics_state_manager.h" | 159 #include "components/metrics/metrics_state_manager.h" |
159 #include "components/prefs/pref_registry_simple.h" | 160 #include "components/prefs/pref_registry_simple.h" |
160 #include "components/prefs/pref_service.h" | 161 #include "components/prefs/pref_service.h" |
161 #include "components/variations/entropy_provider.h" | 162 #include "components/variations/entropy_provider.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 state_saver_factory_(this) { | 299 state_saver_factory_(this) { |
299 DCHECK(IsSingleThreaded()); | 300 DCHECK(IsSingleThreaded()); |
300 DCHECK(state_manager_); | 301 DCHECK(state_manager_); |
301 DCHECK(client_); | 302 DCHECK(client_); |
302 DCHECK(local_state_); | 303 DCHECK(local_state_); |
303 | 304 |
304 // Set the install date if this is our first run. | 305 // Set the install date if this is our first run. |
305 int64_t install_date = local_state_->GetInt64(prefs::kInstallDate); | 306 int64_t install_date = local_state_->GetInt64(prefs::kInstallDate); |
306 if (install_date == 0) | 307 if (install_date == 0) |
307 local_state_->SetInt64(prefs::kInstallDate, base::Time::Now().ToTimeT()); | 308 local_state_->SetInt64(prefs::kInstallDate, base::Time::Now().ToTimeT()); |
| 309 MetricsDataUseMeasurements::Initialize(local_state_); |
308 } | 310 } |
309 | 311 |
310 MetricsService::~MetricsService() { | 312 MetricsService::~MetricsService() { |
311 DisableRecording(); | 313 DisableRecording(); |
312 } | 314 } |
313 | 315 |
314 void MetricsService::InitializeMetricsRecordingState() { | 316 void MetricsService::InitializeMetricsRecordingState() { |
315 InitializeMetricsState(); | 317 InitializeMetricsState(); |
316 | 318 |
317 base::Closure upload_callback = | 319 base::Closure upload_callback = |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 } | 861 } |
860 if (!log_manager_.has_unsent_logs()) { | 862 if (!log_manager_.has_unsent_logs()) { |
861 // Should only get here if serializing the log failed somehow. | 863 // Should only get here if serializing the log failed somehow. |
862 // Just tell the scheduler it was uploaded and wait for the next log | 864 // Just tell the scheduler it was uploaded and wait for the next log |
863 // interval. | 865 // interval. |
864 scheduler_->UploadFinished(true, log_manager_.has_unsent_logs()); | 866 scheduler_->UploadFinished(true, log_manager_.has_unsent_logs()); |
865 return; | 867 return; |
866 } | 868 } |
867 if (!log_manager_.has_staged_log()) | 869 if (!log_manager_.has_staged_log()) |
868 log_manager_.StageNextLogForUpload(); | 870 log_manager_.StageNextLogForUpload(); |
869 SendStagedLog(); | 871 if (MetricsDataUseMeasurements::GetInstance()->CanUploadUMALog( |
| 872 log_manager_.staged_log_hash().size())) |
| 873 SendStagedLog(); |
| 874 else |
| 875 scheduler_->UploadCancelled(); |
870 } | 876 } |
871 | 877 |
872 bool MetricsService::ProvidersHaveInitialStabilityMetrics() { | 878 bool MetricsService::ProvidersHaveInitialStabilityMetrics() { |
873 // Check whether any metrics provider has initial stability metrics. | 879 // Check whether any metrics provider has initial stability metrics. |
874 for (MetricsProvider* provider : metrics_providers_) { | 880 for (MetricsProvider* provider : metrics_providers_) { |
875 if (provider->HasInitialStabilityMetrics()) | 881 if (provider->HasInitialStabilityMetrics()) |
876 return true; | 882 return true; |
877 } | 883 } |
878 | 884 |
879 return false; | 885 return false; |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 base::Time::Now().ToTimeT()); | 1167 base::Time::Now().ToTimeT()); |
1162 } | 1168 } |
1163 | 1169 |
1164 void MetricsService::SkipAndDiscardUpload() { | 1170 void MetricsService::SkipAndDiscardUpload() { |
1165 log_manager_.DiscardStagedLog(); | 1171 log_manager_.DiscardStagedLog(); |
1166 scheduler_->UploadCancelled(); | 1172 scheduler_->UploadCancelled(); |
1167 log_upload_in_progress_ = false; | 1173 log_upload_in_progress_ = false; |
1168 } | 1174 } |
1169 | 1175 |
1170 } // namespace metrics | 1176 } // namespace metrics |
OLD | NEW |