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/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 bool ShouldShowActionOnUI( | 125 bool ShouldShowActionOnUI( |
126 const syncer::SyncProtocolError& error) { | 126 const syncer::SyncProtocolError& error) { |
127 return (error.action != syncer::UNKNOWN_ACTION && | 127 return (error.action != syncer::UNKNOWN_ACTION && |
128 error.action != syncer::DISABLE_SYNC_ON_CLIENT); | 128 error.action != syncer::DISABLE_SYNC_ON_CLIENT); |
129 } | 129 } |
130 | 130 |
131 ProfileSyncService::ProfileSyncService(ProfileSyncComponentsFactory* factory, | 131 ProfileSyncService::ProfileSyncService(ProfileSyncComponentsFactory* factory, |
132 Profile* profile, | 132 Profile* profile, |
133 SigninManager* signin_manager, | 133 SigninManager* signin_manager, |
134 StartBehavior start_behavior) | 134 StartBehavior start_behavior) |
135 : last_auth_error_(AuthError::None()), | 135 : last_auth_error_(AuthError::AuthErrorNone()), |
136 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED), | 136 passphrase_required_reason_(syncer::REASON_PASSPHRASE_NOT_REQUIRED), |
137 factory_(factory), | 137 factory_(factory), |
138 profile_(profile), | 138 profile_(profile), |
139 // |profile| may be NULL in unit tests. | 139 // |profile| may be NULL in unit tests. |
140 sync_prefs_(profile_ ? profile_->GetPrefs() : NULL), | 140 sync_prefs_(profile_ ? profile_->GetPrefs() : NULL), |
141 invalidator_storage_(profile_ ? profile_->GetPrefs(): NULL), | 141 invalidator_storage_(profile_ ? profile_->GetPrefs(): NULL), |
142 sync_service_url_(kDevServerUrl), | 142 sync_service_url_(kDevServerUrl), |
143 is_first_time_sync_configure_(false), | 143 is_first_time_sync_configure_(false), |
144 backend_initialized_(false), | 144 backend_initialized_(false), |
145 is_auth_in_progress_(false), | 145 is_auth_in_progress_(false), |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 // NULL if we're called from Shutdown(). | 662 // NULL if we're called from Shutdown(). |
663 if (invalidator_registrar_.get()) | 663 if (invalidator_registrar_.get()) |
664 UpdateInvalidatorRegistrarState(); | 664 UpdateInvalidatorRegistrarState(); |
665 cached_passphrase_.clear(); | 665 cached_passphrase_.clear(); |
666 encryption_pending_ = false; | 666 encryption_pending_ = false; |
667 encrypt_everything_ = false; | 667 encrypt_everything_ = false; |
668 encrypted_types_ = syncer::SyncEncryptionHandler::SensitiveTypes(); | 668 encrypted_types_ = syncer::SyncEncryptionHandler::SensitiveTypes(); |
669 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED; | 669 passphrase_required_reason_ = syncer::REASON_PASSPHRASE_NOT_REQUIRED; |
670 // Revert to "no auth error". | 670 // Revert to "no auth error". |
671 if (last_auth_error_.state() != GoogleServiceAuthError::NONE) | 671 if (last_auth_error_.state() != GoogleServiceAuthError::NONE) |
672 UpdateAuthErrorState(GoogleServiceAuthError::None()); | 672 UpdateAuthErrorState(GoogleServiceAuthError::AuthErrorNone()); |
673 | 673 |
674 if (sync_global_error_.get()) { | 674 if (sync_global_error_.get()) { |
675 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError( | 675 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError( |
676 sync_global_error_.get()); | 676 sync_global_error_.get()); |
677 RemoveObserver(sync_global_error_.get()); | 677 RemoveObserver(sync_global_error_.get()); |
678 sync_global_error_.reset(NULL); | 678 sync_global_error_.reset(NULL); |
679 } | 679 } |
680 } | 680 } |
681 | 681 |
682 void ProfileSyncService::DisableForUser() { | 682 void ProfileSyncService::DisableForUser() { |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 signin()->signin_global_error()->AuthStatusChanged(); | 996 signin()->signin_global_error()->AuthStatusChanged(); |
997 NotifyObservers(); | 997 NotifyObservers(); |
998 } | 998 } |
999 | 999 |
1000 namespace { | 1000 namespace { |
1001 | 1001 |
1002 AuthError ConnectionStatusToAuthError( | 1002 AuthError ConnectionStatusToAuthError( |
1003 syncer::ConnectionStatus status) { | 1003 syncer::ConnectionStatus status) { |
1004 switch (status) { | 1004 switch (status) { |
1005 case syncer::CONNECTION_OK: | 1005 case syncer::CONNECTION_OK: |
1006 return AuthError::None(); | 1006 return AuthError::AuthErrorNone(); |
1007 break; | 1007 break; |
1008 case syncer::CONNECTION_AUTH_ERROR: | 1008 case syncer::CONNECTION_AUTH_ERROR: |
1009 return AuthError(AuthError::INVALID_GAIA_CREDENTIALS); | 1009 return AuthError(AuthError::INVALID_GAIA_CREDENTIALS); |
1010 break; | 1010 break; |
1011 case syncer::CONNECTION_SERVER_ERROR: | 1011 case syncer::CONNECTION_SERVER_ERROR: |
1012 return AuthError(AuthError::CONNECTION_FAILED); | 1012 return AuthError(AuthError::CONNECTION_FAILED); |
1013 break; | 1013 break; |
1014 default: | 1014 default: |
1015 NOTREACHED(); | 1015 NOTREACHED(); |
1016 return AuthError(AuthError::CONNECTION_FAILED); | 1016 return AuthError(AuthError::CONNECTION_FAILED); |
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2020 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. | 2020 // See http://stackoverflow.com/questions/6224121/is-new-this-myclass-undefine
d-behaviour-after-directly-calling-the-destru. |
2021 ProfileSyncService* old_this = this; | 2021 ProfileSyncService* old_this = this; |
2022 this->~ProfileSyncService(); | 2022 this->~ProfileSyncService(); |
2023 new(old_this) ProfileSyncService( | 2023 new(old_this) ProfileSyncService( |
2024 new ProfileSyncComponentsFactoryImpl(profile, | 2024 new ProfileSyncComponentsFactoryImpl(profile, |
2025 CommandLine::ForCurrentProcess()), | 2025 CommandLine::ForCurrentProcess()), |
2026 profile, | 2026 profile, |
2027 signin, | 2027 signin, |
2028 behavior); | 2028 behavior); |
2029 } | 2029 } |
OLD | NEW |