| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 registry->RegisterListPref(prefs::kMetricsInitialLogs); | 251 registry->RegisterListPref(prefs::kMetricsInitialLogs); |
| 252 registry->RegisterListPref(prefs::kMetricsOngoingLogs); | 252 registry->RegisterListPref(prefs::kMetricsOngoingLogs); |
| 253 | 253 |
| 254 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); | 254 registry->RegisterInt64Pref(prefs::kUninstallLaunchCount, 0); |
| 255 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); | 255 registry->RegisterInt64Pref(prefs::kUninstallMetricsUptimeSec, 0); |
| 256 } | 256 } |
| 257 | 257 |
| 258 MetricsService::MetricsService(MetricsStateManager* state_manager, | 258 MetricsService::MetricsService(MetricsStateManager* state_manager, |
| 259 MetricsServiceClient* client, | 259 MetricsServiceClient* client, |
| 260 PrefService* local_state) | 260 PrefService* local_state) |
| 261 : log_manager_(local_state, kUploadLogAvoidRetransmitSize), | 261 : log_store_(local_state, kUploadLogAvoidRetransmitSize), |
| 262 histogram_snapshot_manager_(this), | 262 histogram_snapshot_manager_(this), |
| 263 state_manager_(state_manager), | 263 state_manager_(state_manager), |
| 264 client_(client), | 264 client_(client), |
| 265 local_state_(local_state), | 265 local_state_(local_state), |
| 266 clean_exit_beacon_(client->GetRegistryBackupKey(), local_state), | 266 clean_exit_beacon_(client->GetRegistryBackupKey(), local_state), |
| 267 recording_state_(UNSET), | 267 recording_state_(UNSET), |
| 268 reporting_active_(false), | 268 reporting_active_(false), |
| 269 test_mode_active_(false), | 269 test_mode_active_(false), |
| 270 state_(INITIALIZED), | 270 state_(INITIALIZED), |
| 271 log_upload_in_progress_(false), | 271 log_upload_in_progress_(false), |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 StabilityMetricsProvider(local_state_) | 513 StabilityMetricsProvider(local_state_) |
| 514 .RecordBreakpadHasDebugger(has_debugger); | 514 .RecordBreakpadHasDebugger(has_debugger); |
| 515 } | 515 } |
| 516 | 516 |
| 517 void MetricsService::ClearSavedStabilityMetrics() { | 517 void MetricsService::ClearSavedStabilityMetrics() { |
| 518 for (auto& provider : metrics_providers_) | 518 for (auto& provider : metrics_providers_) |
| 519 provider->ClearSavedStabilityMetrics(); | 519 provider->ClearSavedStabilityMetrics(); |
| 520 } | 520 } |
| 521 | 521 |
| 522 void MetricsService::PushExternalLog(const std::string& log) { | 522 void MetricsService::PushExternalLog(const std::string& log) { |
| 523 log_manager_.StoreLog(log, MetricsLog::ONGOING_LOG); | 523 log_store_.StoreLog(log, MetricsLog::ONGOING_LOG); |
| 524 } | 524 } |
| 525 | 525 |
| 526 void MetricsService::UpdateMetricsUsagePrefs(const std::string& service_name, | 526 void MetricsService::UpdateMetricsUsagePrefs(const std::string& service_name, |
| 527 int message_size, | 527 int message_size, |
| 528 bool is_cellular) { | 528 bool is_cellular) { |
| 529 DCHECK(thread_checker_.CalledOnValidThread()); | 529 DCHECK(thread_checker_.CalledOnValidThread()); |
| 530 if (data_use_tracker_) { | 530 if (data_use_tracker_) { |
| 531 data_use_tracker_->UpdateMetricsUsagePrefs(service_name, | 531 data_use_tracker_->UpdateMetricsUsagePrefs(service_name, |
| 532 message_size, | 532 message_size, |
| 533 is_cellular); | 533 is_cellular); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 548 | 548 |
| 549 bool version_changed = false; | 549 bool version_changed = false; |
| 550 EnvironmentRecorder recorder(local_state_); | 550 EnvironmentRecorder recorder(local_state_); |
| 551 int64_t previous_buildtime = recorder.GetLastBuildtime(); | 551 int64_t previous_buildtime = recorder.GetLastBuildtime(); |
| 552 std::string previous_version = recorder.GetLastVersion(); | 552 std::string previous_version = recorder.GetLastVersion(); |
| 553 if (previous_buildtime != buildtime || previous_version != version) { | 553 if (previous_buildtime != buildtime || previous_version != version) { |
| 554 recorder.SetBuildtimeAndVersion(buildtime, version); | 554 recorder.SetBuildtimeAndVersion(buildtime, version); |
| 555 version_changed = true; | 555 version_changed = true; |
| 556 } | 556 } |
| 557 | 557 |
| 558 log_manager_.LoadPersistedUnsentLogs(); | 558 log_store_.LoadPersistedUnsentLogs(); |
| 559 | 559 |
| 560 session_id_ = local_state_->GetInteger(prefs::kMetricsSessionID); | 560 session_id_ = local_state_->GetInteger(prefs::kMetricsSessionID); |
| 561 | 561 |
| 562 StabilityMetricsProvider provider(local_state_); | 562 StabilityMetricsProvider provider(local_state_); |
| 563 if (!clean_exit_beacon_.exited_cleanly()) { | 563 if (!clean_exit_beacon_.exited_cleanly()) { |
| 564 provider.LogCrash(); | 564 provider.LogCrash(); |
| 565 // Reset flag, and wait until we call LogNeedForCleanShutdown() before | 565 // Reset flag, and wait until we call LogNeedForCleanShutdown() before |
| 566 // monitoring. | 566 // monitoring. |
| 567 clean_exit_beacon_.WriteBeaconValue(true); | 567 clean_exit_beacon_.WriteBeaconValue(true); |
| 568 ExecutionPhaseManager manager(local_state_); | 568 ExecutionPhaseManager manager(local_state_); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 RecordCurrentEnvironment(current_log); | 735 RecordCurrentEnvironment(current_log); |
| 736 base::TimeDelta incremental_uptime; | 736 base::TimeDelta incremental_uptime; |
| 737 base::TimeDelta uptime; | 737 base::TimeDelta uptime; |
| 738 GetUptimes(local_state_, &incremental_uptime, &uptime); | 738 GetUptimes(local_state_, &incremental_uptime, &uptime); |
| 739 current_log->RecordStabilityMetrics(metrics_providers_, incremental_uptime, | 739 current_log->RecordStabilityMetrics(metrics_providers_, incremental_uptime, |
| 740 uptime); | 740 uptime); |
| 741 | 741 |
| 742 current_log->RecordGeneralMetrics(metrics_providers_); | 742 current_log->RecordGeneralMetrics(metrics_providers_); |
| 743 RecordCurrentHistograms(); | 743 RecordCurrentHistograms(); |
| 744 DVLOG(1) << "Generated an ongoing log."; | 744 DVLOG(1) << "Generated an ongoing log."; |
| 745 log_manager_.FinishCurrentLog(); | 745 log_manager_.FinishCurrentLog(&log_store_); |
| 746 } | 746 } |
| 747 | 747 |
| 748 void MetricsService::PushPendingLogsToPersistentStorage() { | 748 void MetricsService::PushPendingLogsToPersistentStorage() { |
| 749 if (state_ < SENDING_LOGS) | 749 if (state_ < SENDING_LOGS) |
| 750 return; // We didn't and still don't have time to get plugin list etc. | 750 return; // We didn't and still don't have time to get plugin list etc. |
| 751 | 751 |
| 752 CloseCurrentLog(); | 752 CloseCurrentLog(); |
| 753 log_manager_.PersistUnsentLogs(); | 753 log_store_.PersistUnsentLogs(); |
| 754 } | 754 } |
| 755 | 755 |
| 756 //------------------------------------------------------------------------------ | 756 //------------------------------------------------------------------------------ |
| 757 // Transmission of logs methods | 757 // Transmission of logs methods |
| 758 | 758 |
| 759 void MetricsService::StartSchedulerIfNecessary() { | 759 void MetricsService::StartSchedulerIfNecessary() { |
| 760 // Never schedule cutting or uploading of logs in test mode. | 760 // Never schedule cutting or uploading of logs in test mode. |
| 761 if (test_mode_active_) | 761 if (test_mode_active_) |
| 762 return; | 762 return; |
| 763 | 763 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 794 rotation_scheduler_->RotationFinished(); | 794 rotation_scheduler_->RotationFinished(); |
| 795 } else { | 795 } else { |
| 796 scheduler_->Stop(); | 796 scheduler_->Stop(); |
| 797 scheduler_->UploadCancelled(); | 797 scheduler_->UploadCancelled(); |
| 798 } | 798 } |
| 799 return; | 799 return; |
| 800 } | 800 } |
| 801 | 801 |
| 802 // If there are unsent logs, send the next one. If not, start the asynchronous | 802 // If there are unsent logs, send the next one. If not, start the asynchronous |
| 803 // process of finalizing the current log for upload. | 803 // process of finalizing the current log for upload. |
| 804 if (state_ == SENDING_LOGS && log_manager_.has_unsent_logs()) { | 804 if (state_ == SENDING_LOGS && log_store_.has_unsent_logs()) { |
| 805 if (upload_scheduler_) { | 805 if (upload_scheduler_) { |
| 806 upload_scheduler_->Start(); | 806 upload_scheduler_->Start(); |
| 807 rotation_scheduler_->RotationFinished(); | 807 rotation_scheduler_->RotationFinished(); |
| 808 } else { | 808 } else { |
| 809 SendNextLog(); | 809 SendNextLog(); |
| 810 } | 810 } |
| 811 } else { | 811 } else { |
| 812 // There are no logs left to send, so start creating a new one. | 812 // There are no logs left to send, so start creating a new one. |
| 813 client_->CollectFinalMetricsForLog( | 813 client_->CollectFinalMetricsForLog( |
| 814 base::Bind(&MetricsService::OnFinalLogInfoCollectionDone, | 814 base::Bind(&MetricsService::OnFinalLogInfoCollectionDone, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 DCHECK_EQ(SENDING_LOGS, state_); | 861 DCHECK_EQ(SENDING_LOGS, state_); |
| 862 if (!reporting_active()) { | 862 if (!reporting_active()) { |
| 863 if (upload_scheduler_) { | 863 if (upload_scheduler_) { |
| 864 upload_scheduler_->StopAndUploadCancelled(); | 864 upload_scheduler_->StopAndUploadCancelled(); |
| 865 } else { | 865 } else { |
| 866 scheduler_->Stop(); | 866 scheduler_->Stop(); |
| 867 scheduler_->UploadCancelled(); | 867 scheduler_->UploadCancelled(); |
| 868 } | 868 } |
| 869 return; | 869 return; |
| 870 } | 870 } |
| 871 if (!log_manager_.has_unsent_logs()) { | 871 if (!log_store_.has_unsent_logs()) { |
| 872 // Should only get here if serializing the log failed somehow. | 872 // Should only get here if serializing the log failed somehow. |
| 873 if (upload_scheduler_) { | 873 if (upload_scheduler_) { |
| 874 upload_scheduler_->Stop(); | 874 upload_scheduler_->Stop(); |
| 875 // Reset backoff interval | 875 // Reset backoff interval |
| 876 upload_scheduler_->UploadFinished(true); | 876 upload_scheduler_->UploadFinished(true); |
| 877 } else { | 877 } else { |
| 878 // Just tell the scheduler it was uploaded and wait for the next log | 878 // Just tell the scheduler it was uploaded and wait for the next log |
| 879 // interval. | 879 // interval. |
| 880 scheduler_->UploadFinished(true, log_manager_.has_unsent_logs()); | 880 scheduler_->UploadFinished(true, log_store_.has_unsent_logs()); |
| 881 } | 881 } |
| 882 return; | 882 return; |
| 883 } | 883 } |
| 884 if (!log_manager_.has_staged_log()) | 884 if (!log_store_.has_staged_log()) |
| 885 log_manager_.StageNextLogForUpload(); | 885 log_store_.StageNextLog(); |
| 886 | 886 |
| 887 // Proceed to stage the log for upload if log size satisfies cellular log | 887 // Proceed to stage the log for upload if log size satisfies cellular log |
| 888 // upload constrains. | 888 // upload constrains. |
| 889 bool upload_canceled = false; | 889 bool upload_canceled = false; |
| 890 bool is_cellular_logic = client_->IsUMACellularUploadLogicEnabled(); | 890 bool is_cellular_logic = client_->IsUMACellularUploadLogicEnabled(); |
| 891 if (is_cellular_logic && data_use_tracker_ && | 891 if (is_cellular_logic && data_use_tracker_ && |
| 892 !data_use_tracker_->ShouldUploadLogOnCellular( | 892 !data_use_tracker_->ShouldUploadLogOnCellular( |
| 893 log_manager_.staged_log_hash().size())) { | 893 log_store_.staged_log_hash().size())) { |
| 894 if (upload_scheduler_) { | 894 if (upload_scheduler_) { |
| 895 upload_scheduler_->UploadOverDataUsageCap(); | 895 upload_scheduler_->UploadOverDataUsageCap(); |
| 896 } else { | 896 } else { |
| 897 scheduler_->UploadCancelled(); | 897 scheduler_->UploadCancelled(); |
| 898 } | 898 } |
| 899 upload_canceled = true; | 899 upload_canceled = true; |
| 900 } else { | 900 } else { |
| 901 SendStagedLog(); | 901 SendStagedLog(); |
| 902 } | 902 } |
| 903 if (is_cellular_logic) { | 903 if (is_cellular_logic) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 // Note: Some stability providers may record stability stats via histograms, | 941 // Note: Some stability providers may record stability stats via histograms, |
| 942 // so this call has to be after BeginLoggingWithLog(). | 942 // so this call has to be after BeginLoggingWithLog(). |
| 943 log_manager_.current_log()->RecordStabilityMetrics( | 943 log_manager_.current_log()->RecordStabilityMetrics( |
| 944 metrics_providers_, base::TimeDelta(), base::TimeDelta()); | 944 metrics_providers_, base::TimeDelta(), base::TimeDelta()); |
| 945 RecordCurrentStabilityHistograms(); | 945 RecordCurrentStabilityHistograms(); |
| 946 | 946 |
| 947 // Note: RecordGeneralMetrics() intentionally not called since this log is for | 947 // Note: RecordGeneralMetrics() intentionally not called since this log is for |
| 948 // stability stats from a previous session only. | 948 // stability stats from a previous session only. |
| 949 | 949 |
| 950 DVLOG(1) << "Generated an stability log."; | 950 DVLOG(1) << "Generated an stability log."; |
| 951 log_manager_.FinishCurrentLog(); | 951 log_manager_.FinishCurrentLog(&log_store_); |
| 952 log_manager_.ResumePausedLog(); | 952 log_manager_.ResumePausedLog(); |
| 953 | 953 |
| 954 // Store unsent logs, including the stability log that was just saved, so | 954 // Store unsent logs, including the stability log that was just saved, so |
| 955 // that they're not lost in case of a crash before upload time. | 955 // that they're not lost in case of a crash before upload time. |
| 956 log_manager_.PersistUnsentLogs(); | 956 log_store_.PersistUnsentLogs(); |
| 957 | 957 |
| 958 return true; | 958 return true; |
| 959 } | 959 } |
| 960 | 960 |
| 961 void MetricsService::PrepareInitialMetricsLog() { | 961 void MetricsService::PrepareInitialMetricsLog() { |
| 962 DCHECK_EQ(INIT_TASK_DONE, state_); | 962 DCHECK_EQ(INIT_TASK_DONE, state_); |
| 963 | 963 |
| 964 RecordCurrentEnvironment(initial_metrics_log_.get()); | 964 RecordCurrentEnvironment(initial_metrics_log_.get()); |
| 965 base::TimeDelta incremental_uptime; | 965 base::TimeDelta incremental_uptime; |
| 966 base::TimeDelta uptime; | 966 base::TimeDelta uptime; |
| 967 GetUptimes(local_state_, &incremental_uptime, &uptime); | 967 GetUptimes(local_state_, &incremental_uptime, &uptime); |
| 968 | 968 |
| 969 // 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 |
| 970 // before writing them. | 970 // before writing them. |
| 971 log_manager_.PauseCurrentLog(); | 971 log_manager_.PauseCurrentLog(); |
| 972 log_manager_.BeginLoggingWithLog(std::move(initial_metrics_log_)); | 972 log_manager_.BeginLoggingWithLog(std::move(initial_metrics_log_)); |
| 973 | 973 |
| 974 // Note: Some stability providers may record stability stats via histograms, | 974 // Note: Some stability providers may record stability stats via histograms, |
| 975 // so this call has to be after BeginLoggingWithLog(). | 975 // so this call has to be after BeginLoggingWithLog(). |
| 976 MetricsLog* current_log = log_manager_.current_log(); | 976 MetricsLog* current_log = log_manager_.current_log(); |
| 977 current_log->RecordStabilityMetrics(metrics_providers_, base::TimeDelta(), | 977 current_log->RecordStabilityMetrics(metrics_providers_, base::TimeDelta(), |
| 978 base::TimeDelta()); | 978 base::TimeDelta()); |
| 979 current_log->RecordGeneralMetrics(metrics_providers_); | 979 current_log->RecordGeneralMetrics(metrics_providers_); |
| 980 RecordCurrentHistograms(); | 980 RecordCurrentHistograms(); |
| 981 | 981 |
| 982 DVLOG(1) << "Generated an initial log."; | 982 DVLOG(1) << "Generated an initial log."; |
| 983 log_manager_.FinishCurrentLog(); | 983 log_manager_.FinishCurrentLog(&log_store_); |
| 984 log_manager_.ResumePausedLog(); | 984 log_manager_.ResumePausedLog(); |
| 985 | 985 |
| 986 // Store unsent logs, including the initial log that was just saved, so | 986 // Store unsent logs, including the initial log that was just saved, so |
| 987 // that they're not lost in case of a crash before upload time. | 987 // that they're not lost in case of a crash before upload time. |
| 988 log_manager_.PersistUnsentLogs(); | 988 log_store_.PersistUnsentLogs(); |
| 989 | 989 |
| 990 state_ = SENDING_LOGS; | 990 state_ = SENDING_LOGS; |
| 991 } | 991 } |
| 992 | 992 |
| 993 void MetricsService::SendStagedLog() { | 993 void MetricsService::SendStagedLog() { |
| 994 DCHECK(log_manager_.has_staged_log()); | 994 DCHECK(log_store_.has_staged_log()); |
| 995 if (!log_manager_.has_staged_log()) | 995 if (!log_store_.has_staged_log()) |
| 996 return; | 996 return; |
| 997 | 997 |
| 998 DCHECK(!log_upload_in_progress_); | 998 DCHECK(!log_upload_in_progress_); |
| 999 log_upload_in_progress_ = true; | 999 log_upload_in_progress_ = true; |
| 1000 | 1000 |
| 1001 if (!log_uploader_) { | 1001 if (!log_uploader_) { |
| 1002 log_uploader_ = client_->CreateUploader( | 1002 log_uploader_ = client_->CreateUploader( |
| 1003 client_->GetMetricsServerUrl(), | 1003 client_->GetMetricsServerUrl(), |
| 1004 metrics::kDefaultMetricsMimeType, | 1004 metrics::kDefaultMetricsMimeType, |
| 1005 base::Bind(&MetricsService::OnLogUploadComplete, | 1005 base::Bind(&MetricsService::OnLogUploadComplete, |
| 1006 self_ptr_factory_.GetWeakPtr())); | 1006 self_ptr_factory_.GetWeakPtr())); |
| 1007 } | 1007 } |
| 1008 const std::string hash = | 1008 const std::string hash = base::HexEncode(log_store_.staged_log_hash().data(), |
| 1009 base::HexEncode(log_manager_.staged_log_hash().data(), | 1009 log_store_.staged_log_hash().size()); |
| 1010 log_manager_.staged_log_hash().size()); | 1010 log_uploader_->UploadLog(log_store_.staged_log(), hash); |
| 1011 log_uploader_->UploadLog(log_manager_.staged_log(), hash); | |
| 1012 | 1011 |
| 1013 if (!upload_scheduler_) | 1012 if (!upload_scheduler_) |
| 1014 HandleIdleSinceLastTransmission(true); | 1013 HandleIdleSinceLastTransmission(true); |
| 1015 } | 1014 } |
| 1016 | 1015 |
| 1017 | 1016 |
| 1018 void MetricsService::OnLogUploadComplete(int response_code) { | 1017 void MetricsService::OnLogUploadComplete(int response_code) { |
| 1019 DVLOG(1) << "OnLogUploadComplete:" << response_code; | 1018 DVLOG(1) << "OnLogUploadComplete:" << response_code; |
| 1020 if (!upload_scheduler_) | 1019 if (!upload_scheduler_) |
| 1021 DCHECK_EQ(SENDING_LOGS, state_); | 1020 DCHECK_EQ(SENDING_LOGS, state_); |
| 1022 DCHECK(log_upload_in_progress_); | 1021 DCHECK(log_upload_in_progress_); |
| 1023 log_upload_in_progress_ = false; | 1022 log_upload_in_progress_ = false; |
| 1024 | 1023 |
| 1025 // Log a histogram to track response success vs. failure rates. | 1024 // Log a histogram to track response success vs. failure rates. |
| 1026 UMA_HISTOGRAM_ENUMERATION("UMA.UploadResponseStatus.Protobuf", | 1025 UMA_HISTOGRAM_ENUMERATION("UMA.UploadResponseStatus.Protobuf", |
| 1027 ResponseCodeToStatus(response_code), | 1026 ResponseCodeToStatus(response_code), |
| 1028 NUM_RESPONSE_STATUSES); | 1027 NUM_RESPONSE_STATUSES); |
| 1029 | 1028 |
| 1030 bool upload_succeeded = response_code == 200; | 1029 bool upload_succeeded = response_code == 200; |
| 1031 | 1030 |
| 1032 // Provide boolean for error recovery (allow us to ignore response_code). | 1031 // Provide boolean for error recovery (allow us to ignore response_code). |
| 1033 bool discard_log = false; | 1032 bool discard_log = false; |
| 1034 const size_t log_size = log_manager_.staged_log().length(); | 1033 const size_t log_size = log_store_.staged_log().length(); |
| 1035 if (upload_succeeded) { | 1034 if (upload_succeeded) { |
| 1036 UMA_HISTOGRAM_COUNTS_10000("UMA.LogSize.OnSuccess", log_size / 1024); | 1035 UMA_HISTOGRAM_COUNTS_10000("UMA.LogSize.OnSuccess", log_size / 1024); |
| 1037 } else if (log_size > kUploadLogAvoidRetransmitSize) { | 1036 } else if (log_size > kUploadLogAvoidRetransmitSize) { |
| 1038 UMA_HISTOGRAM_COUNTS("UMA.Large Rejected Log was Discarded", | 1037 UMA_HISTOGRAM_COUNTS("UMA.Large Rejected Log was Discarded", |
| 1039 static_cast<int>(log_size)); | 1038 static_cast<int>(log_size)); |
| 1040 discard_log = true; | 1039 discard_log = true; |
| 1041 } else if (response_code == 400) { | 1040 } else if (response_code == 400) { |
| 1042 // Bad syntax. Retransmission won't work. | 1041 // Bad syntax. Retransmission won't work. |
| 1043 discard_log = true; | 1042 discard_log = true; |
| 1044 } | 1043 } |
| 1045 | 1044 |
| 1046 if (upload_succeeded || discard_log) { | 1045 if (upload_succeeded || discard_log) { |
| 1047 log_manager_.DiscardStagedLog(); | 1046 log_store_.DiscardStagedLog(); |
| 1048 // Store the updated list to disk now that the removed log is uploaded. | 1047 // Store the updated list to disk now that the removed log is uploaded. |
| 1049 log_manager_.PersistUnsentLogs(); | 1048 log_store_.PersistUnsentLogs(); |
| 1050 } | 1049 } |
| 1051 | 1050 |
| 1052 // Error 400 indicates a problem with the log, not with the server, so | 1051 // Error 400 indicates a problem with the log, not with the server, so |
| 1053 // don't consider that a sign that the server is in trouble. | 1052 // don't consider that a sign that the server is in trouble. |
| 1054 bool server_is_healthy = upload_succeeded || response_code == 400; | 1053 bool server_is_healthy = upload_succeeded || response_code == 400; |
| 1055 if (upload_scheduler_) { | 1054 if (upload_scheduler_) { |
| 1056 if (!log_manager_.has_unsent_logs()) { | 1055 if (!log_store_.has_unsent_logs()) { |
| 1057 DVLOG(1) << "Stopping upload_scheduler_"; | 1056 DVLOG(1) << "Stopping upload_scheduler_"; |
| 1058 upload_scheduler_->Stop(); | 1057 upload_scheduler_->Stop(); |
| 1059 } | 1058 } |
| 1060 upload_scheduler_->UploadFinished(server_is_healthy); | 1059 upload_scheduler_->UploadFinished(server_is_healthy); |
| 1061 } else { | 1060 } else { |
| 1062 scheduler_->UploadFinished(server_is_healthy, | 1061 scheduler_->UploadFinished(server_is_healthy, log_store_.has_unsent_logs()); |
| 1063 log_manager_.has_unsent_logs()); | |
| 1064 } | 1062 } |
| 1065 } | 1063 } |
| 1066 | 1064 |
| 1067 void MetricsService::IncrementLongPrefsValue(const char* path) { | 1065 void MetricsService::IncrementLongPrefsValue(const char* path) { |
| 1068 int64_t value = local_state_->GetInt64(path); | 1066 int64_t value = local_state_->GetInt64(path); |
| 1069 local_state_->SetInt64(path, value + 1); | 1067 local_state_->SetInt64(path, value + 1); |
| 1070 } | 1068 } |
| 1071 | 1069 |
| 1072 bool MetricsService::UmaMetricsProperlyShutdown() { | 1070 bool MetricsService::UmaMetricsProperlyShutdown() { |
| 1073 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || | 1071 CHECK(clean_shutdown_status_ == CLEANLY_SHUTDOWN || |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 // Redundant setting to assure that we always reset this value at shutdown | 1210 // Redundant setting to assure that we always reset this value at shutdown |
| 1213 // (and that we don't use some alternate path, and not call LogCleanShutdown). | 1211 // (and that we don't use some alternate path, and not call LogCleanShutdown). |
| 1214 clean_shutdown_status_ = CLEANLY_SHUTDOWN; | 1212 clean_shutdown_status_ = CLEANLY_SHUTDOWN; |
| 1215 client_->OnLogCleanShutdown(); | 1213 client_->OnLogCleanShutdown(); |
| 1216 clean_exit_beacon_.WriteBeaconValue(true); | 1214 clean_exit_beacon_.WriteBeaconValue(true); |
| 1217 SetExecutionPhase(ExecutionPhase::SHUTDOWN_COMPLETE, local_state_); | 1215 SetExecutionPhase(ExecutionPhase::SHUTDOWN_COMPLETE, local_state_); |
| 1218 StabilityMetricsProvider(local_state_).MarkSessionEndCompleted(end_completed); | 1216 StabilityMetricsProvider(local_state_).MarkSessionEndCompleted(end_completed); |
| 1219 } | 1217 } |
| 1220 | 1218 |
| 1221 } // namespace metrics | 1219 } // namespace metrics |
| OLD | NEW |