| 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 #include <cstddef> | 8 #include <cstddef> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 254 } |
| 255 | 255 |
| 256 bool ProfileSyncService::CanSyncStart() const { | 256 bool ProfileSyncService::CanSyncStart() const { |
| 257 return IsSyncAllowed() && IsSyncRequested() && IsSignedIn(); | 257 return IsSyncAllowed() && IsSyncRequested() && IsSignedIn(); |
| 258 } | 258 } |
| 259 | 259 |
| 260 void ProfileSyncService::Initialize() { | 260 void ProfileSyncService::Initialize() { |
| 261 sync_client_->Initialize(); | 261 sync_client_->Initialize(); |
| 262 | 262 |
| 263 startup_controller_.reset(new browser_sync::StartupController( | 263 startup_controller_.reset(new browser_sync::StartupController( |
| 264 oauth2_token_service_, &sync_prefs_, signin_.get(), | 264 &sync_prefs_, |
| 265 base::Bind(&ProfileSyncService::CanBackendStart, base::Unretained(this)), |
| 265 base::Bind(&ProfileSyncService::StartUpSlowBackendComponents, | 266 base::Bind(&ProfileSyncService::StartUpSlowBackendComponents, |
| 266 startup_controller_weak_factory_.GetWeakPtr()))); | 267 startup_controller_weak_factory_.GetWeakPtr()))); |
| 267 scoped_ptr<browser_sync::LocalSessionEventRouter> router( | 268 scoped_ptr<browser_sync::LocalSessionEventRouter> router( |
| 268 sync_client_->GetSyncSessionsClient()->GetLocalSessionEventRouter()); | 269 sync_client_->GetSyncSessionsClient()->GetLocalSessionEventRouter()); |
| 269 local_device_ = sync_client_->GetSyncApiComponentFactory() | 270 local_device_ = sync_client_->GetSyncApiComponentFactory() |
| 270 ->CreateLocalDeviceInfoProvider(); | 271 ->CreateLocalDeviceInfoProvider(); |
| 271 sync_stopped_reporter_.reset(new browser_sync::SyncStoppedReporter( | 272 sync_stopped_reporter_.reset(new browser_sync::SyncStoppedReporter( |
| 272 sync_service_url_, local_device_->GetSyncUserAgent(), | 273 sync_service_url_, local_device_->GetSyncUserAgent(), |
| 273 url_request_context_, | 274 url_request_context_, |
| 274 browser_sync::SyncStoppedReporter::ResultCallback())); | 275 browser_sync::SyncStoppedReporter::ResultCallback())); |
| (...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 void ProfileSyncService::TriggerRefresh(const syncer::ModelTypeSet& types) { | 1528 void ProfileSyncService::TriggerRefresh(const syncer::ModelTypeSet& types) { |
| 1528 if (backend_initialized_) | 1529 if (backend_initialized_) |
| 1529 backend_->TriggerRefresh(types); | 1530 backend_->TriggerRefresh(types); |
| 1530 } | 1531 } |
| 1531 | 1532 |
| 1532 bool ProfileSyncService::IsSignedIn() const { | 1533 bool ProfileSyncService::IsSignedIn() const { |
| 1533 // Sync is logged in if there is a non-empty effective account id. | 1534 // Sync is logged in if there is a non-empty effective account id. |
| 1534 return !signin_->GetAccountIdToUse().empty(); | 1535 return !signin_->GetAccountIdToUse().empty(); |
| 1535 } | 1536 } |
| 1536 | 1537 |
| 1538 bool ProfileSyncService::CanBackendStart() const { |
| 1539 return CanSyncStart() && oauth2_token_service_ && |
| 1540 oauth2_token_service_->RefreshTokenIsAvailable( |
| 1541 signin_->GetAccountIdToUse()); |
| 1542 } |
| 1543 |
| 1537 bool ProfileSyncService::IsBackendInitialized() const { | 1544 bool ProfileSyncService::IsBackendInitialized() const { |
| 1538 return backend_initialized_; | 1545 return backend_initialized_; |
| 1539 } | 1546 } |
| 1540 | 1547 |
| 1541 bool ProfileSyncService::ConfigurationDone() const { | 1548 bool ProfileSyncService::ConfigurationDone() const { |
| 1542 return data_type_manager_ && | 1549 return data_type_manager_ && |
| 1543 data_type_manager_->state() == DataTypeManager::CONFIGURED; | 1550 data_type_manager_->state() == DataTypeManager::CONFIGURED; |
| 1544 } | 1551 } |
| 1545 | 1552 |
| 1546 bool ProfileSyncService::waiting_for_auth() const { | 1553 bool ProfileSyncService::waiting_for_auth() const { |
| (...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2483 } | 2490 } |
| 2484 | 2491 |
| 2485 std::string ProfileSyncService::unrecoverable_error_message() const { | 2492 std::string ProfileSyncService::unrecoverable_error_message() const { |
| 2486 return unrecoverable_error_message_; | 2493 return unrecoverable_error_message_; |
| 2487 } | 2494 } |
| 2488 | 2495 |
| 2489 tracked_objects::Location ProfileSyncService::unrecoverable_error_location() | 2496 tracked_objects::Location ProfileSyncService::unrecoverable_error_location() |
| 2490 const { | 2497 const { |
| 2491 return unrecoverable_error_location_; | 2498 return unrecoverable_error_location_; |
| 2492 } | 2499 } |
| OLD | NEW |