Chromium Code Reviews| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 | 193 |
| 194 // If an upload fails, and the transmission was over this byte count, then we | 194 // If an upload fails, and the transmission was over this byte count, then we |
| 195 // will discard the log, and not try to retransmit it. We also don't persist | 195 // will discard the log, and not try to retransmit it. We also don't persist |
| 196 // the log to the prefs for transmission during the next chrome session if this | 196 // the log to the prefs for transmission during the next chrome session if this |
| 197 // limit is exceeded. | 197 // limit is exceeded. |
| 198 const size_t kUploadLogAvoidRetransmitSize = 100 * 1024; | 198 const size_t kUploadLogAvoidRetransmitSize = 100 * 1024; |
| 199 | 199 |
| 200 // Interval, in minutes, between state saves. | 200 // Interval, in minutes, between state saves. |
| 201 const int kSaveStateIntervalMinutes = 5; | 201 const int kSaveStateIntervalMinutes = 5; |
| 202 | 202 |
| 203 // Default sampling rate for UMA log uploads | |
| 204 const int kDefaultSamplingProbability = 100; | |
| 205 | |
| 203 enum ResponseStatus { | 206 enum ResponseStatus { |
| 204 UNKNOWN_FAILURE, | 207 UNKNOWN_FAILURE, |
| 205 SUCCESS, | 208 SUCCESS, |
| 206 BAD_REQUEST, // Invalid syntax or log too large. | 209 BAD_REQUEST, // Invalid syntax or log too large. |
| 207 NO_RESPONSE, | 210 NO_RESPONSE, |
| 208 NUM_RESPONSE_STATUSES | 211 NUM_RESPONSE_STATUSES |
| 209 }; | 212 }; |
| 210 | 213 |
| 211 ResponseStatus ResponseCodeToStatus(int response_code) { | 214 ResponseStatus ResponseCodeToStatus(int response_code) { |
| 212 switch (response_code) { | 215 switch (response_code) { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 228 local_state->SetInteger(prefs::kStabilityExecutionPhase, | 231 local_state->SetInteger(prefs::kStabilityExecutionPhase, |
| 229 MetricsService::SHUTDOWN_COMPLETE); | 232 MetricsService::SHUTDOWN_COMPLETE); |
| 230 // Start writing right away (write happens on a different thread). | 233 // Start writing right away (write happens on a different thread). |
| 231 local_state->CommitPendingWrite(); | 234 local_state->CommitPendingWrite(); |
| 232 } | 235 } |
| 233 #endif // defined(OS_ANDROID) || defined(OS_IOS) | 236 #endif // defined(OS_ANDROID) || defined(OS_IOS) |
| 234 | 237 |
| 235 // Determines if current log should be sent based on sampling rate. Returns true | 238 // Determines if current log should be sent based on sampling rate. Returns true |
| 236 // if the sampling rate is not set. | 239 // if the sampling rate is not set. |
| 237 bool ShouldUploadLog() { | 240 bool ShouldUploadLog() { |
| 241 std::string experiment_group = | |
| 242 base::FieldTrialList::FindFullName("UMA_EnableCellularLogUpload"); | |
| 243 if (experiment_group.empty()) | |
| 244 return true; | |
| 245 | |
| 238 std::string probability_str = variations::GetVariationParamValue( | 246 std::string probability_str = variations::GetVariationParamValue( |
| 239 "UMA_EnableCellularLogUpload", "Sample_Probability"); | 247 "UMA_EnableCellularLogUpload", "Sample_Probability"); |
| 248 int probability; | |
| 240 if (probability_str.empty()) | 249 if (probability_str.empty()) |
| 241 return true; | 250 probability = kDefaultSamplingProbability; |
|
Alexei Svitkine (slow)
2016/05/13 20:21:09
I think we discussed offline that we could just re
gayane -on leave until 09-2017
2016/05/13 20:43:00
Done.
| |
| 242 | 251 |
| 243 int probability; | |
| 244 // In case specified sampling rate is invalid. | 252 // In case specified sampling rate is invalid. |
| 245 if (!base::StringToInt(probability_str, &probability)) | 253 if (!base::StringToInt(probability_str, &probability)) |
| 246 return true; | 254 return true; |
| 247 return base::RandInt(1, 100) <= probability; | 255 return base::RandInt(1, 100) <= probability; |
| 248 } | 256 } |
| 249 | 257 |
| 250 } // namespace | 258 } // namespace |
| 251 | 259 |
| 252 // static | 260 // static |
| 253 MetricsService::ShutdownCleanliness MetricsService::clean_shutdown_status_ = | 261 MetricsService::ShutdownCleanliness MetricsService::clean_shutdown_status_ = |
| (...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1191 base::Time::Now().ToTimeT()); | 1199 base::Time::Now().ToTimeT()); |
| 1192 } | 1200 } |
| 1193 | 1201 |
| 1194 void MetricsService::SkipAndDiscardUpload() { | 1202 void MetricsService::SkipAndDiscardUpload() { |
| 1195 log_manager_.DiscardStagedLog(); | 1203 log_manager_.DiscardStagedLog(); |
| 1196 scheduler_->UploadCancelled(); | 1204 scheduler_->UploadCancelled(); |
| 1197 log_upload_in_progress_ = false; | 1205 log_upload_in_progress_ = false; |
| 1198 } | 1206 } |
| 1199 | 1207 |
| 1200 } // namespace metrics | 1208 } // namespace metrics |
| OLD | NEW |