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