OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/quiesce_status_change_checker.h" | 5 #include "chrome/browser/sync/test/integration/quiesce_status_change_checker.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/scoped_observer.h" | 8 #include "base/scoped_observer.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 167 |
168 bool QuiesceStatusChangeChecker::IsExitConditionSatisfied() { | 168 bool QuiesceStatusChangeChecker::IsExitConditionSatisfied() { |
169 // Check that all progress markers are up to date. | 169 // Check that all progress markers are up to date. |
170 for (ScopedVector<ProgressMarkerWatcher>::const_iterator it = | 170 for (ScopedVector<ProgressMarkerWatcher>::const_iterator it = |
171 observers_.begin(); it != observers_.end(); ++it) { | 171 observers_.begin(); it != observers_.end(); ++it) { |
172 if ((*it)->IsSyncDisabled()) { | 172 if ((*it)->IsSyncDisabled()) { |
173 continue; // Skip disabled services. | 173 continue; // Skip disabled services. |
174 } | 174 } |
175 | 175 |
176 if (!(*it)->HasLatestProgressMarkers()) { | 176 if (!(*it)->HasLatestProgressMarkers()) { |
177 VLOG(1) << "Not quiesced: Progress markers are old."; | 177 DVLOG(1) << "Not quiesced: Progress markers are old."; |
178 return false; | 178 return false; |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 std::vector<ProfileSyncService*> enabled_services; | 182 std::vector<ProfileSyncService*> enabled_services; |
183 for (std::vector<ProfileSyncService*>::const_iterator it = services_.begin(); | 183 for (std::vector<ProfileSyncService*>::const_iterator it = services_.begin(); |
184 it != services_.end(); ++it) { | 184 it != services_.end(); ++it) { |
185 if (!IsSyncDisabled(*it)) { | 185 if (!IsSyncDisabled(*it)) { |
186 enabled_services.push_back(*it); | 186 enabled_services.push_back(*it); |
187 } | 187 } |
188 } | 188 } |
189 | 189 |
190 // Return true if we have nothing to compare against. | 190 // Return true if we have nothing to compare against. |
191 if (enabled_services.size() <= 1) { | 191 if (enabled_services.size() <= 1) { |
192 return true; | 192 return true; |
193 } | 193 } |
194 | 194 |
195 std::vector<ProfileSyncService*>::const_iterator it1 = | 195 std::vector<ProfileSyncService*>::const_iterator it1 = |
196 enabled_services.begin(); | 196 enabled_services.begin(); |
197 std::vector<ProfileSyncService*>::const_iterator it2 = | 197 std::vector<ProfileSyncService*>::const_iterator it2 = |
198 enabled_services.begin(); | 198 enabled_services.begin(); |
199 it2++; | 199 it2++; |
200 | 200 |
201 while (it2 != enabled_services.end()) { | 201 while (it2 != enabled_services.end()) { |
202 // Return false if there is a progress marker mismatch. | 202 // Return false if there is a progress marker mismatch. |
203 if (!ProgressMarkersMatch(*it1, *it2)) { | 203 if (!ProgressMarkersMatch(*it1, *it2)) { |
204 VLOG(1) << "Not quiesced: Progress marker mismatch."; | 204 DVLOG(1) << "Not quiesced: Progress marker mismatch."; |
205 return false; | 205 return false; |
206 } | 206 } |
207 it1++; | 207 it1++; |
208 it2++; | 208 it2++; |
209 } | 209 } |
210 | 210 |
211 return true; | 211 return true; |
212 } | 212 } |
213 | 213 |
214 std::string QuiesceStatusChangeChecker::GetDebugMessage() const { | 214 std::string QuiesceStatusChangeChecker::GetDebugMessage() const { |
215 return base::StringPrintf("Waiting for quiescence of %" PRIuS " clients", | 215 return base::StringPrintf("Waiting for quiescence of %" PRIuS " clients", |
216 services_.size()); | 216 services_.size()); |
217 } | 217 } |
218 | 218 |
219 void QuiesceStatusChangeChecker::OnServiceStateChanged( | 219 void QuiesceStatusChangeChecker::OnServiceStateChanged( |
220 ProfileSyncService* service) { | 220 ProfileSyncService* service) { |
221 CheckExitCondition(); | 221 CheckExitCondition(); |
222 } | 222 } |
OLD | NEW |