jianli | 1235e51c | 2014-09-08 18:56:41 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "components/gcm_driver/gcm_backoff_policy.h" |
| 6 | |
| 7 | namespace gcm { |
| 8 | |
| 9 | namespace { |
| 10 | |
| 11 | // Backoff policy. Shared across GCM requests. |
| 12 | // Note: In order to ensure a minimum of 20 seconds between server errors (for |
| 13 | // server reasons), we have a 30s +- 10s (33%) jitter initial backoff. |
| 14 | const net::BackoffEntry::Policy kDefaultBackoffPolicy = { |
| 15 | // Number of initial errors (in sequence) to ignore before applying |
| 16 | // exponential back-off rules. |
| 17 | 0, |
| 18 | |
| 19 | // Initial delay for exponential back-off in ms. |
| 20 | 30 * 1000, // 30 seconds. |
| 21 | |
| 22 | // Factor by which the waiting time will be multiplied. |
| 23 | 2, |
| 24 | |
| 25 | // Fuzzing percentage. ex: 10% will spread requests randomly |
| 26 | // between 90%-100% of the calculated time. |
| 27 | 0.33, // 33%. |
| 28 | |
| 29 | // Maximum amount of time we are willing to delay our request in ms. |
| 30 | 10 * 60 * 1000, // 10 minutes. |
| 31 | |
| 32 | // Time to keep an entry from being discarded even when it |
| 33 | // has no significant state, -1 to never discard. |
| 34 | -1, |
| 35 | |
| 36 | // Don't use initial delay unless the last request was an error. |
| 37 | false, |
| 38 | }; |
| 39 | |
| 40 | } // namespace |
| 41 | |
| 42 | const net::BackoffEntry::Policy& GetGCMBackoffPolicy() { |
| 43 | return kDefaultBackoffPolicy; |
| 44 | } |
| 45 | |
| 46 | } // namespace gcm |