OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_SYNC_RETRY_VERIFIER_H_ |
| 6 #define CHROME_BROWSER_SYNC_RETRY_VERIFIER_H_ |
| 7 #pragma once |
| 8 |
| 9 |
| 10 #include "base/time.h" |
| 11 |
| 12 |
| 13 namespace browser_sync { |
| 14 namespace sessions { |
| 15 struct SyncSessionSnapshot; |
| 16 } |
| 17 } |
| 18 |
| 19 // The minimum and maximum wait times for a retry. The actual retry would take |
| 20 // place somewhere in this range. The algorithm that calculates the retry wait |
| 21 // time uses rand functions. |
| 22 struct DelayInfo { |
| 23 int64 min_delay; |
| 24 int64 max_delay; |
| 25 }; |
| 26 |
| 27 // Class to verify retries take place using the exponential backoff algorithm. |
| 28 class RetryVerifier { |
| 29 public: |
| 30 static const int max_retry = 10; |
| 31 RetryVerifier(); |
| 32 ~RetryVerifier(); |
| 33 int RetryCount() const { return retry_count; } |
| 34 void Initialize(const browser_sync::sessions::SyncSessionSnapshot& snap); |
| 35 bool VerifyRetryInterval( |
| 36 const browser_sync::sessions::SyncSessionSnapshot& snap); |
| 37 |
| 38 private: |
| 39 int retry_count; |
| 40 base::Time last_sync_time; |
| 41 DelayInfo delay_table[max_retry]; |
| 42 }; |
| 43 |
| 44 #endif // CHROME_BROWSER_SYNC_RETRY_VERIFIER_H_ |
OLD | NEW |