Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chrome_sync_client.h" | 5 #include "chrome/browser/sync/chrome_sync_client.h" |
| 6 | 6 |
| 7 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 7 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
| 10 #include "chrome/browser/history/history_service_factory.h" | 10 #include "chrome/browser/history/history_service_factory.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 | 62 |
| 63 #if defined(OS_CHROMEOS) | 63 #if defined(OS_CHROMEOS) |
| 64 #include "components/wifi_sync/wifi_credential_syncable_service.h" | 64 #include "components/wifi_sync/wifi_credential_syncable_service.h" |
| 65 #include "components/wifi_sync/wifi_credential_syncable_service_factory.h" | 65 #include "components/wifi_sync/wifi_credential_syncable_service_factory.h" |
| 66 #endif | 66 #endif |
| 67 | 67 |
| 68 namespace browser_sync { | 68 namespace browser_sync { |
| 69 | 69 |
| 70 ChromeSyncClient::ChromeSyncClient( | 70 ChromeSyncClient::ChromeSyncClient( |
| 71 Profile* profile, | 71 Profile* profile, |
| 72 ProfileSyncComponentsFactoryImpl* component_factory) | 72 sync_driver::SyncApiComponentFactory* component_factory) |
| 73 : profile_(profile), | 73 : profile_(profile), |
| 74 component_factory_(component_factory) { | 74 component_factory_(component_factory) { |
| 75 // Must be called on UI thread. | |
| 76 web_data_service_ = GetWebDataService(); | |
| 77 password_store_ = GetPasswordStore(); | |
| 78 } | 75 } |
| 79 ChromeSyncClient::~ChromeSyncClient() { | 76 ChromeSyncClient::~ChromeSyncClient() { |
| 80 } | 77 } |
| 81 | 78 |
| 79 void ChromeSyncClient::Initialize(sync_driver::SyncService* sync_service) { | |
| 80 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
| 81 sync_service_ = sync_service; | |
| 82 web_data_service_ = GetWebDataService(); | |
|
stanisc
2015/08/27 22:14:04
Since these two functions are called here and the
Nicolas Zea
2015/08/27 23:37:15
They're called externally too, but on the UI threa
| |
| 83 password_store_ = GetPasswordStore(); | |
| 84 } | |
| 85 | |
| 86 sync_driver::SyncService* ChromeSyncClient::GetSyncService() { | |
| 87 // TODO(zea): bring back this DCHECK after Typed URLs are converted to | |
| 88 // SyncableService. | |
| 89 // DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
| 90 return sync_service_; | |
| 91 } | |
| 92 | |
| 82 PrefService* ChromeSyncClient::GetPrefService() { | 93 PrefService* ChromeSyncClient::GetPrefService() { |
| 83 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 94 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 84 return profile_->GetPrefs(); | 95 return profile_->GetPrefs(); |
| 85 } | 96 } |
| 86 | 97 |
| 87 bookmarks::BookmarkModel* ChromeSyncClient::GetBookmarkModel() { | 98 bookmarks::BookmarkModel* ChromeSyncClient::GetBookmarkModel() { |
| 88 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 99 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 89 return BookmarkModelFactory::GetForProfile(profile_); | 100 return BookmarkModelFactory::GetForProfile(profile_); |
| 90 } | 101 } |
| 91 | 102 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 default: | 241 default: |
| 231 // The following datatypes still need to be transitioned to the | 242 // The following datatypes still need to be transitioned to the |
| 232 // syncer::SyncableService API: | 243 // syncer::SyncableService API: |
| 233 // Bookmarks | 244 // Bookmarks |
| 234 // Typed URLs | 245 // Typed URLs |
| 235 NOTREACHED(); | 246 NOTREACHED(); |
| 236 return base::WeakPtr<syncer::SyncableService>(); | 247 return base::WeakPtr<syncer::SyncableService>(); |
| 237 } | 248 } |
| 238 } | 249 } |
| 239 | 250 |
| 240 scoped_ptr<syncer::AttachmentService> ChromeSyncClient::CreateAttachmentService( | 251 sync_driver::SyncApiComponentFactory* |
| 241 scoped_ptr<syncer::AttachmentStoreForSync> attachment_store, | 252 ChromeSyncClient::GetSyncApiComponentFactory() { |
| 242 const syncer::UserShare& user_share, | |
| 243 const std::string& store_birthday, | |
| 244 syncer::ModelType model_type, | |
| 245 syncer::AttachmentService::Delegate* delegate) { | |
| 246 return GetProfileSyncComponentsFactoryImpl() | |
| 247 ->CreateAttachmentService(attachment_store.Pass(), user_share, | |
| 248 store_birthday, model_type, delegate) | |
| 249 .Pass(); | |
| 250 } | |
| 251 | |
| 252 void ChromeSyncClient::RegisterDataTypes(ProfileSyncService* pss) { | |
| 253 component_factory_->RegisterDataTypes(pss); | |
| 254 } | |
| 255 | |
| 256 sync_driver::DataTypeManager* ChromeSyncClient::CreateDataTypeManager( | |
| 257 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | |
| 258 debug_info_listener, | |
| 259 const sync_driver::DataTypeController::TypeMap* controllers, | |
| 260 const sync_driver::DataTypeEncryptionHandler* encryption_handler, | |
| 261 browser_sync::SyncBackendHost* backend, | |
| 262 sync_driver::DataTypeManagerObserver* observer) { | |
| 263 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
| 264 return component_factory_->CreateDataTypeManager( | |
| 265 debug_info_listener, controllers, encryption_handler, backend, observer); | |
| 266 } | |
| 267 | |
| 268 browser_sync::SyncBackendHost* ChromeSyncClient::CreateSyncBackendHost( | |
| 269 const std::string& name, | |
| 270 Profile* profile, | |
| 271 invalidation::InvalidationService* invalidator, | |
| 272 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs, | |
| 273 const base::FilePath& sync_folder) { | |
| 274 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
| 275 return component_factory_->CreateSyncBackendHost(name, profile, invalidator, | |
| 276 sync_prefs, sync_folder); | |
| 277 } | |
| 278 | |
| 279 scoped_ptr<sync_driver::LocalDeviceInfoProvider> | |
| 280 ChromeSyncClient::CreateLocalDeviceInfoProvider() { | |
| 281 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
| 282 return component_factory_->CreateLocalDeviceInfoProvider(); | |
| 283 } | |
| 284 | |
| 285 ProfileSyncComponentsFactory::SyncComponents | |
| 286 ChromeSyncClient::CreateBookmarkSyncComponents( | |
| 287 ProfileSyncService* profile_sync_service, | |
| 288 sync_driver::DataTypeErrorHandler* error_handler) { | |
| 289 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
| 290 return component_factory_->CreateBookmarkSyncComponents(profile_sync_service, | |
| 291 error_handler); | |
| 292 } | |
| 293 | |
| 294 ProfileSyncComponentsFactory::SyncComponents | |
| 295 ChromeSyncClient::CreateTypedUrlSyncComponents( | |
| 296 ProfileSyncService* profile_sync_service, | |
| 297 history::HistoryBackend* history_backend, | |
| 298 sync_driver::DataTypeErrorHandler* error_handler) { | |
| 299 return component_factory_->CreateTypedUrlSyncComponents( | |
| 300 profile_sync_service, history_backend, error_handler); | |
| 301 } | |
| 302 | |
| 303 ProfileSyncComponentsFactoryImpl* | |
| 304 ChromeSyncClient::GetProfileSyncComponentsFactoryImpl() { | |
| 305 return component_factory_; | 253 return component_factory_; |
| 306 } | 254 } |
| 307 | 255 |
| 308 } // namespace browser_sync | 256 } // namespace browser_sync |
| OLD | NEW |