| 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/test/test_internal_components_factory.h" |
| 15 #include "sync/internal_api/public/user_share.h" | 16 #include "sync/internal_api/public/user_share.h" |
| 16 #include "sync/js/js_reply_handler.h" | 17 #include "sync/js/js_reply_handler.h" |
| 17 #include "sync/protocol/encryption.pb.h" | 18 #include "sync/protocol/encryption.pb.h" |
| 18 #include "sync/syncable/directory.h" | 19 #include "sync/syncable/directory.h" |
| 19 | 20 |
| 20 using syncer::ModelSafeRoutingInfo; | 21 using syncer::ModelSafeRoutingInfo; |
| 22 using syncer::TestInternalComponentsFactory; |
| 21 using syncer::sessions::ModelNeutralState; | 23 using syncer::sessions::ModelNeutralState; |
| 22 using syncer::sessions::SyncSessionSnapshot; | 24 using syncer::sessions::SyncSessionSnapshot; |
| 23 using syncer::sessions::SyncSourceInfo; | 25 using syncer::sessions::SyncSourceInfo; |
| 24 using syncer::UserShare; | 26 using syncer::UserShare; |
| 25 using syncer::syncable::Directory; | 27 using syncer::syncable::Directory; |
| 26 | 28 |
| 27 namespace browser_sync { | 29 namespace browser_sync { |
| 28 | 30 |
| 29 SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( | 31 SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( |
| 30 Profile* profile, | 32 Profile* profile, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 52 } // namespace | 54 } // namespace |
| 53 | 55 |
| 54 void SyncBackendHostForProfileSyncTest::InitCore( | 56 void SyncBackendHostForProfileSyncTest::InitCore( |
| 55 const DoInitializeOptions& options) { | 57 const DoInitializeOptions& options) { |
| 56 DoInitializeOptions test_options = options; | 58 DoInitializeOptions test_options = options; |
| 57 test_options.make_http_bridge_factory_fn = | 59 test_options.make_http_bridge_factory_fn = |
| 58 base::Bind(&MakeTestHttpBridgeFactory); | 60 base::Bind(&MakeTestHttpBridgeFactory); |
| 59 test_options.credentials.email = "testuser@gmail.com"; | 61 test_options.credentials.email = "testuser@gmail.com"; |
| 60 test_options.credentials.sync_token = "token"; | 62 test_options.credentials.sync_token = "token"; |
| 61 test_options.restored_key_for_bootstrapping = ""; | 63 test_options.restored_key_for_bootstrapping = ""; |
| 62 test_options.testing_mode = | 64 TestInternalComponentsFactory::StorageOption storage = |
| 63 use_real_database_ ? syncer::SyncManager::TEST_ON_DISK | 65 use_real_database_ ? TestInternalComponentsFactory::ON_DISK |
| 64 : syncer::SyncManager::TEST_IN_MEMORY; | 66 : TestInternalComponentsFactory::IN_MEMORY; |
| 67 |
| 68 // It'd be nice if we avoided creating the InternalComponentsFactory in the |
| 69 // first place, but SyncBackendHost will have created one by now so we must |
| 70 // free it. |
| 71 delete test_options.internal_components_factory; |
| 72 test_options.internal_components_factory = |
| 73 new TestInternalComponentsFactory(storage); |
| 65 SyncBackendHost::InitCore(test_options); | 74 SyncBackendHost::InitCore(test_options); |
| 66 // TODO(akalin): Figure out a better way to do this. | 75 // TODO(akalin): Figure out a better way to do this. |
| 67 if (synchronous_init_) { | 76 if (synchronous_init_) { |
| 68 // The SyncBackend posts a task to the current loop when | 77 // The SyncBackend posts a task to the current loop when |
| 69 // initialization completes. | 78 // initialization completes. |
| 70 MessageLoop::current()->Run(); | 79 MessageLoop::current()->Run(); |
| 71 } | 80 } |
| 72 } | 81 } |
| 73 | 82 |
| 74 void SyncBackendHostForProfileSyncTest::RequestConfigureSyncer( | 83 void SyncBackendHostForProfileSyncTest::RequestConfigureSyncer( |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 void TestProfileSyncService::CreateBackend() { | 213 void TestProfileSyncService::CreateBackend() { |
| 205 backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest( | 214 backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest( |
| 206 profile(), | 215 profile(), |
| 207 sync_prefs_.AsWeakPtr(), | 216 sync_prefs_.AsWeakPtr(), |
| 208 invalidator_storage_.AsWeakPtr(), | 217 invalidator_storage_.AsWeakPtr(), |
| 209 set_initial_sync_ended_on_init_, | 218 set_initial_sync_ended_on_init_, |
| 210 synchronous_backend_initialization_, | 219 synchronous_backend_initialization_, |
| 211 fail_initial_download_, | 220 fail_initial_download_, |
| 212 use_real_database_)); | 221 use_real_database_)); |
| 213 } | 222 } |
| OLD | NEW |