| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/sync/test_profile_sync_service.h" | 5 #include "chrome/browser/sync/test_profile_sync_service.h" |
| 6 | 6 |
| 7 #include "chrome/browser/signin/signin_manager.h" | 7 #include "chrome/browser/signin/signin_manager.h" |
| 8 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" | 8 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
| 9 #include "chrome/browser/sync/glue/data_type_controller.h" | 9 #include "chrome/browser/sync/glue/data_type_controller.h" |
| 10 #include "chrome/browser/sync/glue/sync_backend_host.h" | 10 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 11 #include "chrome/browser/sync/profile_sync_components_factory.h" | 11 #include "chrome/browser/sync/profile_sync_components_factory.h" |
| 12 #include "chrome/browser/sync/test/test_http_bridge_factory.h" | 12 #include "chrome/browser/sync/test/test_http_bridge_factory.h" |
| 13 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
| 14 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" | 14 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" |
| 15 #include "sync/internal_api/public/user_share.h" | 15 #include "sync/internal_api/public/user_share.h" |
| 16 #include "sync/js/js_reply_handler.h" | 16 #include "sync/js/js_reply_handler.h" |
| 17 #include "sync/protocol/encryption.pb.h" | 17 #include "sync/protocol/encryption.pb.h" |
| 18 #include "sync/syncable/directory.h" | 18 #include "sync/syncable/directory.h" |
| 19 | 19 |
| 20 using syncer::InternalComponentsFactory; | 20 using syncer::InternalComponentsFactory; |
| 21 using syncer::ModelSafeRoutingInfo; | 21 using syncer::ModelSafeRoutingInfo; |
| 22 using syncer::TestInternalComponentsFactory; | 22 using syncer::TestInternalComponentsFactory; |
| 23 using syncer::sessions::ModelNeutralState; | 23 using syncer::sessions::ModelNeutralState; |
| 24 using syncer::sessions::SyncSessionSnapshot; | 24 using syncer::sessions::SyncSessionSnapshot; |
| 25 using syncer::sessions::SyncSourceInfo; | 25 using syncer::sessions::SyncSourceInfo; |
| 26 using syncer::UserShare; | 26 using syncer::UserShare; |
| 27 using syncer::syncable::Directory; | 27 using syncer::syncable::Directory; |
| 28 using syncer::NIGORI; |
| 29 using syncer::DEVICE_INFO; |
| 28 | 30 |
| 29 namespace browser_sync { | 31 namespace browser_sync { |
| 30 | 32 |
| 31 SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( | 33 SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( |
| 32 Profile* profile, | 34 Profile* profile, |
| 33 const base::WeakPtr<SyncPrefs>& sync_prefs, | 35 const base::WeakPtr<SyncPrefs>& sync_prefs, |
| 34 const base::WeakPtr<InvalidatorStorage>& invalidator_storage, | 36 const base::WeakPtr<InvalidatorStorage>& invalidator_storage, |
| 35 syncer::TestIdFactory& id_factory, | 37 syncer::TestIdFactory& id_factory, |
| 36 base::Closure& callback, | 38 base::Closure& callback, |
| 37 bool set_initial_sync_ended_on_init, | 39 bool set_initial_sync_ended_on_init, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 if (!callback_.is_null()) { | 113 if (!callback_.is_null()) { |
| 112 callback_.Run(); | 114 callback_.Run(); |
| 113 } | 115 } |
| 114 | 116 |
| 115 // Pretend we downloaded initial updates and set initial sync ended bits | 117 // Pretend we downloaded initial updates and set initial sync ended bits |
| 116 // if we were asked to. | 118 // if we were asked to. |
| 117 if (set_initial_sync_ended_on_init_) { | 119 if (set_initial_sync_ended_on_init_) { |
| 118 UserShare* user_share = GetUserShare(); | 120 UserShare* user_share = GetUserShare(); |
| 119 Directory* directory = user_share->directory.get(); | 121 Directory* directory = user_share->directory.get(); |
| 120 | 122 |
| 121 if (!directory->initial_sync_ended_for_type(syncer::NIGORI)) { | 123 if (!directory->initial_sync_ended_for_type(NIGORI)) { |
| 122 ProfileSyncServiceTestHelper::CreateRoot( | 124 ProfileSyncServiceTestHelper::CreateRoot(NIGORI, user_share); |
| 123 syncer::NIGORI, user_share, &id_factory_); | |
| 124 | 125 |
| 125 // A side effect of adding the NIGORI mode (normally done by the | 126 // A side effect of adding the NIGORI mode (normally done by the |
| 126 // syncer) is a decryption attempt, which will fail the first time. | 127 // syncer) is a decryption attempt, which will fail the first time. |
| 127 } | 128 } |
| 128 | 129 |
| 130 if (!directory->initial_sync_ended_for_type(DEVICE_INFO)) { |
| 131 ProfileSyncServiceTestHelper::CreateRoot(DEVICE_INFO, user_share); |
| 132 } |
| 133 |
| 129 SetInitialSyncEndedForAllTypes(); | 134 SetInitialSyncEndedForAllTypes(); |
| 130 restored_types = syncer::ModelTypeSet::All(); | 135 restored_types = syncer::ModelTypeSet::All(); |
| 131 } | 136 } |
| 132 } | 137 } |
| 133 | 138 |
| 134 SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop( | 139 SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop( |
| 135 js_backend, success, restored_types); | 140 js_backend, success, restored_types); |
| 136 } | 141 } |
| 137 | 142 |
| 138 void SyncBackendHostForProfileSyncTest::SetInitialSyncEndedForAllTypes() { | 143 void SyncBackendHostForProfileSyncTest::SetInitialSyncEndedForAllTypes() { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 profile(), | 239 profile(), |
| 235 sync_prefs_.AsWeakPtr(), | 240 sync_prefs_.AsWeakPtr(), |
| 236 invalidator_storage_.AsWeakPtr(), | 241 invalidator_storage_.AsWeakPtr(), |
| 237 id_factory_, | 242 id_factory_, |
| 238 callback_, | 243 callback_, |
| 239 set_initial_sync_ended_on_init_, | 244 set_initial_sync_ended_on_init_, |
| 240 synchronous_backend_initialization_, | 245 synchronous_backend_initialization_, |
| 241 fail_initial_download_, | 246 fail_initial_download_, |
| 242 storage_option_)); | 247 storage_option_)); |
| 243 } | 248 } |
| OLD | NEW |