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