Chromium Code Reviews| 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 #include "base/time.h" | |
| 10 | |
| 11 namespace browser_sync { | |
| 12 namespace sessions { | |
| 13 struct SyncSessionSnapshot; | |
| 14 } // namespace sessions | |
| 15 } // namespace browser_sync | |
| 16 | |
| 17 namespace sync_test_harness { | |
|
tim (not reviewing)
2011/08/09 19:57:47
a namespace that doesn't match the directory hiera
lipalani1
2011/08/09 20:36:48
ah.. changed that.
On 2011/08/09 19:57:47, timstee
| |
| 18 // The minimum and maximum wait times for a retry. The actual retry would take | |
| 19 // place somewhere in this range. The algorithm that calculates the retry wait | |
| 20 // time uses rand functions. | |
| 21 struct DelayInfo { | |
| 22 int64 min_delay; | |
| 23 int64 max_delay; | |
| 24 }; | |
| 25 | |
| 26 // Class to verify retries take place using the exponential backoff algorithm. | |
| 27 class RetryVerifier { | |
| 28 public: | |
| 29 static const int kMaxRetry = 5; | |
| 30 RetryVerifier(); | |
| 31 ~RetryVerifier(); | |
| 32 int retry_count() const { return retry_count_; } | |
| 33 | |
| 34 // Initialize with the current sync session snapshot. Using the snapshot | |
| 35 // we will figure out when the first retry sync happened. | |
| 36 void Initialize(const browser_sync::sessions::SyncSessionSnapshot& snap); | |
| 37 void VerifyRetryInterval( | |
| 38 const browser_sync::sessions::SyncSessionSnapshot& snap); | |
| 39 bool done() const { return done_; } | |
| 40 bool Succeeded() const { return done() && success_; } | |
| 41 | |
| 42 private: | |
| 43 int retry_count_; | |
| 44 base::Time last_sync_time_; | |
| 45 DelayInfo delay_table_[kMaxRetry]; | |
| 46 bool success_; | |
| 47 bool done_; | |
| 48 DISALLOW_COPY_AND_ASSIGN(RetryVerifier); | |
| 49 }; | |
| 50 } // namespace sync_test_harness | |
| 51 #endif // CHROME_BROWSER_SYNC_RETRY_VERIFIER_H_ | |
| OLD | NEW |