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 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 unrecoverable_error_reason_, | 834 unrecoverable_error_reason_, |
835 ERROR_REASON_LIMIT); | 835 ERROR_REASON_LIMIT); |
836 NotifyObservers(); | 836 NotifyObservers(); |
837 std::string location; | 837 std::string location; |
838 from_here.Write(true, true, &location); | 838 from_here.Write(true, true, &location); |
839 LOG(ERROR) | 839 LOG(ERROR) |
840 << "Unrecoverable error detected at " << location | 840 << "Unrecoverable error detected at " << location |
841 << " -- ProfileSyncService unusable: " << message; | 841 << " -- ProfileSyncService unusable: " << message; |
842 | 842 |
843 // Shut all data types down. | 843 // Shut all data types down. |
844 MessageLoop::current()->PostTask(FROM_HERE, | 844 base::MessageLoop::current()->PostTask(FROM_HERE, |
845 base::Bind(&ProfileSyncService::ShutdownImpl, weak_factory_.GetWeakPtr(), | 845 base::Bind(&ProfileSyncService::ShutdownImpl, weak_factory_.GetWeakPtr(), |
846 delete_sync_database)); | 846 delete_sync_database)); |
847 } | 847 } |
848 | 848 |
849 void ProfileSyncService::DisableBrokenDatatype( | 849 void ProfileSyncService::DisableBrokenDatatype( |
850 syncer::ModelType type, | 850 syncer::ModelType type, |
851 const tracked_objects::Location& from_here, | 851 const tracked_objects::Location& from_here, |
852 std::string message) { | 852 std::string message) { |
853 // First deactivate the type so that no further server changes are | 853 // First deactivate the type so that no further server changes are |
854 // passed onto the change processor. | 854 // passed onto the change processor. |
855 DeactivateDataType(type); | 855 DeactivateDataType(type); |
856 | 856 |
857 syncer::SyncError error(from_here, message, type); | 857 syncer::SyncError error(from_here, message, type); |
858 | 858 |
859 std::list<syncer::SyncError> errors; | 859 std::list<syncer::SyncError> errors; |
860 errors.push_back(error); | 860 errors.push_back(error); |
861 | 861 |
862 // Update this before posting a task. So if a configure happens before | 862 // Update this before posting a task. So if a configure happens before |
863 // the task that we are going to post, this type would still be disabled. | 863 // the task that we are going to post, this type would still be disabled. |
864 failed_datatypes_handler_.UpdateFailedDatatypes(errors, | 864 failed_datatypes_handler_.UpdateFailedDatatypes(errors, |
865 FailedDatatypesHandler::RUNTIME); | 865 FailedDatatypesHandler::RUNTIME); |
866 | 866 |
867 MessageLoop::current()->PostTask(FROM_HERE, | 867 base::MessageLoop::current()->PostTask(FROM_HERE, |
868 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, | 868 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, |
869 weak_factory_.GetWeakPtr())); | 869 weak_factory_.GetWeakPtr())); |
870 } | 870 } |
871 | 871 |
872 void ProfileSyncService::OnInvalidatorStateChange( | 872 void ProfileSyncService::OnInvalidatorStateChange( |
873 syncer::InvalidatorState state) { | 873 syncer::InvalidatorState state) { |
874 invalidator_state_ = state; | 874 invalidator_state_ = state; |
875 UpdateInvalidatorRegistrarState(); | 875 UpdateInvalidatorRegistrarState(); |
876 } | 876 } |
877 | 877 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
960 } | 960 } |
961 | 961 |
962 void ProfileSyncService::OnSyncCycleCompleted() { | 962 void ProfileSyncService::OnSyncCycleCompleted() { |
963 UpdateLastSyncedTime(); | 963 UpdateLastSyncedTime(); |
964 if (GetSessionModelAssociator()) { | 964 if (GetSessionModelAssociator()) { |
965 // Trigger garbage collection of old sessions now that we've downloaded | 965 // Trigger garbage collection of old sessions now that we've downloaded |
966 // any new session data. TODO(zea): Have this be a notification the session | 966 // any new session data. TODO(zea): Have this be a notification the session |
967 // model associator listens too. Also consider somehow plumbing the current | 967 // model associator listens too. Also consider somehow plumbing the current |
968 // server time as last reported by CheckServerReachable, so we don't have to | 968 // server time as last reported by CheckServerReachable, so we don't have to |
969 // rely on the local clock, which may be off significantly. | 969 // rely on the local clock, which may be off significantly. |
970 MessageLoop::current()->PostTask(FROM_HERE, | 970 base::MessageLoop::current()->PostTask(FROM_HERE, |
971 base::Bind(&browser_sync::SessionModelAssociator::DeleteStaleSessions, | 971 base::Bind(&browser_sync::SessionModelAssociator::DeleteStaleSessions, |
972 GetSessionModelAssociator()->AsWeakPtr())); | 972 GetSessionModelAssociator()->AsWeakPtr())); |
973 } | 973 } |
974 DVLOG(2) << "Notifying observers sync cycle completed"; | 974 DVLOG(2) << "Notifying observers sync cycle completed"; |
975 NotifyObservers(); | 975 NotifyObservers(); |
976 } | 976 } |
977 | 977 |
978 void ProfileSyncService::OnExperimentsChanged( | 978 void ProfileSyncService::OnExperimentsChanged( |
979 const syncer::Experiments& experiments) { | 979 const syncer::Experiments& experiments) { |
980 if (current_experiments_.Matches(experiments)) | 980 if (current_experiments_.Matches(experiments)) |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 LOG(ERROR) << "ProfileSyncService error: " | 1295 LOG(ERROR) << "ProfileSyncService error: " |
1296 << message; | 1296 << message; |
1297 OnInternalUnrecoverableError(error.location(), | 1297 OnInternalUnrecoverableError(error.location(), |
1298 message, | 1298 message, |
1299 true, | 1299 true, |
1300 ERROR_REASON_CONFIGURATION_FAILURE); | 1300 ERROR_REASON_CONFIGURATION_FAILURE); |
1301 return; | 1301 return; |
1302 } | 1302 } |
1303 | 1303 |
1304 // Now handle partial success and full success. | 1304 // Now handle partial success and full success. |
1305 MessageLoop::current()->PostTask(FROM_HERE, | 1305 base::MessageLoop::current()->PostTask(FROM_HERE, |
1306 base::Bind(&ProfileSyncService::OnSyncConfigureDone, | 1306 base::Bind(&ProfileSyncService::OnSyncConfigureDone, |
1307 weak_factory_.GetWeakPtr(), result)); | 1307 weak_factory_.GetWeakPtr(), result)); |
1308 | 1308 |
1309 // We should never get in a state where we have no encrypted datatypes | 1309 // We should never get in a state where we have no encrypted datatypes |
1310 // enabled, and yet we still think we require a passphrase for decryption. | 1310 // enabled, and yet we still think we require a passphrase for decryption. |
1311 DCHECK(!(IsPassphraseRequiredForDecryption() && | 1311 DCHECK(!(IsPassphraseRequiredForDecryption() && |
1312 !IsEncryptedDatatypeEnabled())); | 1312 !IsEncryptedDatatypeEnabled())); |
1313 | 1313 |
1314 // This must be done before we start syncing with the server to avoid | 1314 // This must be done before we start syncing with the server to avoid |
1315 // sending unencrypted data up on a first time sync. | 1315 // sending unencrypted data up on a first time sync. |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2104 #if defined(ENABLE_MANAGED_USERS) | 2104 #if defined(ENABLE_MANAGED_USERS) |
2105 if (ManagedUserService::ProfileIsManaged(profile_)) { | 2105 if (ManagedUserService::ProfileIsManaged(profile_)) { |
2106 DCHECK_EQ(std::string(), signin_->GetAuthenticatedUsername()); | 2106 DCHECK_EQ(std::string(), signin_->GetAuthenticatedUsername()); |
2107 return ManagedUserService::GetManagedUserPseudoEmail(); | 2107 return ManagedUserService::GetManagedUserPseudoEmail(); |
2108 } | 2108 } |
2109 #endif | 2109 #endif |
2110 | 2110 |
2111 return signin_->GetAuthenticatedUsername(); | 2111 return signin_->GetAuthenticatedUsername(); |
2112 } | 2112 } |
2113 | 2113 |
OLD | NEW |