OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "sync/internal_api/test/sync_manager_for_profile_sync_test.h" | 5 #include "sync/internal_api/test/sync_manager_for_profile_sync_test.h" |
6 | 6 |
7 #include "sync/internal_api/public/test/test_user_share.h" | 7 #include "sync/internal_api/public/test/test_user_share.h" |
8 #include "sync/internal_api/public/user_share.h" | 8 #include "sync/internal_api/public/user_share.h" |
9 #include "sync/syncable/directory.h" | 9 #include "sync/syncable/directory.h" |
10 | 10 |
11 namespace syncer { | 11 namespace syncer { |
12 | 12 |
13 SyncManagerForProfileSyncTest::SyncManagerForProfileSyncTest( | 13 SyncManagerForProfileSyncTest::SyncManagerForProfileSyncTest( |
14 std::string name, | 14 std::string name, |
15 base::Closure init_callback, | 15 base::Closure init_callback) |
16 bool set_initial_sync_ended) | |
17 : SyncManagerImpl(name), | 16 : SyncManagerImpl(name), |
18 init_callback_(init_callback), | 17 init_callback_(init_callback) {} |
19 set_initial_sync_ended_(set_initial_sync_ended) {} | |
20 | 18 |
21 SyncManagerForProfileSyncTest::~SyncManagerForProfileSyncTest() {} | 19 SyncManagerForProfileSyncTest::~SyncManagerForProfileSyncTest() {} |
22 | 20 |
23 void SyncManagerForProfileSyncTest::NotifyInitializationSuccess() { | 21 void SyncManagerForProfileSyncTest::NotifyInitializationSuccess() { |
24 UserShare* user_share = GetUserShare(); | 22 UserShare* user_share = GetUserShare(); |
25 syncable::Directory* directory = user_share->directory.get(); | 23 syncable::Directory* directory = user_share->directory.get(); |
26 | 24 |
27 if (!init_callback_.is_null()) | 25 if (!init_callback_.is_null()) |
28 init_callback_.Run(); | 26 init_callback_.Run(); |
29 | 27 |
30 if (set_initial_sync_ended_) { | 28 ModelTypeSet early_download_types; |
31 ModelTypeSet early_download_types; | 29 early_download_types.PutAll(ControlTypes()); |
32 early_download_types.PutAll(ControlTypes()); | 30 early_download_types.PutAll(PriorityUserTypes()); |
33 early_download_types.PutAll(PriorityUserTypes()); | 31 for (ModelTypeSet::Iterator it = early_download_types.First(); |
34 for (ModelTypeSet::Iterator it = early_download_types.First(); | 32 it.Good(); it.Inc()) { |
35 it.Good(); it.Inc()) { | 33 if (!directory->InitialSyncEndedForType(it.Get())) { |
36 if (!directory->InitialSyncEndedForType(it.Get())) { | 34 syncer::TestUserShare::CreateRoot(it.Get(), user_share); |
37 syncer::TestUserShare::CreateRoot(it.Get(), user_share); | |
38 } | |
39 } | 35 } |
40 } else { | |
41 VLOG(2) << "Skipping directory init"; | |
42 } | 36 } |
43 | 37 |
44 SyncManagerImpl::NotifyInitializationSuccess(); | 38 SyncManagerImpl::NotifyInitializationSuccess(); |
45 } | 39 } |
46 | 40 |
47 }; | 41 }; |
OLD | NEW |