OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/sync/test/integration/migration_waiter.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "chrome/browser/sync/test/integration/migration_watcher.h" |
| 9 |
| 10 MigrationWaiter::MigrationWaiter(syncer::ModelTypeSet expected_types, |
| 11 MigrationWatcher* watcher) |
| 12 : watcher_(watcher), expected_types_(expected_types) { |
| 13 DCHECK(!expected_types_.Empty()); |
| 14 watcher_->set_migration_waiter(this); |
| 15 } |
| 16 |
| 17 MigrationWaiter::~MigrationWaiter() { |
| 18 watcher_->clear_migration_waiter(); |
| 19 } |
| 20 |
| 21 // Returns true when sync reports that there is no pending migration, and |
| 22 // migration is complete for all data types in |expected_types_|. |
| 23 bool MigrationWaiter::IsExitConditionSatisfied() { |
| 24 return watcher_->GetMigratedTypes().HasAll(expected_types_) && |
| 25 !watcher_->HasPendingBackendMigration(); |
| 26 } |
| 27 |
| 28 std::string MigrationWaiter::GetDebugMessage() const { |
| 29 return "Waiting to migrate (" + ModelTypeSetToString(expected_types_) + |
| 30 "); " + "Currently migrated: (" + |
| 31 ModelTypeSetToString(watcher_->GetMigratedTypes()) + ")"; |
| 32 } |
| 33 |
| 34 void MigrationWaiter::Wait() { |
| 35 if (IsExitConditionSatisfied()) { |
| 36 DVLOG(1) << "Skipping wait: " << GetDebugMessage(); |
| 37 return; |
| 38 } |
| 39 |
| 40 StartBlockingWait(); |
| 41 } |
| 42 |
| 43 void MigrationWaiter::OnMigrationStateChange() { |
| 44 CheckExitCondition(); |
| 45 } |
OLD | NEW |