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

Unified Diff: update_check_scheduler.cc

Issue 3275006: AU: Implement server-dictated poll interval. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: rebase to head Created 10 years, 4 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 | « update_check_scheduler.h ('k') | update_check_scheduler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: update_check_scheduler.cc
diff --git a/update_check_scheduler.cc b/update_check_scheduler.cc
index c0a52ab8540257ec79916b0448a85c616930398e..3d00ff38ab13a28319687c90a146e8ae2a59dae5 100644
--- a/update_check_scheduler.cc
+++ b/update_check_scheduler.cc
@@ -17,7 +17,8 @@ UpdateCheckScheduler::UpdateCheckScheduler(UpdateAttempter* update_attempter)
: update_attempter_(update_attempter),
enabled_(false),
scheduled_(false),
- last_interval_(0) {}
+ last_interval_(0),
+ poll_interval_(0) {}
UpdateCheckScheduler::~UpdateCheckScheduler() {}
@@ -90,18 +91,23 @@ gboolean UpdateCheckScheduler::StaticCheck(void* scheduler) {
void UpdateCheckScheduler::ComputeNextIntervalAndFuzz(int* next_interval,
int* next_fuzz) {
int interval = 0;
- int fuzz = 0;
- // Implements exponential back off on 500 (Internal Server Error) and 503
- // (Service Unavailable) HTTP response codes.
- if (update_attempter_->http_response_code() == 500 ||
- update_attempter_->http_response_code() == 503) {
+ if (poll_interval_ > 0) {
+ // Server-dictated poll interval.
+ interval = poll_interval_;
+ LOG(WARNING) << "Using server-dictated poll interval: " << interval;
+ } else if (update_attempter_->http_response_code() == 500 ||
+ update_attempter_->http_response_code() == 503) {
+ // Implements exponential back off on 500 (Internal Server Error) and 503
+ // (Service Unavailable) HTTP response codes.
interval = 2 * last_interval_;
- if (interval > kTimeoutMaxBackoff) {
- interval = kTimeoutMaxBackoff;
- }
- // Exponential back off is fuzzed by +/- |interval|/2.
- fuzz = interval;
+ LOG(WARNING) << "Exponential back off due to 500/503 HTTP response code.";
}
+ if (interval > kTimeoutMaxBackoff) {
+ interval = kTimeoutMaxBackoff;
+ }
+ // Back off and server-dictated poll intervals are fuzzed by +/- |interval|/2.
+ int fuzz = interval;
+
// Ensures that under normal conditions the regular update check interval and
// fuzz are used. Also covers the case where back off is required based on the
// initial update check.
« no previous file with comments | « update_check_scheduler.h ('k') | update_check_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698