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 "components/browser_sync/browser/profile_sync_service.h" | 5 #include "components/browser_sync/browser/profile_sync_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 #include <map> | 10 #include <map> |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 #include "components/version_info/version_info_values.h" | 93 #include "components/version_info/version_info_values.h" |
94 #include "net/cookies/cookie_monster.h" | 94 #include "net/cookies/cookie_monster.h" |
95 #include "net/url_request/url_request_context_getter.h" | 95 #include "net/url_request/url_request_context_getter.h" |
96 #include "ui/base/l10n/l10n_util.h" | 96 #include "ui/base/l10n/l10n_util.h" |
97 #include "ui/base/l10n/time_format.h" | 97 #include "ui/base/l10n/time_format.h" |
98 | 98 |
99 #if defined(OS_ANDROID) | 99 #if defined(OS_ANDROID) |
100 #include "components/sync/core/read_transaction.h" | 100 #include "components/sync/core/read_transaction.h" |
101 #endif | 101 #endif |
102 | 102 |
103 using browser_sync::SessionsSyncManager; | |
104 using browser_sync::SyncBackendHost; | 103 using browser_sync::SyncBackendHost; |
105 using sync_driver::ChangeProcessor; | 104 using sync_driver::ChangeProcessor; |
106 using sync_driver::DataTypeController; | 105 using sync_driver::DataTypeController; |
107 using sync_driver::DataTypeManager; | 106 using sync_driver::DataTypeManager; |
108 using sync_driver::DataTypeStatusTable; | 107 using sync_driver::DataTypeStatusTable; |
109 using sync_driver::DeviceInfoSyncService; | 108 using sync_driver::DeviceInfoSyncService; |
110 using sync_driver_v2::DeviceInfoService; | 109 using sync_driver_v2::DeviceInfoService; |
| 110 using sync_sessions::SessionsSyncManager; |
111 using syncer::ModelType; | 111 using syncer::ModelType; |
112 using syncer::ModelTypeSet; | 112 using syncer::ModelTypeSet; |
113 using syncer::JsBackend; | 113 using syncer::JsBackend; |
114 using syncer::JsController; | 114 using syncer::JsController; |
115 using syncer::JsEventDetails; | 115 using syncer::JsEventDetails; |
116 using syncer::JsEventHandler; | 116 using syncer::JsEventHandler; |
117 using syncer::ModelSafeRoutingInfo; | 117 using syncer::ModelSafeRoutingInfo; |
118 using syncer::SyncCredentials; | 118 using syncer::SyncCredentials; |
119 using syncer::SyncProtocolError; | 119 using syncer::SyncProtocolError; |
120 using syncer::WeakHandle; | 120 using syncer::WeakHandle; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 void ProfileSyncService::Initialize() { | 270 void ProfileSyncService::Initialize() { |
271 sync_client_->Initialize(); | 271 sync_client_->Initialize(); |
272 | 272 |
273 // We don't pass StartupController an Unretained reference to future-proof | 273 // We don't pass StartupController an Unretained reference to future-proof |
274 // against the controller impl changing to post tasks. | 274 // against the controller impl changing to post tasks. |
275 startup_controller_.reset(new browser_sync::StartupController( | 275 startup_controller_.reset(new browser_sync::StartupController( |
276 &sync_prefs_, | 276 &sync_prefs_, |
277 base::Bind(&ProfileSyncService::CanBackendStart, base::Unretained(this)), | 277 base::Bind(&ProfileSyncService::CanBackendStart, base::Unretained(this)), |
278 base::Bind(&ProfileSyncService::StartUpSlowBackendComponents, | 278 base::Bind(&ProfileSyncService::StartUpSlowBackendComponents, |
279 weak_factory_.GetWeakPtr()))); | 279 weak_factory_.GetWeakPtr()))); |
280 std::unique_ptr<browser_sync::LocalSessionEventRouter> router( | 280 std::unique_ptr<sync_sessions::LocalSessionEventRouter> router( |
281 sync_client_->GetSyncSessionsClient()->GetLocalSessionEventRouter()); | 281 sync_client_->GetSyncSessionsClient()->GetLocalSessionEventRouter()); |
282 local_device_ = sync_client_->GetSyncApiComponentFactory() | 282 local_device_ = sync_client_->GetSyncApiComponentFactory() |
283 ->CreateLocalDeviceInfoProvider(); | 283 ->CreateLocalDeviceInfoProvider(); |
284 sync_stopped_reporter_.reset(new browser_sync::SyncStoppedReporter( | 284 sync_stopped_reporter_.reset(new browser_sync::SyncStoppedReporter( |
285 sync_service_url_, local_device_->GetSyncUserAgent(), | 285 sync_service_url_, local_device_->GetSyncUserAgent(), |
286 url_request_context_, | 286 url_request_context_, |
287 browser_sync::SyncStoppedReporter::ResultCallback())); | 287 browser_sync::SyncStoppedReporter::ResultCallback())); |
288 sessions_sync_manager_.reset(new SessionsSyncManager( | 288 sessions_sync_manager_.reset(new SessionsSyncManager( |
289 sync_client_->GetSyncSessionsClient(), &sync_prefs_, local_device_.get(), | 289 sync_client_->GetSyncSessionsClient(), &sync_prefs_, local_device_.get(), |
290 std::move(router), | 290 std::move(router), |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 bool ProfileSyncService::IsDataTypeControllerRunning( | 433 bool ProfileSyncService::IsDataTypeControllerRunning( |
434 syncer::ModelType type) const { | 434 syncer::ModelType type) const { |
435 DataTypeController::TypeMap::const_iterator iter = | 435 DataTypeController::TypeMap::const_iterator iter = |
436 data_type_controllers_.find(type); | 436 data_type_controllers_.find(type); |
437 if (iter == data_type_controllers_.end()) { | 437 if (iter == data_type_controllers_.end()) { |
438 return false; | 438 return false; |
439 } | 439 } |
440 return iter->second->state() == DataTypeController::RUNNING; | 440 return iter->second->state() == DataTypeController::RUNNING; |
441 } | 441 } |
442 | 442 |
443 sync_driver::OpenTabsUIDelegate* ProfileSyncService::GetOpenTabsUIDelegate() { | 443 sync_sessions::OpenTabsUIDelegate* ProfileSyncService::GetOpenTabsUIDelegate() { |
444 if (!IsDataTypeControllerRunning(syncer::SESSIONS)) | 444 if (!IsDataTypeControllerRunning(syncer::SESSIONS)) |
445 return NULL; | 445 return NULL; |
446 return sessions_sync_manager_.get(); | 446 return sessions_sync_manager_.get(); |
447 } | 447 } |
448 | 448 |
449 browser_sync::FaviconCache* ProfileSyncService::GetFaviconCache() { | 449 sync_sessions::FaviconCache* ProfileSyncService::GetFaviconCache() { |
450 return sessions_sync_manager_->GetFaviconCache(); | 450 return sessions_sync_manager_->GetFaviconCache(); |
451 } | 451 } |
452 | 452 |
453 sync_driver::DeviceInfoTracker* ProfileSyncService::GetDeviceInfoTracker() | 453 sync_driver::DeviceInfoTracker* ProfileSyncService::GetDeviceInfoTracker() |
454 const { | 454 const { |
455 // One of the two should always be non-null after initialization is done. | 455 // One of the two should always be non-null after initialization is done. |
456 if (device_info_service_) { | 456 if (device_info_service_) { |
457 return device_info_service_.get(); | 457 return device_info_service_.get(); |
458 } else { | 458 } else { |
459 return device_info_sync_service_.get(); | 459 return device_info_sync_service_.get(); |
(...skipping 14 matching lines...) Expand all Loading... |
474 } | 474 } |
475 | 475 |
476 void ProfileSyncService::OnSessionRestoreComplete() { | 476 void ProfileSyncService::OnSessionRestoreComplete() { |
477 DataTypeController::TypeMap::const_iterator iter = | 477 DataTypeController::TypeMap::const_iterator iter = |
478 data_type_controllers_.find(syncer::SESSIONS); | 478 data_type_controllers_.find(syncer::SESSIONS); |
479 if (iter == data_type_controllers_.end()) { | 479 if (iter == data_type_controllers_.end()) { |
480 return; | 480 return; |
481 } | 481 } |
482 DCHECK(iter->second); | 482 DCHECK(iter->second); |
483 | 483 |
484 static_cast<browser_sync::SessionDataTypeController*>(iter->second.get()) | 484 static_cast<sync_sessions::SessionDataTypeController*>(iter->second.get()) |
485 ->OnSessionRestoreComplete(); | 485 ->OnSessionRestoreComplete(); |
486 } | 486 } |
487 | 487 |
488 SyncCredentials ProfileSyncService::GetCredentials() { | 488 SyncCredentials ProfileSyncService::GetCredentials() { |
489 SyncCredentials credentials; | 489 SyncCredentials credentials; |
490 credentials.account_id = signin_->GetAccountIdToUse(); | 490 credentials.account_id = signin_->GetAccountIdToUse(); |
491 DCHECK(!credentials.account_id.empty()); | 491 DCHECK(!credentials.account_id.empty()); |
492 credentials.email = signin_->GetEffectiveUsername(); | 492 credentials.email = signin_->GetEffectiveUsername(); |
493 credentials.sync_token = access_token_; | 493 credentials.sync_token = access_token_; |
494 | 494 |
(...skipping 2036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2531 if (--outstanding_setup_in_progress_handles_ != 0) | 2531 if (--outstanding_setup_in_progress_handles_ != 0) |
2532 return; | 2532 return; |
2533 | 2533 |
2534 DCHECK(startup_controller_->IsSetupInProgress()); | 2534 DCHECK(startup_controller_->IsSetupInProgress()); |
2535 startup_controller_->SetSetupInProgress(false); | 2535 startup_controller_->SetSetupInProgress(false); |
2536 | 2536 |
2537 if (IsBackendInitialized()) | 2537 if (IsBackendInitialized()) |
2538 ReconfigureDatatypeManager(); | 2538 ReconfigureDatatypeManager(); |
2539 NotifyObservers(); | 2539 NotifyObservers(); |
2540 } | 2540 } |
OLD | NEW |