| 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" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 bool fail_initial_download, | 35 bool fail_initial_download, |
| 36 bool use_real_database) | 36 bool use_real_database) |
| 37 : browser_sync::SyncBackendHost( | 37 : browser_sync::SyncBackendHost( |
| 38 profile->GetDebugName(), profile, sync_prefs, invalidator_storage), | 38 profile->GetDebugName(), profile, sync_prefs, invalidator_storage), |
| 39 synchronous_init_(synchronous_init), | 39 synchronous_init_(synchronous_init), |
| 40 fail_initial_download_(fail_initial_download), | 40 fail_initial_download_(fail_initial_download), |
| 41 use_real_database_(use_real_database) {} | 41 use_real_database_(use_real_database) {} |
| 42 | 42 |
| 43 SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} | 43 SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} |
| 44 | 44 |
| 45 void SyncBackendHostForProfileSyncTest:: | |
| 46 SimulateSyncCycleCompletedInitialSyncEnded( | |
| 47 const tracked_objects::Location& location) { | |
| 48 syncer::ModelTypeSet sync_ended; | |
| 49 if (!fail_initial_download_) | |
| 50 sync_ended = syncer::ModelTypeSet::All(); | |
| 51 syncer::ModelTypePayloadMap download_progress_markers; | |
| 52 HandleSyncCycleCompletedOnFrontendLoop( | |
| 53 SyncSessionSnapshot( | |
| 54 ModelNeutralState(), false, sync_ended, download_progress_markers, | |
| 55 false, false, 0, 0, 0, 0, SyncSourceInfo(), false, 0, | |
| 56 base::Time::Now(), false)); | |
| 57 } | |
| 58 | |
| 59 namespace { | 45 namespace { |
| 60 | 46 |
| 61 syncer::HttpPostProviderFactory* MakeTestHttpBridgeFactory() { | 47 scoped_ptr<syncer::HttpPostProviderFactory> MakeTestHttpBridgeFactory() { |
| 62 return new browser_sync::TestHttpBridgeFactory(); | 48 return scoped_ptr<syncer::HttpPostProviderFactory>( |
| 49 new browser_sync::TestHttpBridgeFactory()); |
| 63 } | 50 } |
| 64 | 51 |
| 65 } // namespace | 52 } // namespace |
| 66 | 53 |
| 67 void SyncBackendHostForProfileSyncTest::InitCore( | 54 void SyncBackendHostForProfileSyncTest::InitCore( |
| 68 const DoInitializeOptions& options) { | 55 const DoInitializeOptions& options) { |
| 69 DoInitializeOptions test_options = options; | 56 DoInitializeOptions test_options = options; |
| 70 test_options.make_http_bridge_factory_fn = | 57 test_options.make_http_bridge_factory_fn = |
| 71 base::Bind(&MakeTestHttpBridgeFactory); | 58 base::Bind(&MakeTestHttpBridgeFactory); |
| 72 test_options.credentials.email = "testuser@gmail.com"; | 59 test_options.credentials.email = "testuser@gmail.com"; |
| 73 test_options.credentials.sync_token = "token"; | 60 test_options.credentials.sync_token = "token"; |
| 74 test_options.restored_key_for_bootstrapping = ""; | 61 test_options.restored_key_for_bootstrapping = ""; |
| 75 test_options.testing_mode = | 62 test_options.testing_mode = |
| 76 use_real_database_ ? syncer::SyncManager::TEST_ON_DISK | 63 use_real_database_ ? syncer::SyncManager::TEST_ON_DISK |
| 77 : syncer::SyncManager::TEST_IN_MEMORY; | 64 : syncer::SyncManager::TEST_IN_MEMORY; |
| 78 SyncBackendHost::InitCore(test_options); | 65 SyncBackendHost::InitCore(test_options); |
| 79 // TODO(akalin): Figure out a better way to do this. | 66 // TODO(akalin): Figure out a better way to do this. |
| 80 if (synchronous_init_) { | 67 if (synchronous_init_) { |
| 81 // The SyncBackend posts a task to the current loop when | 68 // The SyncBackend posts a task to the current loop when |
| 82 // initialization completes. | 69 // initialization completes. |
| 83 MessageLoop::current()->Run(); | 70 MessageLoop::current()->Run(); |
| 84 } | 71 } |
| 85 } | 72 } |
| 86 | 73 |
| 87 void SyncBackendHostForProfileSyncTest::StartConfiguration( | 74 void SyncBackendHostForProfileSyncTest::RequestConfigureSyncer( |
| 88 const base::Closure& callback) { | 75 syncer::ConfigureReason reason, |
| 89 SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop(); | 76 syncer::ModelTypeSet types_to_config, |
| 90 if (IsDownloadingNigoriForTest()) { | 77 const syncer::ModelSafeRoutingInfo& routing_info, |
| 91 syncer::ModelTypeSet sync_ended; | 78 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, |
| 79 const base::Closure& retry_callback) { |
| 80 syncer::ModelTypeSet sync_ended; |
| 81 if (!fail_initial_download_) |
| 82 sync_ended.PutAll(types_to_config); |
| 92 | 83 |
| 93 if (!fail_initial_download_) | 84 FinishConfigureDataTypesOnFrontendLoop(types_to_config, |
| 94 sync_ended.Put(syncer::NIGORI); | 85 sync_ended, |
| 95 syncer::ModelTypePayloadMap download_progress_markers; | 86 ready_task); |
| 96 HandleSyncCycleCompletedOnFrontendLoop( | |
| 97 SyncSessionSnapshot( | |
| 98 ModelNeutralState(), false, sync_ended, download_progress_markers, | |
| 99 false, false, 0, 0, 0, 0, SyncSourceInfo(), false, 0, | |
| 100 base::Time::Now(), false)); | |
| 101 } | |
| 102 } | 87 } |
| 103 | 88 |
| 104 void SyncBackendHostForProfileSyncTest::SetHistoryServiceExpectations( | 89 void SyncBackendHostForProfileSyncTest::SetHistoryServiceExpectations( |
| 105 ProfileMock* profile) { | 90 ProfileMock* profile) { |
| 106 EXPECT_CALL(*profile, GetHistoryService(testing::_)). | 91 EXPECT_CALL(*profile, GetHistoryService(testing::_)). |
| 107 WillOnce(testing::Return((HistoryService*)NULL)); | 92 WillOnce(testing::Return((HistoryService*)NULL)); |
| 108 } | 93 } |
| 109 | 94 |
| 110 } // namespace browser_sync | 95 } // namespace browser_sync |
| 111 | 96 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 void TestProfileSyncService::CreateBackend() { | 210 void TestProfileSyncService::CreateBackend() { |
| 226 backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest( | 211 backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest( |
| 227 profile(), | 212 profile(), |
| 228 sync_prefs_.AsWeakPtr(), | 213 sync_prefs_.AsWeakPtr(), |
| 229 invalidator_storage_.AsWeakPtr(), | 214 invalidator_storage_.AsWeakPtr(), |
| 230 set_initial_sync_ended_on_init_, | 215 set_initial_sync_ended_on_init_, |
| 231 synchronous_backend_initialization_, | 216 synchronous_backend_initialization_, |
| 232 fail_initial_download_, | 217 fail_initial_download_, |
| 233 use_real_database_)); | 218 use_real_database_)); |
| 234 } | 219 } |
| OLD | NEW |