OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/retry_verifier.h" | 5 #include "chrome/browser/sync/retry_verifier.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "sync/engine/polling_constants.h" | 10 #include "sync/engine/polling_constants.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 memset(&delay_table_, 0, sizeof(delay_table_)); | 74 memset(&delay_table_, 0, sizeof(delay_table_)); |
75 } | 75 } |
76 | 76 |
77 RetryVerifier::~RetryVerifier() { | 77 RetryVerifier::~RetryVerifier() { |
78 } | 78 } |
79 | 79 |
80 // Initializes the state for verification. | 80 // Initializes the state for verification. |
81 void RetryVerifier::Initialize( | 81 void RetryVerifier::Initialize( |
82 const browser_sync::sessions::SyncSessionSnapshot& snap) { | 82 const browser_sync::sessions::SyncSessionSnapshot& snap) { |
83 retry_count_ = 0; | 83 retry_count_ = 0; |
84 last_sync_time_ = snap.sync_start_time; | 84 last_sync_time_ = snap.sync_start_time(); |
85 FillDelayTable(delay_table_, kMaxRetry); | 85 FillDelayTable(delay_table_, kMaxRetry); |
86 done_ = false; | 86 done_ = false; |
87 success_ = false; | 87 success_ = false; |
88 } | 88 } |
89 | 89 |
90 void RetryVerifier::VerifyRetryInterval( | 90 void RetryVerifier::VerifyRetryInterval( |
91 const browser_sync::sessions::SyncSessionSnapshot& snap) { | 91 const browser_sync::sessions::SyncSessionSnapshot& snap) { |
92 DCHECK(retry_count_ < kMaxRetry); | 92 DCHECK(retry_count_ < kMaxRetry); |
93 if (retry_count_ == 0) { | 93 if (retry_count_ == 0) { |
94 if (snap.sync_start_time != last_sync_time_) { | 94 if (snap.sync_start_time() != last_sync_time_) { |
95 retry_count_++; | 95 retry_count_++; |
96 last_sync_time_ = snap.sync_start_time; | 96 last_sync_time_ = snap.sync_start_time(); |
97 } | 97 } |
98 success_ = true; | 98 success_ = true; |
99 return; | 99 return; |
100 } | 100 } |
101 | 101 |
102 // Check if the sync start time has changed. If so indicates a new sync | 102 // Check if the sync start time has changed. If so indicates a new sync |
103 // has taken place. | 103 // has taken place. |
104 if (snap.sync_start_time != last_sync_time_) { | 104 if (snap.sync_start_time() != last_sync_time_) { |
105 base::TimeDelta delta = snap.sync_start_time - last_sync_time_; | 105 base::TimeDelta delta = snap.sync_start_time() - last_sync_time_; |
106 success_ = IsRetryOnTime(delay_table_,retry_count_ -1, delta); | 106 success_ = IsRetryOnTime(delay_table_,retry_count_ -1, delta); |
107 last_sync_time_ = snap.sync_start_time; | 107 last_sync_time_ = snap.sync_start_time(); |
108 ++retry_count_; | 108 ++retry_count_; |
109 done_ = (retry_count_ >= kMaxRetry); | 109 done_ = (retry_count_ >= kMaxRetry); |
110 return; | 110 return; |
111 } | 111 } |
112 } | 112 } |
113 } // namespace browser_sync | 113 } // namespace browser_sync |
OLD | NEW |