| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_RETRY_VERIFIER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_RETRY_VERIFIER_H_ |
| 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_RETRY_VERIFIER_H_ | 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_RETRY_VERIFIER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 | 12 |
| 13 namespace syncer { | 13 namespace syncer { |
| 14 namespace sessions { | 14 class SyncCycleSnapshot; |
| 15 class SyncSessionSnapshot; | |
| 16 } // namespace sessions | |
| 17 } // namespace syncer | 15 } // namespace syncer |
| 18 | 16 |
| 19 // The minimum and maximum wait times for a retry. The actual retry would take | 17 // 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 | 18 // place somewhere in this range. The algorithm that calculates the retry wait |
| 21 // time uses rand functions. | 19 // time uses rand functions. |
| 22 struct DelayInfo { | 20 struct DelayInfo { |
| 23 int64_t min_delay; | 21 int64_t min_delay; |
| 24 int64_t max_delay; | 22 int64_t max_delay; |
| 25 }; | 23 }; |
| 26 | 24 |
| 27 // Class to verify retries take place using the exponential backoff algorithm. | 25 // Class to verify retries take place using the exponential backoff algorithm. |
| 28 class RetryVerifier { | 26 class RetryVerifier { |
| 29 public: | 27 public: |
| 30 static const int kMaxRetry = 3; | 28 static const int kMaxRetry = 3; |
| 31 RetryVerifier(); | 29 RetryVerifier(); |
| 32 ~RetryVerifier(); | 30 ~RetryVerifier(); |
| 33 int retry_count() const { return retry_count_; } | 31 int retry_count() const { return retry_count_; } |
| 34 | 32 |
| 35 // Initialize with the current sync session snapshot. Using the snapshot | 33 // Initialize with the current sync session snapshot. Using the snapshot |
| 36 // we will figure out when the first retry sync happened. | 34 // we will figure out when the first retry sync happened. |
| 37 void Initialize(const syncer::sessions::SyncSessionSnapshot& snap); | 35 void Initialize(const syncer::SyncCycleSnapshot& snap); |
| 38 void VerifyRetryInterval( | 36 void VerifyRetryInterval(const syncer::SyncCycleSnapshot& snap); |
| 39 const syncer::sessions::SyncSessionSnapshot& snap); | |
| 40 bool done() const { return done_; } | 37 bool done() const { return done_; } |
| 41 bool Succeeded() const { return done() && success_; } | 38 bool Succeeded() const { return done() && success_; } |
| 42 | 39 |
| 43 private: | 40 private: |
| 44 int retry_count_; | 41 int retry_count_; |
| 45 base::Time last_sync_time_; | 42 base::Time last_sync_time_; |
| 46 DelayInfo delay_table_[kMaxRetry]; | 43 DelayInfo delay_table_[kMaxRetry]; |
| 47 bool success_; | 44 bool success_; |
| 48 bool done_; | 45 bool done_; |
| 49 DISALLOW_COPY_AND_ASSIGN(RetryVerifier); | 46 DISALLOW_COPY_AND_ASSIGN(RetryVerifier); |
| 50 }; | 47 }; |
| 51 | 48 |
| 52 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_RETRY_VERIFIER_H_ | 49 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_RETRY_VERIFIER_H_ |
| OLD | NEW |