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

Unified Diff: components/ukm/ukm_service.cc

Issue 2736683003: Handle the case where Purge is called while upload is in progress. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/ukm/ukm_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ukm/ukm_service.cc
diff --git a/components/ukm/ukm_service.cc b/components/ukm/ukm_service.cc
index c58eef8482c8c17680a4359290e250e67d3e914c..0c7829077d2da046cb5633b4d8e71ef66620dc04 100644
--- a/components/ukm/ukm_service.cc
+++ b/components/ukm/ukm_service.cc
@@ -298,21 +298,27 @@ void UkmService::OnLogUploadComplete(int response_code) {
UMA_HISTOGRAM_SPARSE_SLOWLY("UKM.Upload.ResponseCode", response_code);
bool upload_succeeded = response_code == 200;
-
- // Provide boolean for error recovery (allow us to ignore response_code).
- bool discard_log = false;
- const size_t log_size_bytes = persisted_logs_.staged_log().length();
- if (upload_succeeded) {
- UMA_HISTOGRAM_COUNTS_10000("UKM.LogSize.OnSuccess", log_size_bytes / 1024);
- } else if (response_code == 400) {
- // Bad syntax. Retransmission won't work.
- discard_log = true;
- }
-
- if (upload_succeeded || discard_log) {
- persisted_logs_.DiscardStagedLog();
Alexei Svitkine (slow) 2017/03/07 22:02:10 You'll need to rebase on my change.
Steven Holte 2017/03/07 22:26:18 Done.
- // Store the updated list to disk now that the removed log is uploaded.
- persisted_logs_.PersistUnsentLogs();
+ if (persisted_logs_.has_staged_log()) {
+ // Provide boolean for error recovery (allow us to ignore response_code).
+ bool discard_log = false;
+ const size_t log_size_bytes = persisted_logs_.staged_log().length();
+ if (upload_succeeded) {
+ UMA_HISTOGRAM_COUNTS_10000("UKM.LogSize.OnSuccess",
+ log_size_bytes / 1024);
+ } else if (response_code == 400) {
+ // Bad syntax. Retransmission won't work.
+ discard_log = true;
+ }
+
+ if (upload_succeeded || discard_log) {
+ persisted_logs_.DiscardStagedLog();
+ // Store the updated list to disk now that the removed log is uploaded.
+ persisted_logs_.PersistUnsentLogs();
+ }
+ } else {
+ // Staged log may have been deleted by Purge already.
+ UMA_HISTOGRAM_SPARSE_SLOWLY("UKM.Upload.Purged.ResponseCode",
Alexei Svitkine (slow) 2017/03/07 22:02:10 I don't understand why we should do a separate cod
Steven Holte 2017/03/07 22:26:18 Was just adding this to record how often it actual
+ response_code);
}
// Error 400 indicates a problem with the log, not with the server, so
« no previous file with comments | « no previous file | components/ukm/ukm_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698