| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/scoped_observer.h" | 10 #include "base/scoped_observer.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "components/browser_sync/profile_sync_service.h" | 13 #include "components/browser_sync/profile_sync_service.h" |
| 14 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" | 14 #include "components/sync/engine/cycle/sync_cycle_snapshot.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // Returns true if this service is disabled. | 18 // Returns true if this service is disabled. |
| 19 bool IsSyncDisabled(browser_sync::ProfileSyncService* service) { | 19 bool IsSyncDisabled(browser_sync::ProfileSyncService* service) { |
| 20 return !service->IsSetupInProgress() && !service->IsFirstSetupComplete(); | 20 return !service->IsSetupInProgress() && !service->IsFirstSetupComplete(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 // Returns true if these services have matching progress markers. | 23 // Returns true if these services have matching progress markers. |
| 24 bool ProgressMarkersMatch(const browser_sync::ProfileSyncService* service1, | 24 bool ProgressMarkersMatch(const browser_sync::ProfileSyncService* service1, |
| 25 const browser_sync::ProfileSyncService* service2) { | 25 const browser_sync::ProfileSyncService* service2) { |
| 26 // GetActiveDataTypes() is always empty during configuration, so progress |
| 27 // markers cannot be compared. |
| 28 if (!service1->ConfigurationDone() || !service2->ConfigurationDone()) { |
| 29 return false; |
| 30 } |
| 31 |
| 26 const syncer::ModelTypeSet common_types = | 32 const syncer::ModelTypeSet common_types = |
| 27 Intersection(service1->GetActiveDataTypes(), | 33 Intersection(service1->GetActiveDataTypes(), |
| 28 service2->GetActiveDataTypes()); | 34 service2->GetActiveDataTypes()); |
| 29 | 35 |
| 30 const syncer::SyncCycleSnapshot& snap1 = service1->GetLastCycleSnapshot(); | 36 const syncer::SyncCycleSnapshot& snap1 = service1->GetLastCycleSnapshot(); |
| 31 const syncer::SyncCycleSnapshot& snap2 = service2->GetLastCycleSnapshot(); | 37 const syncer::SyncCycleSnapshot& snap2 = service2->GetLastCycleSnapshot(); |
| 32 | 38 |
| 33 for (syncer::ModelTypeSet::Iterator type_it = common_types.First(); | 39 for (syncer::ModelTypeSet::Iterator type_it = common_types.First(); |
| 34 type_it.Good(); type_it.Inc()) { | 40 type_it.Good(); type_it.Inc()) { |
| 35 // Look up the progress markers. Fail if either one is missing. | 41 // Look up the progress markers. Fail if either one is missing. |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 208 |
| 203 std::string QuiesceStatusChangeChecker::GetDebugMessage() const { | 209 std::string QuiesceStatusChangeChecker::GetDebugMessage() const { |
| 204 return base::StringPrintf("Waiting for quiescence of %" PRIuS " clients", | 210 return base::StringPrintf("Waiting for quiescence of %" PRIuS " clients", |
| 205 services_.size()); | 211 services_.size()); |
| 206 } | 212 } |
| 207 | 213 |
| 208 void QuiesceStatusChangeChecker::OnServiceStateChanged( | 214 void QuiesceStatusChangeChecker::OnServiceStateChanged( |
| 209 browser_sync::ProfileSyncService* service) { | 215 browser_sync::ProfileSyncService* service) { |
| 210 CheckExitCondition(); | 216 CheckExitCondition(); |
| 211 } | 217 } |
| OLD | NEW |