| 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/profile_sync_service.h" | 5 #include "components/browser_sync/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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 syncer::GetSyncServiceURL(*base::CommandLine::ForCurrentProcess(), | 191 syncer::GetSyncServiceURL(*base::CommandLine::ForCurrentProcess(), |
| 192 init_params.channel)), | 192 init_params.channel)), |
| 193 network_time_update_callback_( | 193 network_time_update_callback_( |
| 194 std::move(init_params.network_time_update_callback)), | 194 std::move(init_params.network_time_update_callback)), |
| 195 url_request_context_(init_params.url_request_context), | 195 url_request_context_(init_params.url_request_context), |
| 196 blocking_pool_(init_params.blocking_pool), | 196 blocking_pool_(init_params.blocking_pool), |
| 197 is_first_time_sync_configure_(false), | 197 is_first_time_sync_configure_(false), |
| 198 engine_initialized_(false), | 198 engine_initialized_(false), |
| 199 sync_disabled_by_admin_(false), | 199 sync_disabled_by_admin_(false), |
| 200 is_auth_in_progress_(false), | 200 is_auth_in_progress_(false), |
| 201 local_sync_backend_folder_(init_params.local_sync_backend_folder), |
| 201 unrecoverable_error_reason_(ERROR_REASON_UNSET), | 202 unrecoverable_error_reason_(ERROR_REASON_UNSET), |
| 202 expect_sync_configuration_aborted_(false), | 203 expect_sync_configuration_aborted_(false), |
| 203 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()), | 204 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()), |
| 204 encrypt_everything_allowed_(true), | 205 encrypt_everything_allowed_(true), |
| 205 encrypt_everything_(false), | 206 encrypt_everything_(false), |
| 206 encryption_pending_(false), | 207 encryption_pending_(false), |
| 207 configure_status_(DataTypeManager::UNKNOWN), | 208 configure_status_(DataTypeManager::UNKNOWN), |
| 208 oauth2_token_service_(init_params.oauth2_token_service), | 209 oauth2_token_service_(init_params.oauth2_token_service), |
| 209 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy), | 210 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy), |
| 210 connection_status_(syncer::CONNECTION_NOT_ATTEMPTED), | 211 connection_status_(syncer::CONNECTION_NOT_ATTEMPTED), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 234 DCHECK(thread_checker_.CalledOnValidThread()); | 235 DCHECK(thread_checker_.CalledOnValidThread()); |
| 235 if (gaia_cookie_manager_service_) | 236 if (gaia_cookie_manager_service_) |
| 236 gaia_cookie_manager_service_->RemoveObserver(this); | 237 gaia_cookie_manager_service_->RemoveObserver(this); |
| 237 sync_prefs_.RemoveSyncPrefObserver(this); | 238 sync_prefs_.RemoveSyncPrefObserver(this); |
| 238 // Shutdown() should have been called before destruction. | 239 // Shutdown() should have been called before destruction. |
| 239 CHECK(!engine_initialized_); | 240 CHECK(!engine_initialized_); |
| 240 } | 241 } |
| 241 | 242 |
| 242 bool ProfileSyncService::CanSyncStart() const { | 243 bool ProfileSyncService::CanSyncStart() const { |
| 243 DCHECK(thread_checker_.CalledOnValidThread()); | 244 DCHECK(thread_checker_.CalledOnValidThread()); |
| 244 return IsSyncAllowed() && IsSyncRequested() && IsSignedIn(); | 245 return (IsSyncAllowed() && IsSyncRequested() && |
| 246 (IsLocalSyncEnabled() || IsSignedIn())); |
| 245 } | 247 } |
| 246 | 248 |
| 247 void ProfileSyncService::Initialize() { | 249 void ProfileSyncService::Initialize() { |
| 248 DCHECK(thread_checker_.CalledOnValidThread()); | 250 DCHECK(thread_checker_.CalledOnValidThread()); |
| 249 sync_client_->Initialize(); | 251 sync_client_->Initialize(); |
| 250 | 252 |
| 251 // We don't pass StartupController an Unretained reference to future-proof | 253 // We don't pass StartupController an Unretained reference to future-proof |
| 252 // against the controller impl changing to post tasks. | 254 // against the controller impl changing to post tasks. |
| 253 startup_controller_ = base::MakeUnique<syncer::StartupController>( | 255 startup_controller_ = base::MakeUnique<syncer::StartupController>( |
| 254 &sync_prefs_, | 256 &sync_prefs_, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 gaia_cookie_manager_service_->AddObserver(this); | 303 gaia_cookie_manager_service_->AddObserver(this); |
| 302 | 304 |
| 303 // We clear this here (vs Shutdown) because we want to remember that an error | 305 // We clear this here (vs Shutdown) because we want to remember that an error |
| 304 // happened on shutdown so we can display details (message, location) about it | 306 // happened on shutdown so we can display details (message, location) about it |
| 305 // in about:sync. | 307 // in about:sync. |
| 306 ClearStaleErrors(); | 308 ClearStaleErrors(); |
| 307 | 309 |
| 308 sync_prefs_.AddSyncPrefObserver(this); | 310 sync_prefs_.AddSyncPrefObserver(this); |
| 309 | 311 |
| 310 SyncInitialState sync_state = CAN_START; | 312 SyncInitialState sync_state = CAN_START; |
| 311 if (!IsSignedIn()) { | 313 if (!IsLocalSyncEnabled() && !IsSignedIn()) { |
| 312 sync_state = NOT_SIGNED_IN; | 314 sync_state = NOT_SIGNED_IN; |
| 313 } else if (IsManaged()) { | 315 } else if (IsManaged()) { |
| 314 sync_state = IS_MANAGED; | 316 sync_state = IS_MANAGED; |
| 315 } else if (!IsSyncAllowedByPlatform()) { | 317 } else if (!IsSyncAllowedByPlatform()) { |
| 316 // This case should currently never be hit, as Android's master sync isn't | 318 // This case should currently never be hit, as Android's master sync isn't |
| 317 // plumbed into PSS until after this function. See http://crbug.com/568771. | 319 // plumbed into PSS until after this function. See http://crbug.com/568771. |
| 318 sync_state = NOT_ALLOWED_BY_PLATFORM; | 320 sync_state = NOT_ALLOWED_BY_PLATFORM; |
| 319 } else if (!IsSyncRequested()) { | 321 } else if (!IsSyncRequested()) { |
| 320 if (IsFirstSetupComplete()) { | 322 if (IsFirstSetupComplete()) { |
| 321 sync_state = NOT_REQUESTED; | 323 sync_state = NOT_REQUESTED; |
| 322 } else { | 324 } else { |
| 323 sync_state = NOT_REQUESTED_NOT_SETUP; | 325 sync_state = NOT_REQUESTED_NOT_SETUP; |
| 324 } | 326 } |
| 325 } else if (!IsFirstSetupComplete()) { | 327 } else if (!IsFirstSetupComplete()) { |
| 326 sync_state = NEEDS_CONFIRMATION; | 328 sync_state = NEEDS_CONFIRMATION; |
| 327 } | 329 } |
| 328 UMA_HISTOGRAM_ENUMERATION("Sync.InitialState", sync_state, | 330 UMA_HISTOGRAM_ENUMERATION("Sync.InitialState", sync_state, |
| 329 SYNC_INITIAL_STATE_LIMIT); | 331 SYNC_INITIAL_STATE_LIMIT); |
| 330 | 332 |
| 331 // If sync isn't allowed, the only thing to do is to turn it off. | 333 // If sync isn't allowed, the only thing to do is to turn it off. |
| 332 if (!IsSyncAllowed()) { | 334 if (!IsSyncAllowed()) { |
| 333 // Only clear data if disallowed by policy. | 335 // Only clear data if disallowed by policy. |
| 334 RequestStop(IsManaged() ? CLEAR_DATA : KEEP_DATA); | 336 RequestStop(IsManaged() ? CLEAR_DATA : KEEP_DATA); |
| 335 return; | 337 return; |
| 336 } | 338 } |
| 337 | 339 |
| 338 RegisterAuthNotifications(); | 340 if (!IsLocalSyncEnabled()) { |
| 341 RegisterAuthNotifications(); |
| 339 | 342 |
| 340 if (!IsSignedIn()) { | 343 if (!IsSignedIn()) { |
| 341 // Clean up in case of previous crash during signout. | 344 // Clean up in case of previous crash during signout. |
| 342 StopImpl(CLEAR_DATA); | 345 StopImpl(CLEAR_DATA); |
| 346 } |
| 343 } | 347 } |
| 344 | 348 |
| 345 #if defined(OS_CHROMEOS) | 349 #if defined(OS_CHROMEOS) |
| 346 std::string bootstrap_token = sync_prefs_.GetEncryptionBootstrapToken(); | 350 std::string bootstrap_token = sync_prefs_.GetEncryptionBootstrapToken(); |
| 347 if (bootstrap_token.empty()) { | 351 if (bootstrap_token.empty()) { |
| 348 sync_prefs_.SetEncryptionBootstrapToken( | 352 sync_prefs_.SetEncryptionBootstrapToken( |
| 349 sync_prefs_.GetSpareBootstrapToken()); | 353 sync_prefs_.GetSpareBootstrapToken()); |
| 350 } | 354 } |
| 351 #endif | 355 #endif |
| 352 | 356 |
| 353 #if !defined(OS_ANDROID) | 357 #if !defined(OS_ANDROID) |
| 354 DCHECK(sync_error_controller_ == nullptr) | 358 DCHECK(sync_error_controller_ == nullptr) |
| 355 << "Initialize() called more than once."; | 359 << "Initialize() called more than once."; |
| 356 sync_error_controller_ = base::MakeUnique<syncer::SyncErrorController>(this); | 360 sync_error_controller_ = base::MakeUnique<syncer::SyncErrorController>(this); |
| 357 AddObserver(sync_error_controller_.get()); | 361 AddObserver(sync_error_controller_.get()); |
| 358 #endif | 362 #endif |
| 359 | 363 |
| 360 memory_pressure_listener_ = base::MakeUnique<base::MemoryPressureListener>( | 364 memory_pressure_listener_ = base::MakeUnique<base::MemoryPressureListener>( |
| 361 base::Bind(&ProfileSyncService::OnMemoryPressure, | 365 base::Bind(&ProfileSyncService::OnMemoryPressure, |
| 362 sync_enabled_weak_factory_.GetWeakPtr())); | 366 sync_enabled_weak_factory_.GetWeakPtr())); |
| 363 startup_controller_->Reset(GetRegisteredDataTypes()); | 367 startup_controller_->Reset(GetRegisteredDataTypes()); |
| 364 | 368 |
| 365 // Auto-start means means the first time the profile starts up, sync should | 369 // Auto-start means the first time the profile starts up, sync should start up |
| 366 // start up immediately. | 370 // immediately. |
| 367 if (start_behavior_ == AUTO_START && IsSyncRequested() && | 371 if (start_behavior_ == AUTO_START && IsSyncRequested() && |
| 368 !IsFirstSetupComplete()) { | 372 !IsFirstSetupComplete()) { |
| 369 startup_controller_->TryStartImmediately(); | 373 startup_controller_->TryStartImmediately(); |
| 370 } else { | 374 } else { |
| 371 startup_controller_->TryStart(); | 375 startup_controller_->TryStart(); |
| 372 } | 376 } |
| 373 } | 377 } |
| 374 | 378 |
| 375 void ProfileSyncService::StartSyncingWithServer() { | 379 void ProfileSyncService::StartSyncingWithServer() { |
| 376 if (base::FeatureList::IsEnabled( | 380 if (base::FeatureList::IsEnabled( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 392 DCHECK(thread_checker_.CalledOnValidThread()); | 396 DCHECK(thread_checker_.CalledOnValidThread()); |
| 393 oauth2_token_service_->AddObserver(this); | 397 oauth2_token_service_->AddObserver(this); |
| 394 if (signin()) | 398 if (signin()) |
| 395 signin()->AddObserver(this); | 399 signin()->AddObserver(this); |
| 396 } | 400 } |
| 397 | 401 |
| 398 void ProfileSyncService::UnregisterAuthNotifications() { | 402 void ProfileSyncService::UnregisterAuthNotifications() { |
| 399 DCHECK(thread_checker_.CalledOnValidThread()); | 403 DCHECK(thread_checker_.CalledOnValidThread()); |
| 400 if (signin()) | 404 if (signin()) |
| 401 signin()->RemoveObserver(this); | 405 signin()->RemoveObserver(this); |
| 402 oauth2_token_service_->RemoveObserver(this); | 406 if (oauth2_token_service_) |
| 407 oauth2_token_service_->RemoveObserver(this); |
| 403 } | 408 } |
| 404 | 409 |
| 405 void ProfileSyncService::RegisterDataTypeController( | 410 void ProfileSyncService::RegisterDataTypeController( |
| 406 std::unique_ptr<syncer::DataTypeController> data_type_controller) { | 411 std::unique_ptr<syncer::DataTypeController> data_type_controller) { |
| 407 DCHECK(thread_checker_.CalledOnValidThread()); | 412 DCHECK(thread_checker_.CalledOnValidThread()); |
| 408 DCHECK_EQ(data_type_controllers_.count(data_type_controller->type()), 0U); | 413 DCHECK_EQ(data_type_controllers_.count(data_type_controller->type()), 0U); |
| 409 data_type_controllers_[data_type_controller->type()] = | 414 data_type_controllers_[data_type_controller->type()] = |
| 410 std::move(data_type_controller); | 415 std::move(data_type_controller); |
| 411 } | 416 } |
| 412 | 417 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 return; | 473 return; |
| 469 } | 474 } |
| 470 DCHECK(iter->second); | 475 DCHECK(iter->second); |
| 471 | 476 |
| 472 static_cast<sync_sessions::SessionDataTypeController*>(iter->second.get()) | 477 static_cast<sync_sessions::SessionDataTypeController*>(iter->second.get()) |
| 473 ->OnSessionRestoreComplete(); | 478 ->OnSessionRestoreComplete(); |
| 474 } | 479 } |
| 475 | 480 |
| 476 SyncCredentials ProfileSyncService::GetCredentials() { | 481 SyncCredentials ProfileSyncService::GetCredentials() { |
| 477 SyncCredentials credentials; | 482 SyncCredentials credentials; |
| 483 |
| 484 // No credentials exist or are needed for the local sync backend. |
| 485 if (IsLocalSyncEnabled()) |
| 486 return credentials; |
| 487 |
| 478 credentials.account_id = signin_->GetAccountIdToUse(); | 488 credentials.account_id = signin_->GetAccountIdToUse(); |
| 479 DCHECK(!credentials.account_id.empty()); | 489 DCHECK(!credentials.account_id.empty()); |
| 480 credentials.email = signin_->GetEffectiveUsername(); | 490 credentials.email = signin_->GetEffectiveUsername(); |
| 481 credentials.sync_token = access_token_; | 491 credentials.sync_token = access_token_; |
| 482 | 492 |
| 483 if (credentials.sync_token.empty()) | 493 if (credentials.sync_token.empty()) |
| 484 credentials.sync_token = "credentials_lost"; | 494 credentials.sync_token = "credentials_lost"; |
| 485 | 495 |
| 486 credentials.scope_set.insert(signin_->GetSyncScopeToUse()); | 496 credentials.scope_set.insert(signin_->GetSyncScopeToUse()); |
| 487 | 497 |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 OnInternalUnrecoverableError(FROM_HERE, "BackendInitialize failure", false, | 952 OnInternalUnrecoverableError(FROM_HERE, "BackendInitialize failure", false, |
| 943 ERROR_REASON_ENGINE_INIT_FAILURE); | 953 ERROR_REASON_ENGINE_INIT_FAILURE); |
| 944 return; | 954 return; |
| 945 } | 955 } |
| 946 | 956 |
| 947 engine_initialized_ = true; | 957 engine_initialized_ = true; |
| 948 | 958 |
| 949 sync_js_controller_.AttachJsBackend(js_backend); | 959 sync_js_controller_.AttachJsBackend(js_backend); |
| 950 debug_info_listener_ = debug_info_listener; | 960 debug_info_listener_ = debug_info_listener; |
| 951 | 961 |
| 952 SigninClient* signin_client = signin_->GetOriginal()->signin_client(); | 962 std::string signin_scoped_device_id; |
| 953 DCHECK(signin_client); | 963 if (IsLocalSyncEnabled()) { |
| 954 std::string signin_scoped_device_id = | 964 signin_scoped_device_id = "local_device"; |
| 955 signin_client->GetSigninScopedDeviceId(); | 965 } else { |
| 966 SigninClient* signin_client = signin_->GetOriginal()->signin_client(); |
| 967 DCHECK(signin_client); |
| 968 std::string signin_scoped_device_id = |
| 969 signin_client->GetSigninScopedDeviceId(); |
| 970 } |
| 956 | 971 |
| 957 // Initialize local device info. | 972 // Initialize local device info. |
| 958 local_device_->Initialize(cache_guid, signin_scoped_device_id, | 973 local_device_->Initialize(cache_guid, signin_scoped_device_id, |
| 959 blocking_pool_); | 974 blocking_pool_); |
| 960 | 975 |
| 961 if (protocol_event_observers_.might_have_observers()) { | 976 if (protocol_event_observers_.might_have_observers()) { |
| 962 engine_->RequestBufferedProtocolEventsAndEnableForwarding(); | 977 engine_->RequestBufferedProtocolEventsAndEnableForwarding(); |
| 963 } | 978 } |
| 964 | 979 |
| 965 if (type_debug_info_observers_.might_have_observers()) { | 980 if (type_debug_info_observers_.might_have_observers()) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 995 std::vector<gaia::ListedAccount> accounts; | 1010 std::vector<gaia::ListedAccount> accounts; |
| 996 std::vector<gaia::ListedAccount> signed_out_accounts; | 1011 std::vector<gaia::ListedAccount> signed_out_accounts; |
| 997 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); | 1012 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); |
| 998 if (gaia_cookie_manager_service_ && | 1013 if (gaia_cookie_manager_service_ && |
| 999 gaia_cookie_manager_service_->ListAccounts( | 1014 gaia_cookie_manager_service_->ListAccounts( |
| 1000 &accounts, &signed_out_accounts, "ChromiumProfileSyncService")) { | 1015 &accounts, &signed_out_accounts, "ChromiumProfileSyncService")) { |
| 1001 OnGaiaAccountsInCookieUpdated(accounts, signed_out_accounts, error); | 1016 OnGaiaAccountsInCookieUpdated(accounts, signed_out_accounts, error); |
| 1002 } | 1017 } |
| 1003 | 1018 |
| 1004 NotifyObservers(); | 1019 NotifyObservers(); |
| 1020 |
| 1021 // Nobody will call us to start if no sign in is going to happen. |
| 1022 if (IsLocalSyncEnabled()) |
| 1023 RequestStart(); |
| 1005 } | 1024 } |
| 1006 | 1025 |
| 1007 void ProfileSyncService::OnSyncCycleCompleted() { | 1026 void ProfileSyncService::OnSyncCycleCompleted() { |
| 1008 DCHECK(thread_checker_.CalledOnValidThread()); | 1027 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1009 UpdateLastSyncedTime(); | 1028 UpdateLastSyncedTime(); |
| 1010 const syncer::SyncCycleSnapshot snapshot = GetLastCycleSnapshot(); | 1029 const syncer::SyncCycleSnapshot snapshot = GetLastCycleSnapshot(); |
| 1011 if (IsDataTypeControllerRunning(syncer::SESSIONS) && | 1030 if (IsDataTypeControllerRunning(syncer::SESSIONS) && |
| 1012 snapshot.model_neutral_state().get_updates_request_types.Has( | 1031 snapshot.model_neutral_state().get_updates_request_types.Has( |
| 1013 syncer::SESSIONS) && | 1032 syncer::SESSIONS) && |
| 1014 !syncer::HasSyncerError(snapshot.model_neutral_state())) { | 1033 !syncer::HasSyncerError(snapshot.model_neutral_state())) { |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1523 DCHECK(thread_checker_.CalledOnValidThread()); | 1542 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1524 return IsSyncAllowedByFlag() && !IsManaged() && IsSyncAllowedByPlatform(); | 1543 return IsSyncAllowedByFlag() && !IsManaged() && IsSyncAllowedByPlatform(); |
| 1525 } | 1544 } |
| 1526 | 1545 |
| 1527 bool ProfileSyncService::IsSyncActive() const { | 1546 bool ProfileSyncService::IsSyncActive() const { |
| 1528 DCHECK(thread_checker_.CalledOnValidThread()); | 1547 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1529 return engine_initialized_ && data_type_manager_ && | 1548 return engine_initialized_ && data_type_manager_ && |
| 1530 data_type_manager_->state() != DataTypeManager::STOPPED; | 1549 data_type_manager_->state() != DataTypeManager::STOPPED; |
| 1531 } | 1550 } |
| 1532 | 1551 |
| 1552 bool ProfileSyncService::IsLocalSyncEnabled() const { |
| 1553 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1554 return sync_prefs_.IsLocalSyncEnabled(); |
| 1555 } |
| 1556 |
| 1533 void ProfileSyncService::TriggerRefresh(const syncer::ModelTypeSet& types) { | 1557 void ProfileSyncService::TriggerRefresh(const syncer::ModelTypeSet& types) { |
| 1534 DCHECK(thread_checker_.CalledOnValidThread()); | 1558 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1535 if (engine_initialized_) | 1559 if (engine_initialized_) |
| 1536 engine_->TriggerRefresh(types); | 1560 engine_->TriggerRefresh(types); |
| 1537 } | 1561 } |
| 1538 | 1562 |
| 1539 bool ProfileSyncService::IsSignedIn() const { | 1563 bool ProfileSyncService::IsSignedIn() const { |
| 1540 // Sync is logged in if there is a non-empty effective account id. | 1564 // Sync is logged in if there is a non-empty effective account id. |
| 1541 return !signin_->GetAccountIdToUse().empty(); | 1565 return !signin_->GetAccountIdToUse().empty(); |
| 1542 } | 1566 } |
| 1543 | 1567 |
| 1544 bool ProfileSyncService::CanEngineStart() const { | 1568 bool ProfileSyncService::CanEngineStart() const { |
| 1569 if (IsLocalSyncEnabled()) |
| 1570 return true; |
| 1545 return CanSyncStart() && oauth2_token_service_ && | 1571 return CanSyncStart() && oauth2_token_service_ && |
| 1546 oauth2_token_service_->RefreshTokenIsAvailable( | 1572 oauth2_token_service_->RefreshTokenIsAvailable( |
| 1547 signin_->GetAccountIdToUse()); | 1573 signin_->GetAccountIdToUse()); |
| 1548 } | 1574 } |
| 1549 | 1575 |
| 1550 bool ProfileSyncService::IsEngineInitialized() const { | 1576 bool ProfileSyncService::IsEngineInitialized() const { |
| 1551 DCHECK(thread_checker_.CalledOnValidThread()); | 1577 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1552 return engine_initialized_; | 1578 return engine_initialized_; |
| 1553 } | 1579 } |
| 1554 | 1580 |
| (...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2491 std::unique_ptr<syncer::NetworkResources> network_resources) { | 2517 std::unique_ptr<syncer::NetworkResources> network_resources) { |
| 2492 DCHECK(thread_checker_.CalledOnValidThread()); | 2518 DCHECK(thread_checker_.CalledOnValidThread()); |
| 2493 network_resources_ = std::move(network_resources); | 2519 network_resources_ = std::move(network_resources); |
| 2494 } | 2520 } |
| 2495 | 2521 |
| 2496 bool ProfileSyncService::HasSyncingEngine() const { | 2522 bool ProfileSyncService::HasSyncingEngine() const { |
| 2497 return engine_ != nullptr; | 2523 return engine_ != nullptr; |
| 2498 } | 2524 } |
| 2499 | 2525 |
| 2500 void ProfileSyncService::UpdateFirstSyncTimePref() { | 2526 void ProfileSyncService::UpdateFirstSyncTimePref() { |
| 2501 if (!IsSignedIn()) { | 2527 if (!IsLocalSyncEnabled() && !IsSignedIn()) { |
| 2502 sync_prefs_.ClearFirstSyncTime(); | 2528 sync_prefs_.ClearFirstSyncTime(); |
| 2503 } else if (sync_prefs_.GetFirstSyncTime().is_null()) { | 2529 } else if (sync_prefs_.GetFirstSyncTime().is_null()) { |
| 2504 // Set if not set before and it's syncing now. | 2530 // Set if not set before and it's syncing now. |
| 2505 sync_prefs_.SetFirstSyncTime(base::Time::Now()); | 2531 sync_prefs_.SetFirstSyncTime(base::Time::Now()); |
| 2506 } | 2532 } |
| 2507 } | 2533 } |
| 2508 | 2534 |
| 2509 void ProfileSyncService::FlushDirectory() const { | 2535 void ProfileSyncService::FlushDirectory() const { |
| 2510 DCHECK(thread_checker_.CalledOnValidThread()); | 2536 DCHECK(thread_checker_.CalledOnValidThread()); |
| 2511 // engine_initialized_ implies engine_ isn't null and the manager exists. | 2537 // engine_initialized_ implies engine_ isn't null and the manager exists. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2602 | 2628 |
| 2603 DCHECK(startup_controller_->IsSetupInProgress()); | 2629 DCHECK(startup_controller_->IsSetupInProgress()); |
| 2604 startup_controller_->SetSetupInProgress(false); | 2630 startup_controller_->SetSetupInProgress(false); |
| 2605 | 2631 |
| 2606 if (IsEngineInitialized()) | 2632 if (IsEngineInitialized()) |
| 2607 ReconfigureDatatypeManager(); | 2633 ReconfigureDatatypeManager(); |
| 2608 NotifyObservers(); | 2634 NotifyObservers(); |
| 2609 } | 2635 } |
| 2610 | 2636 |
| 2611 } // namespace browser_sync | 2637 } // namespace browser_sync |
| OLD | NEW |