OLD | NEW |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 database_->SkipReportUpload(report.uuid, | 200 database_->SkipReportUpload(report.uuid, |
201 Metrics::CrashSkippedReason::kUploadsDisabled); | 201 Metrics::CrashSkippedReason::kUploadsDisabled); |
202 return; | 202 return; |
203 } | 203 } |
204 | 204 |
205 // This currently implements very simplistic rate-limiting, compatible with | 205 // This currently implements very simplistic rate-limiting, compatible with |
206 // the Breakpad client, where the strategy is to permit one upload attempt per | 206 // the Breakpad client, where the strategy is to permit one upload attempt per |
207 // hour, and retire reports that would exceed this limit or for which the | 207 // hour, and retire reports that would exceed this limit or for which the |
208 // upload fails on the first attempt. | 208 // upload fails on the first attempt. |
209 // | 209 // |
| 210 // If upload was requested explicitly (i.e. by user action), we do not |
| 211 // throttle the upload. |
| 212 // |
210 // TODO(mark): Provide a proper rate-limiting strategy and allow for failed | 213 // TODO(mark): Provide a proper rate-limiting strategy and allow for failed |
211 // upload attempts to be retried. | 214 // upload attempts to be retried. |
212 if (rate_limit_) { | 215 if (!report.upload_explicitly_requested && rate_limit_) { |
213 time_t last_upload_attempt_time; | 216 time_t last_upload_attempt_time; |
214 if (settings->GetLastUploadAttemptTime(&last_upload_attempt_time)) { | 217 if (settings->GetLastUploadAttemptTime(&last_upload_attempt_time)) { |
215 time_t now = time(nullptr); | 218 time_t now = time(nullptr); |
216 if (now >= last_upload_attempt_time) { | 219 if (now >= last_upload_attempt_time) { |
217 // If the most recent upload attempt occurred within the past hour, | 220 // If the most recent upload attempt occurred within the past hour, |
218 // don’t attempt to upload the new report. If it happened longer ago, | 221 // don’t attempt to upload the new report. If it happened longer ago, |
219 // attempt to upload the report. | 222 // attempt to upload the report. |
220 const int kUploadAttemptIntervalSeconds = 60 * 60; // 1 hour | 223 const int kUploadAttemptIntervalSeconds = 60 * 60; // 1 hour |
221 if (now - last_upload_attempt_time < kUploadAttemptIntervalSeconds) { | 224 if (now - last_upload_attempt_time < kUploadAttemptIntervalSeconds) { |
222 database_->SkipReportUpload( | 225 database_->SkipReportUpload( |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 } | 344 } |
342 | 345 |
343 return UploadResult::kSuccess; | 346 return UploadResult::kSuccess; |
344 } | 347 } |
345 | 348 |
346 void CrashReportUploadThread::DoWork(const WorkerThread* thread) { | 349 void CrashReportUploadThread::DoWork(const WorkerThread* thread) { |
347 ProcessPendingReports(); | 350 ProcessPendingReports(); |
348 } | 351 } |
349 | 352 |
350 } // namespace crashpad | 353 } // namespace crashpad |
OLD | NEW |