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

Unified Diff: handler/crash_report_upload_thread.cc

Issue 1563683002: Allow disabling upload rate-limiting (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: rebase Created 4 years, 11 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 | « handler/crash_report_upload_thread.h ('k') | handler/crashpad_handler.ad » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: handler/crash_report_upload_thread.cc
diff --git a/handler/crash_report_upload_thread.cc b/handler/crash_report_upload_thread.cc
index c84facb2e9459cdb55baa72e06a8e312a36099c0..38ce0297a0e6be9068cbdf907e64554657181904 100644
--- a/handler/crash_report_upload_thread.cc
+++ b/handler/crash_report_upload_thread.cc
@@ -137,14 +137,16 @@ class CallRecordUploadAttempt {
} // namespace
CrashReportUploadThread::CrashReportUploadThread(CrashReportDatabase* database,
- const std::string& url)
+ const std::string& url,
+ bool rate_limit)
: url_(url),
// Check for pending reports every 15 minutes, even in the absence of a
// signal from the handler thread. This allows for failed uploads to be
// retried periodically, and for pending reports written by other
// processes to be recognized.
thread_(15 * 60, this),
- database_(database) {
+ database_(database),
+ rate_limit_(rate_limit) {
}
CrashReportUploadThread::~CrashReportUploadThread() {
@@ -204,28 +206,30 @@ void CrashReportUploadThread::ProcessPendingReport(
//
// TODO(mark): Provide a proper rate-limiting strategy and allow for failed
// upload attempts to be retried.
- time_t last_upload_attempt_time;
- if (settings->GetLastUploadAttemptTime(&last_upload_attempt_time)) {
- time_t now = time(nullptr);
- if (now >= last_upload_attempt_time) {
- // If the most recent upload attempt occurred within the past hour, don’t
- // attempt to upload the new report. If it happened longer ago, attempt to
- // upload the report.
- const int kUploadAttemptIntervalSeconds = 60 * 60; // 1 hour
- if (now - last_upload_attempt_time < kUploadAttemptIntervalSeconds) {
- database_->SkipReportUpload(report.uuid);
- return;
- }
- } else {
- // The most recent upload attempt purportedly occurred in the future. If
- // it “happened” at least one day in the future, assume that the last
- // upload attempt time is bogus, and attempt to upload the report. If the
- // most recent upload time is in the future but within one day, accept it
- // and don’t attempt to upload the report.
- const int kBackwardsClockTolerance = 60 * 60 * 24; // 1 day
- if (last_upload_attempt_time - now < kBackwardsClockTolerance) {
- database_->SkipReportUpload(report.uuid);
- return;
+ if (rate_limit_) {
+ time_t last_upload_attempt_time;
+ if (settings->GetLastUploadAttemptTime(&last_upload_attempt_time)) {
+ time_t now = time(nullptr);
+ if (now >= last_upload_attempt_time) {
+ // If the most recent upload attempt occurred within the past hour,
+ // don’t attempt to upload the new report. If it happened longer ago,
+ // attempt to upload the report.
+ const int kUploadAttemptIntervalSeconds = 60 * 60; // 1 hour
+ if (now - last_upload_attempt_time < kUploadAttemptIntervalSeconds) {
+ database_->SkipReportUpload(report.uuid);
+ return;
+ }
+ } else {
+ // The most recent upload attempt purportedly occurred in the future. If
+ // it “happened” at least one day in the future, assume that the last
+ // upload attempt time is bogus, and attempt to upload the report. If
+ // the most recent upload time is in the future but within one day,
+ // accept it and don’t attempt to upload the report.
+ const int kBackwardsClockTolerance = 60 * 60 * 24; // 1 day
+ if (last_upload_attempt_time - now < kBackwardsClockTolerance) {
+ database_->SkipReportUpload(report.uuid);
+ return;
+ }
}
}
}
« no previous file with comments | « handler/crash_report_upload_thread.h ('k') | handler/crashpad_handler.ad » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698