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/signin/signin_manager_factory.h" | 8 #include "chrome/browser/signin/signin_manager_factory.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 18 matching lines...) Expand all Loading... |
29 using syncer::DEVICE_INFO; | 29 using syncer::DEVICE_INFO; |
30 using syncer::EXPERIMENTS; | 30 using syncer::EXPERIMENTS; |
31 using syncer::NIGORI; | 31 using syncer::NIGORI; |
32 using syncer::PRIORITY_PREFERENCES; | 32 using syncer::PRIORITY_PREFERENCES; |
33 | 33 |
34 namespace browser_sync { | 34 namespace browser_sync { |
35 | 35 |
36 SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( | 36 SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( |
37 Profile* profile, | 37 Profile* profile, |
38 const base::WeakPtr<SyncPrefs>& sync_prefs, | 38 const base::WeakPtr<SyncPrefs>& sync_prefs, |
39 const base::WeakPtr<InvalidatorStorage>& invalidator_storage, | |
40 syncer::TestIdFactory& id_factory, | 39 syncer::TestIdFactory& id_factory, |
41 base::Closure& callback, | 40 base::Closure& callback, |
42 bool set_initial_sync_ended_on_init, | 41 bool set_initial_sync_ended_on_init, |
43 bool synchronous_init, | 42 bool synchronous_init, |
44 bool fail_initial_download, | 43 bool fail_initial_download, |
45 syncer::StorageOption storage_option) | 44 syncer::StorageOption storage_option) |
46 : browser_sync::SyncBackendHost( | 45 : browser_sync::SyncBackendHost( |
47 profile->GetDebugName(), profile, sync_prefs, invalidator_storage), | 46 profile->GetDebugName(), profile, sync_prefs), |
48 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 47 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
49 id_factory_(id_factory), | 48 id_factory_(id_factory), |
50 callback_(callback), | 49 callback_(callback), |
51 fail_initial_download_(fail_initial_download), | 50 fail_initial_download_(fail_initial_download), |
52 set_initial_sync_ended_on_init_(set_initial_sync_ended_on_init), | 51 set_initial_sync_ended_on_init_(set_initial_sync_ended_on_init), |
53 synchronous_init_(synchronous_init), | 52 synchronous_init_(synchronous_init), |
54 storage_option_(storage_option) {} | 53 storage_option_(storage_option) {} |
55 | 54 |
56 SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} | 55 SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} |
57 | 56 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 syncer::ConfigureReason reason, | 104 syncer::ConfigureReason reason, |
106 syncer::ModelTypeSet types_to_config, | 105 syncer::ModelTypeSet types_to_config, |
107 syncer::ModelTypeSet failed_types, | 106 syncer::ModelTypeSet failed_types, |
108 const syncer::ModelSafeRoutingInfo& routing_info, | 107 const syncer::ModelSafeRoutingInfo& routing_info, |
109 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, | 108 const base::Callback<void(syncer::ModelTypeSet)>& ready_task, |
110 const base::Closure& retry_callback) { | 109 const base::Closure& retry_callback) { |
111 syncer::ModelTypeSet failed_configuration_types; | 110 syncer::ModelTypeSet failed_configuration_types; |
112 if (fail_initial_download_) | 111 if (fail_initial_download_) |
113 failed_configuration_types = types_to_config; | 112 failed_configuration_types = types_to_config; |
114 | 113 |
115 FinishConfigureDataTypesOnFrontendLoop(failed_configuration_types, | 114 FinishConfigureDataTypesOnFrontendLoop(types_to_config, |
| 115 failed_configuration_types, |
116 ready_task); | 116 ready_task); |
117 } | 117 } |
118 | 118 |
119 void SyncBackendHostForProfileSyncTest | 119 void SyncBackendHostForProfileSyncTest |
120 ::HandleSyncManagerInitializationOnFrontendLoop( | 120 ::HandleSyncManagerInitializationOnFrontendLoop( |
121 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 121 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
122 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | 122 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
123 debug_info_listener, | 123 debug_info_listener, |
124 syncer::ModelTypeSet restored_types) { | 124 syncer::ModelTypeSet restored_types) { |
125 // Here's our opportunity to pretend to do things that the SyncManager would | 125 // Here's our opportunity to pretend to do things that the SyncManager would |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 if (fail_initial_download_) { | 166 if (fail_initial_download_) { |
167 frontend()->OnSyncConfigureRetry(); | 167 frontend()->OnSyncConfigureRetry(); |
168 if (synchronous_init_) | 168 if (synchronous_init_) |
169 MessageLoop::current()->Quit(); | 169 MessageLoop::current()->Quit(); |
170 } else { | 170 } else { |
171 initial_download_closure_.Run(); | 171 initial_download_closure_.Run(); |
172 initial_download_closure_.Reset(); | 172 initial_download_closure_.Reset(); |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 void SyncBackendHostForProfileSyncTest::EmitOnInvalidatorStateChange( | |
177 syncer::InvalidatorState state) { | |
178 frontend()->OnInvalidatorStateChange(state); | |
179 } | |
180 | |
181 void SyncBackendHostForProfileSyncTest::EmitOnIncomingInvalidation( | |
182 const syncer::ObjectIdInvalidationMap& invalidation_map) { | |
183 frontend()->OnIncomingInvalidation(invalidation_map); | |
184 } | |
185 | |
186 void SyncBackendHostForProfileSyncTest::ContinueInitialization( | 176 void SyncBackendHostForProfileSyncTest::ContinueInitialization( |
187 const syncer::WeakHandle<syncer::JsBackend>& js_backend, | 177 const syncer::WeakHandle<syncer::JsBackend>& js_backend, |
188 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | 178 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
189 debug_info_listener, | 179 debug_info_listener, |
190 syncer::ModelTypeSet restored_types) { | 180 syncer::ModelTypeSet restored_types) { |
191 SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop( | 181 SyncBackendHost::HandleSyncManagerInitializationOnFrontendLoop( |
192 js_backend, debug_info_listener, restored_types); | 182 js_backend, debug_info_listener, restored_types); |
193 } | 183 } |
194 | 184 |
195 } // namespace browser_sync | 185 } // namespace browser_sync |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 } | 269 } |
280 void TestProfileSyncService::set_storage_option( | 270 void TestProfileSyncService::set_storage_option( |
281 syncer::StorageOption storage_option) { | 271 syncer::StorageOption storage_option) { |
282 storage_option_ = storage_option; | 272 storage_option_ = storage_option; |
283 } | 273 } |
284 | 274 |
285 void TestProfileSyncService::CreateBackend() { | 275 void TestProfileSyncService::CreateBackend() { |
286 backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest( | 276 backend_.reset(new browser_sync::SyncBackendHostForProfileSyncTest( |
287 profile(), | 277 profile(), |
288 sync_prefs_.AsWeakPtr(), | 278 sync_prefs_.AsWeakPtr(), |
289 invalidator_storage_.AsWeakPtr(), | |
290 id_factory_, | 279 id_factory_, |
291 callback_, | 280 callback_, |
292 set_initial_sync_ended_on_init_, | 281 set_initial_sync_ended_on_init_, |
293 synchronous_backend_initialization_, | 282 synchronous_backend_initialization_, |
294 fail_initial_download_, | 283 fail_initial_download_, |
295 storage_option_)); | 284 storage_option_)); |
296 } | 285 } |
OLD | NEW |