Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(884)

Side by Side Diff: chrome/browser/sync/test_profile_sync_service.cc

Issue 10483015: [Sync] Refactor sync configuration logic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: SetBool -> CallbackCounter Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 26 matching lines...) Expand all
37 bool fail_initial_download, 37 bool fail_initial_download,
38 bool use_real_database) 38 bool use_real_database)
39 : browser_sync::SyncBackendHost( 39 : browser_sync::SyncBackendHost(
40 profile->GetDebugName(), profile, sync_prefs, invalidator_storage), 40 profile->GetDebugName(), profile, sync_prefs, invalidator_storage),
41 synchronous_init_(synchronous_init), 41 synchronous_init_(synchronous_init),
42 fail_initial_download_(fail_initial_download), 42 fail_initial_download_(fail_initial_download),
43 use_real_database_(use_real_database) {} 43 use_real_database_(use_real_database) {}
44 44
45 SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} 45 SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {}
46 46
47 void SyncBackendHostForProfileSyncTest::
48 SimulateSyncCycleCompletedInitialSyncEnded(
49 const tracked_objects::Location& location) {
50 syncable::ModelTypeSet sync_ended;
51 if (!fail_initial_download_)
52 sync_ended = syncable::ModelTypeSet::All();
53 syncable::ModelTypePayloadMap download_progress_markers;
54 HandleSyncCycleCompletedOnFrontendLoop(SyncSessionSnapshot(
55 SyncerStatus(), ErrorCounters(), 0, false,
56 sync_ended, download_progress_markers, false, false, 0, 0, 0, 0,
57 SyncSourceInfo(), false, 0, base::Time::Now(), false));
58 }
59
60 namespace { 47 namespace {
61 48
62 sync_api::HttpPostProviderFactory* MakeTestHttpBridgeFactory() { 49 sync_api::HttpPostProviderFactory* MakeTestHttpBridgeFactory() {
63 return new browser_sync::TestHttpBridgeFactory(); 50 return new browser_sync::TestHttpBridgeFactory();
64 } 51 }
65 52
66 } // namespace 53 } // namespace
67 54
68 void SyncBackendHostForProfileSyncTest::InitCore( 55 void SyncBackendHostForProfileSyncTest::InitCore(
69 const DoInitializeOptions& options) { 56 const DoInitializeOptions& options) {
70 DoInitializeOptions test_options = options; 57 DoInitializeOptions test_options = options;
71 test_options.make_http_bridge_factory_fn = 58 test_options.make_http_bridge_factory_fn =
72 base::Bind(&MakeTestHttpBridgeFactory); 59 base::Bind(&MakeTestHttpBridgeFactory);
73 test_options.credentials.email = "testuser@gmail.com"; 60 test_options.credentials.email = "testuser@gmail.com";
74 test_options.credentials.sync_token = "token"; 61 test_options.credentials.sync_token = "token";
75 test_options.restored_key_for_bootstrapping = ""; 62 test_options.restored_key_for_bootstrapping = "";
76 test_options.testing_mode = 63 test_options.testing_mode =
77 use_real_database_ ? sync_api::SyncManager::TEST_ON_DISK 64 use_real_database_ ? sync_api::SyncManager::TEST_ON_DISK
78 : sync_api::SyncManager::TEST_IN_MEMORY; 65 : sync_api::SyncManager::TEST_IN_MEMORY;
79 SyncBackendHost::InitCore(test_options); 66 SyncBackendHost::InitCore(test_options);
80 // TODO(akalin): Figure out a better way to do this. 67 // TODO(akalin): Figure out a better way to do this.
81 if (synchronous_init_) { 68 if (synchronous_init_) {
82 // The SyncBackend posts a task to the current loop when 69 // The SyncBackend posts a task to the current loop when
83 // initialization completes. 70 // initialization completes.
84 MessageLoop::current()->Run(); 71 MessageLoop::current()->Run();
85 } 72 }
86 } 73 }
87 74
88 void SyncBackendHostForProfileSyncTest::StartConfiguration( 75 void SyncBackendHostForProfileSyncTest::RequestConfigureSyncer(
89 const base::Closure& callback) { 76 sync_api::ConfigureReason reason,
90 SyncBackendHost::FinishConfigureDataTypesOnFrontendLoop(); 77 syncable::ModelTypeSet types_to_config,
91 if (IsDownloadingNigoriForTest()) { 78 const browser_sync::ModelSafeRoutingInfo& routing_info,
92 syncable::ModelTypeSet sync_ended; 79 const base::Callback<void(syncable::ModelTypeSet)>& ready_task,
80 const base::Closure& retry_callback) {
81 syncable::ModelTypeSet sync_ended;
82 if (!fail_initial_download_)
83 sync_ended.PutAll(types_to_config);
93 84
94 if (!fail_initial_download_) 85 FinishConfigureDataTypesOnFrontendLoop(types_to_config,
95 sync_ended.Put(syncable::NIGORI); 86 sync_ended,
96 syncable::ModelTypePayloadMap download_progress_markers; 87 ready_task);
97 HandleSyncCycleCompletedOnFrontendLoop(SyncSessionSnapshot(
98 SyncerStatus(), ErrorCounters(), 0, false,
99 sync_ended, download_progress_markers, false, false, 0, 0, 0, 0,
100 SyncSourceInfo(), false, 0, base::Time::Now(), false));
101 }
102 } 88 }
103 89
104 void SyncBackendHostForProfileSyncTest::SetHistoryServiceExpectations( 90 void SyncBackendHostForProfileSyncTest::SetHistoryServiceExpectations(
105 ProfileMock* profile) { 91 ProfileMock* profile) {
106 EXPECT_CALL(*profile, GetHistoryService(testing::_)). 92 EXPECT_CALL(*profile, GetHistoryService(testing::_)).
107 WillOnce(testing::Return((HistoryService*)NULL)); 93 WillOnce(testing::Return((HistoryService*)NULL));
108 } 94 }
109 95
110 } // namespace browser_sync 96 } // namespace browser_sync
111 97
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 void TestProfileSyncService::CreateBackend() { 211 void TestProfileSyncService::CreateBackend() {
226 backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest( 212 backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest(
227 profile(), 213 profile(),
228 sync_prefs_.AsWeakPtr(), 214 sync_prefs_.AsWeakPtr(),
229 invalidator_storage_.AsWeakPtr(), 215 invalidator_storage_.AsWeakPtr(),
230 set_initial_sync_ended_on_init_, 216 set_initial_sync_ended_on_init_,
231 synchronous_backend_initialization_, 217 synchronous_backend_initialization_,
232 fail_initial_download_, 218 fail_initial_download_,
233 use_real_database_)); 219 use_real_database_));
234 } 220 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698