Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / sync / test / integration / retry_verifier.h
blobbf7003fdbcabf8133500a00bc1c2d34671d5f5b4
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_RETRY_VERIFIER_H_
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_RETRY_VERIFIER_H_
8 #include "base/time/time.h"
10 namespace syncer {
11 namespace sessions {
12 class SyncSessionSnapshot;
13 } // namespace sessions
14 } // namespace syncer
16 // The minimum and maximum wait times for a retry. The actual retry would take
17 // place somewhere in this range. The algorithm that calculates the retry wait
18 // time uses rand functions.
19 struct DelayInfo {
20 int64 min_delay;
21 int64 max_delay;
24 // Class to verify retries take place using the exponential backoff algorithm.
25 class RetryVerifier {
26 public:
27 static const int kMaxRetry = 3;
28 RetryVerifier();
29 ~RetryVerifier();
30 int retry_count() const { return retry_count_; }
32 // Initialize with the current sync session snapshot. Using the snapshot
33 // we will figure out when the first retry sync happened.
34 void Initialize(const syncer::sessions::SyncSessionSnapshot& snap);
35 void VerifyRetryInterval(
36 const syncer::sessions::SyncSessionSnapshot& snap);
37 bool done() const { return done_; }
38 bool Succeeded() const { return done() && success_; }
40 private:
41 int retry_count_;
42 base::Time last_sync_time_;
43 DelayInfo delay_table_[kMaxRetry];
44 bool success_;
45 bool done_;
46 DISALLOW_COPY_AND_ASSIGN(RetryVerifier);
49 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_RETRY_VERIFIER_H_