Revert 168224 - Update V8 to version 3.15.4.
[chromium-blink-merge.git] / chrome / browser / sync / retry_verifier.h
blob77219bf088f57199f620589d111e81746ff74c05
1 // Copyright (c) 2012 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_RETRY_VERIFIER_H_
6 #define CHROME_BROWSER_SYNC_RETRY_VERIFIER_H_
8 #include "base/time.h"
10 // TODO(akalin): Move this to somewhere in sync/ and make
11 // sync/engine/polling_constants.h private.
13 namespace syncer {
14 namespace sessions {
15 class SyncSessionSnapshot;
16 } // namespace sessions
17 } // namespace syncer
19 namespace browser_sync {
21 // The minimum and maximum wait times for a retry. The actual retry would take
22 // place somewhere in this range. The algorithm that calculates the retry wait
23 // time uses rand functions.
24 struct DelayInfo {
25 int64 min_delay;
26 int64 max_delay;
29 // Class to verify retries take place using the exponential backoff algorithm.
30 class RetryVerifier {
31 public:
32 static const int kMaxRetry = 3;
33 RetryVerifier();
34 ~RetryVerifier();
35 int retry_count() const { return retry_count_; }
37 // Initialize with the current sync session snapshot. Using the snapshot
38 // we will figure out when the first retry sync happened.
39 void Initialize(const syncer::sessions::SyncSessionSnapshot& snap);
40 void VerifyRetryInterval(
41 const syncer::sessions::SyncSessionSnapshot& snap);
42 bool done() const { return done_; }
43 bool Succeeded() const { return done() && success_; }
45 private:
46 int retry_count_;
47 base::Time last_sync_time_;
48 DelayInfo delay_table_[kMaxRetry];
49 bool success_;
50 bool done_;
51 DISALLOW_COPY_AND_ASSIGN(RetryVerifier);
54 } // namespace browser_sync
56 #endif // CHROME_BROWSER_SYNC_RETRY_VERIFIER_H_