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

Unified Diff: components/domain_reliability/uploader.cc

Issue 2336043007: Domain Reliability: Don't crash on shutdown with uploads pending (Closed)
Patch Set: No, really. Created 4 years 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
Index: components/domain_reliability/uploader.cc
diff --git a/components/domain_reliability/uploader.cc b/components/domain_reliability/uploader.cc
index f7d4cd9a44c5534b76c2e22c571ef0c825f7c272..d1fbceedfbce85dfbd9b81f794caba96230b5d44 100644
--- a/components/domain_reliability/uploader.cc
+++ b/components/domain_reliability/uploader.cc
@@ -58,9 +58,12 @@ class DomainReliabilityUploaderImpl
net::URLRequestContextGetter>& url_request_context_getter)
: time_(time),
url_request_context_getter_(url_request_context_getter),
- discard_uploads_(true) {}
+ discard_uploads_(true),
+ shutdown_(false) {}
- ~DomainReliabilityUploaderImpl() override {}
+ ~DomainReliabilityUploaderImpl() override {
+ DCHECK(shutdown_);
mmenke 2016/12/14 19:12:17 include base/logging.h
Julia Tuttle 2016/12/15 21:53:00 Done.
+ }
// DomainReliabilityUploader implementation:
void UploadReport(
@@ -71,7 +74,7 @@ class DomainReliabilityUploaderImpl
VLOG(1) << "Uploading report to " << upload_url;
VLOG(2) << "Report JSON: " << report_json;
- if (discard_uploads_) {
+ if (discard_uploads_ || shutdown_) {
VLOG(1) << "Discarding report instead of uploading.";
UploadResult result;
result.status = UploadResult::SUCCESS;
@@ -107,6 +110,12 @@ class DomainReliabilityUploaderImpl
VLOG(1) << "Setting discard_uploads to " << discard_uploads;
}
+ void Shutdown() override {
+ DCHECK(!shutdown_);
+ shutdown_ = true;
+ upload_callbacks_.clear();
+ }
+
// net::URLFetcherDelegate implementation:
void OnURLFetchComplete(const net::URLFetcher* fetcher) override {
DCHECK(fetcher);
@@ -158,6 +167,7 @@ class DomainReliabilityUploaderImpl
upload_callbacks_;
mmenke 2016/12/14 19:12:17 A bit afield from this CL, but do you mind rename
Julia Tuttle 2016/12/15 21:53:00 Sure, I'll just call it uploads_.
bool discard_uploads_;
base::TimeTicks last_upload_start_time_;
+ bool shutdown_;
};
} // namespace
@@ -190,4 +200,6 @@ int DomainReliabilityUploader::GetURLRequestUploadDepth(
return data->depth();
}
+void DomainReliabilityUploader::Shutdown() {}
+
} // namespace domain_reliability

Powered by Google App Engine
This is Rietveld 408576698