| 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 #include "chrome/browser/sync/test/integration/retry_verifier.h" | 5 #include "chrome/browser/sync/test/integration/retry_verifier.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 delay_info.max_delay = | 32 delay_info.max_delay = |
| 33 std::max(static_cast<int64_t>(1), | 33 std::max(static_cast<int64_t>(1), |
| 34 std::min(delay_info.max_delay, syncer::kMaxBackoffSeconds)); | 34 std::min(delay_info.max_delay, syncer::kMaxBackoffSeconds)); |
| 35 | 35 |
| 36 return delay_info; | 36 return delay_info; |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Fills the table with the maximum and minimum values for each retry, upto | 39 // Fills the table with the maximum and minimum values for each retry, upto |
| 40 // |count| number of retries. | 40 // |count| number of retries. |
| 41 void FillDelayTable(DelayInfo* delay_table, int count) { | 41 void FillDelayTable(DelayInfo* delay_table, int count) { |
| 42 DCHECK(count > 1); | 42 DCHECK_GT(count, 1); |
| 43 | 43 |
| 44 // We start off with the minimum value of 2 seconds. | 44 // We start off with the minimum value of 2 seconds. |
| 45 delay_table[0].min_delay = static_cast<int64_t>(2); | 45 delay_table[0].min_delay = static_cast<int64_t>(2); |
| 46 delay_table[0].max_delay = static_cast<int64_t>(2); | 46 delay_table[0].max_delay = static_cast<int64_t>(2); |
| 47 | 47 |
| 48 for (int i = 1 ; i < count ; ++i) { | 48 for (int i = 1 ; i < count ; ++i) { |
| 49 delay_table[i].min_delay = CalculateDelay(delay_table[i-1].min_delay). | 49 delay_table[i].min_delay = CalculateDelay(delay_table[i-1].min_delay). |
| 50 min_delay; | 50 min_delay; |
| 51 delay_table[i].max_delay = CalculateDelay(delay_table[i-1].max_delay). | 51 delay_table[i].max_delay = CalculateDelay(delay_table[i-1].max_delay). |
| 52 max_delay; | 52 max_delay; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 last_sync_time_ = snap.sync_start_time(); | 97 last_sync_time_ = snap.sync_start_time(); |
| 98 } | 98 } |
| 99 success_ = true; | 99 success_ = true; |
| 100 return; | 100 return; |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Check if the sync start time has changed. If so indicates a new sync | 103 // Check if the sync start time has changed. If so indicates a new sync |
| 104 // has taken place. | 104 // has taken place. |
| 105 if (snap.sync_start_time() != last_sync_time_) { | 105 if (snap.sync_start_time() != last_sync_time_) { |
| 106 base::TimeDelta delta = snap.sync_start_time() - last_sync_time_; | 106 base::TimeDelta delta = snap.sync_start_time() - last_sync_time_; |
| 107 success_ = IsRetryOnTime(delay_table_,retry_count_ -1, delta); | 107 success_ = IsRetryOnTime(delay_table_, retry_count_ - 1, delta); |
| 108 last_sync_time_ = snap.sync_start_time(); | 108 last_sync_time_ = snap.sync_start_time(); |
| 109 ++retry_count_; | 109 ++retry_count_; |
| 110 done_ = (retry_count_ >= kMaxRetry); | 110 done_ = (retry_count_ >= kMaxRetry); |
| 111 return; | 111 return; |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| OLD | NEW |