Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Side by Side Diff: chrome/browser/sync/test/integration/migration_waiter.cc

Issue 490643004: sync: Refactor migration integration tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698