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

Unified Diff: components/metrics/reporting_service.cc

Issue 2770853002: Create Ukm ReportingService implementation. (Closed)
Patch Set: Also revert datatracker unittest change 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 | « components/metrics/metrics_service.cc ('k') | components/ukm/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/reporting_service.cc
diff --git a/components/metrics/reporting_service.cc b/components/metrics/reporting_service.cc
index 8b96d4af2e831aec3cc74f84f9d50bf74e006059..97b926ab0c73cd458d7c9727e1d44566bd6ade52 100644
--- a/components/metrics/reporting_service.cc
+++ b/components/metrics/reporting_service.cc
@@ -166,23 +166,27 @@ void ReportingService::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 = log_store()->staged_log().length();
- if (upload_succeeded) {
- LogSuccess(log_size);
- } else if (log_size > max_retransmit_size_) {
- LogLargeRejection(log_size);
- discard_log = true;
- } else if (response_code == 400) {
- // Bad syntax. Retransmission won't work.
- discard_log = true;
- }
-
- if (upload_succeeded || discard_log) {
- log_store()->DiscardStagedLog();
- // Store the updated list to disk now that the removed log is uploaded.
- log_store()->PersistUnsentLogs();
+ // Staged log could have been removed already (such as by Purge() in some
+ // implementations), otherwise we may remove it here.
+ if (log_store()->has_staged_log()) {
+ // Provide boolean for error recovery (allow us to ignore response_code).
+ bool discard_log = false;
+ const size_t log_size = log_store()->staged_log().length();
+ if (upload_succeeded) {
+ LogSuccess(log_size);
+ } else if (log_size > max_retransmit_size_) {
+ LogLargeRejection(log_size);
+ discard_log = true;
+ } else if (response_code == 400) {
+ // Bad syntax. Retransmission won't work.
+ discard_log = true;
+ }
+
+ if (upload_succeeded || discard_log) {
+ log_store()->DiscardStagedLog();
+ // Store the updated list to disk now that the removed log is uploaded.
+ log_store()->PersistUnsentLogs();
+ }
}
// Error 400 indicates a problem with the log, not with the server, so
« no previous file with comments | « components/metrics/metrics_service.cc ('k') | components/ukm/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698