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

Unified Diff: components/ukm/ukm_service.cc

Issue 2736683003: Handle the case where Purge is called while upload is in progress. (Closed)
Patch Set: Update test 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 a43f426f346986148a9a15738dfc4f7c2a885207..b44cf5e3005415db08e8ff6d71846b036852d225 100644
--- a/components/ukm/ukm_service.cc
+++ b/components/ukm/ukm_service.cc
@@ -397,23 +397,25 @@ void UkmService::OnLogUploadComplete(int 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) {
- // TODO(holte): The if below is a temporary fix for a crash bug. We should
- // revisit the logic and update it with a more correct fix. crbug.com/698819
- if (persisted_logs_.has_staged_log())
+ // Staged log may have been deleted by Purge already, otherwise we may
+ // remove it from the log store here.
+ 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();
+ // Store the updated list to disk now that the removed log is uploaded.
+ persisted_logs_.PersistUnsentLogs();
+ }
}
// 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