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

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

Issue 2767893002: Remove ScopedVector from chrome/browser/. (Closed)
Patch Set: Address comments from zea@ Created 3 years, 8 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 <memory>
6 #include <vector>
7
5 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
6 #include "base/macros.h" 9 #include "base/macros.h"
7 #include "base/memory/scoped_vector.h" 10 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" 12 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
10 #include "chrome/browser/sync/test/integration/migration_waiter.h" 13 #include "chrome/browser/sync/test/integration/migration_waiter.h"
11 #include "chrome/browser/sync/test/integration/migration_watcher.h" 14 #include "chrome/browser/sync/test/integration/migration_watcher.h"
12 #include "chrome/browser/sync/test/integration/preferences_helper.h" 15 #include "chrome/browser/sync/test/integration/preferences_helper.h"
13 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h" 16 #include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
14 #include "chrome/browser/sync/test/integration/sync_test.h" 17 #include "chrome/browser/sync/test/integration/sync_test.h"
15 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
16 #include "components/browser_sync/profile_sync_service.h" 19 #include "components/browser_sync/profile_sync_service.h"
17 #include "components/prefs/scoped_user_pref_update.h" 20 #include "components/prefs/scoped_user_pref_update.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 enum TriggerMethod { MODIFY_PREF, MODIFY_BOOKMARK, TRIGGER_NOTIFICATION }; 77 enum TriggerMethod { MODIFY_PREF, MODIFY_BOOKMARK, TRIGGER_NOTIFICATION };
75 78
76 // Set up sync for all profiles and initialize all MigrationWatchers. This 79 // Set up sync for all profiles and initialize all MigrationWatchers. This
77 // helps ensure that all migration events are captured, even if they were to 80 // helps ensure that all migration events are captured, even if they were to
78 // occur before a test calls AwaitMigration for a specific profile. 81 // occur before a test calls AwaitMigration for a specific profile.
79 bool SetupSync() override { 82 bool SetupSync() override {
80 if (!SyncTest::SetupSync()) 83 if (!SyncTest::SetupSync())
81 return false; 84 return false;
82 85
83 for (int i = 0; i < num_clients(); ++i) { 86 for (int i = 0; i < num_clients(); ++i) {
84 MigrationWatcher* watcher = new MigrationWatcher(GetClient(i)); 87 migration_watchers_.push_back(
85 migration_watchers_.push_back(watcher); 88 base::MakeUnique<MigrationWatcher>(GetClient(i)));
86 } 89 }
87 return true; 90 return true;
88 } 91 }
89 92
90 syncer::ModelTypeSet GetPreferredDataTypes() { 93 syncer::ModelTypeSet GetPreferredDataTypes() {
91 // ProfileSyncService must already have been created before we can call 94 // ProfileSyncService must already have been created before we can call
92 // GetPreferredDataTypes(). 95 // GetPreferredDataTypes().
93 DCHECK(GetSyncService(0)); 96 DCHECK(GetSyncService(0));
94 syncer::ModelTypeSet preferred_data_types = 97 syncer::ModelTypeSet preferred_data_types =
95 GetSyncService(0)->GetPreferredDataTypes(); 98 GetSyncService(0)->GetPreferredDataTypes();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 default: 156 default:
154 ADD_FAILURE(); 157 ADD_FAILURE();
155 } 158 }
156 } 159 }
157 160
158 // Block until all clients have completed migration for the given 161 // Block until all clients have completed migration for the given
159 // types. 162 // types.
160 void AwaitMigration(syncer::ModelTypeSet migrate_types) { 163 void AwaitMigration(syncer::ModelTypeSet migrate_types) {
161 for (int i = 0; i < num_clients(); ++i) { 164 for (int i = 0; i < num_clients(); ++i) {
162 ASSERT_TRUE( 165 ASSERT_TRUE(
163 MigrationWaiter(migrate_types, migration_watchers_[i]).Wait()); 166 MigrationWaiter(migrate_types, migration_watchers_[i].get()).Wait());
164 } 167 }
165 } 168 }
166 169
167 // Makes sure migration works with the given migration list and 170 // Makes sure migration works with the given migration list and
168 // trigger method. 171 // trigger method.
169 void RunMigrationTest(const MigrationList& migration_list, 172 void RunMigrationTest(const MigrationList& migration_list,
170 TriggerMethod trigger_method) { 173 TriggerMethod trigger_method) {
171 // If we have only one client, turn off notifications to avoid the 174 // If we have only one client, turn off notifications to avoid the
172 // possibility of spurious sync cycles. 175 // possibility of spurious sync cycles.
173 bool do_test_without_notifications = 176 bool do_test_without_notifications =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 if (!do_test_without_notifications) { 212 if (!do_test_without_notifications) {
210 AwaitQuiescence(); 213 AwaitQuiescence();
211 } 214 }
212 215
213 // TODO(rlarocque): It should be possible to re-enable notifications 216 // TODO(rlarocque): It should be possible to re-enable notifications
214 // here, but doing so makes some windows tests flaky. 217 // here, but doing so makes some windows tests flaky.
215 } 218 }
216 219
217 private: 220 private:
218 // Used to keep track of the migration progress for each sync client. 221 // Used to keep track of the migration progress for each sync client.
219 ScopedVector<MigrationWatcher> migration_watchers_; 222 std::vector<std::unique_ptr<MigrationWatcher>> migration_watchers_;
220 223
221 DISALLOW_COPY_AND_ASSIGN(MigrationTest); 224 DISALLOW_COPY_AND_ASSIGN(MigrationTest);
222 }; 225 };
223 226
224 class MigrationSingleClientTest : public MigrationTest { 227 class MigrationSingleClientTest : public MigrationTest {
225 public: 228 public:
226 MigrationSingleClientTest() : MigrationTest(SINGLE_CLIENT_LEGACY) {} 229 MigrationSingleClientTest() : MigrationTest(SINGLE_CLIENT_LEGACY) {}
227 ~MigrationSingleClientTest() override {} 230 ~MigrationSingleClientTest() override {}
228 231
229 void RunSingleClientMigrationTest(const MigrationList& migration_list, 232 void RunSingleClientMigrationTest(const MigrationList& migration_list,
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 // Do not add optional datatypes. 428 // Do not add optional datatypes.
426 } 429 }
427 430
428 ~MigrationReconfigureTest() override {} 431 ~MigrationReconfigureTest() override {}
429 432
430 private: 433 private:
431 DISALLOW_COPY_AND_ASSIGN(MigrationReconfigureTest); 434 DISALLOW_COPY_AND_ASSIGN(MigrationReconfigureTest);
432 }; 435 };
433 436
434 } // namespace 437 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/apps_helper.cc ('k') | chrome/browser/sync/test/integration/passwords_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698