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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 << " -- ProfileSyncService unusable: " << message; | 944 << " -- ProfileSyncService unusable: " << message; |
945 | 945 |
946 // Shut all data types down. | 946 // Shut all data types down. |
947 base::MessageLoop::current()->PostTask(FROM_HERE, | 947 base::MessageLoop::current()->PostTask(FROM_HERE, |
948 base::Bind(&ProfileSyncService::ShutdownImpl, | 948 base::Bind(&ProfileSyncService::ShutdownImpl, |
949 weak_factory_.GetWeakPtr(), | 949 weak_factory_.GetWeakPtr(), |
950 delete_sync_database ? | 950 delete_sync_database ? |
951 syncer::DISABLE_SYNC : syncer::STOP_SYNC)); | 951 syncer::DISABLE_SYNC : syncer::STOP_SYNC)); |
952 } | 952 } |
953 | 953 |
| 954 // TODO(zea): Move this logic into the DataTypeController/DataTypeManager. |
| 955 void ProfileSyncService::DisableDatatype(const syncer::SyncError& error) { |
| 956 // First deactivate the type so that no further server changes are |
| 957 // passed onto the change processor. |
| 958 DeactivateDataType(error.model_type()); |
| 959 |
| 960 std::map<syncer::ModelType, syncer::SyncError> errors; |
| 961 errors[error.model_type()] = error; |
| 962 |
| 963 // Update this before posting a task. So if a configure happens before |
| 964 // the task that we are going to post, this type would still be disabled. |
| 965 failed_data_types_handler_.UpdateFailedDataTypes(errors); |
| 966 |
| 967 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 968 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, |
| 969 weak_factory_.GetWeakPtr())); |
| 970 } |
| 971 |
954 void ProfileSyncService::ReenableDatatype(syncer::ModelType type) { | 972 void ProfileSyncService::ReenableDatatype(syncer::ModelType type) { |
955 // Only reconfigure if the type actually had a data type or unready error. | 973 // Only reconfigure if the type actually had a data type or unready error. |
956 if (!failed_data_types_handler_.ResetDataTypeErrorFor(type) && | 974 if (!failed_data_types_handler_.ResetDataTypeErrorFor(type) && |
957 !failed_data_types_handler_.ResetUnreadyErrorFor(type)) { | 975 !failed_data_types_handler_.ResetUnreadyErrorFor(type)) { |
958 return; | 976 return; |
959 } | 977 } |
960 | 978 |
961 // If the type is no longer enabled, don't bother reconfiguring. | 979 // If the type is no longer enabled, don't bother reconfiguring. |
962 // TODO(zea): something else should encapsulate the notion of "whether a type | 980 // TODO(zea): something else should encapsulate the notion of "whether a type |
963 // should be enabled". | 981 // should be enabled". |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 | 1377 |
1360 // If sessions are encrypted, full history sync is not possible, and | 1378 // If sessions are encrypted, full history sync is not possible, and |
1361 // delete directives are unnecessary. | 1379 // delete directives are unnecessary. |
1362 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && | 1380 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && |
1363 encrypted_types_.Has(syncer::SESSIONS)) { | 1381 encrypted_types_.Has(syncer::SESSIONS)) { |
1364 syncer::SyncError error( | 1382 syncer::SyncError error( |
1365 FROM_HERE, | 1383 FROM_HERE, |
1366 syncer::SyncError::DATATYPE_POLICY_ERROR, | 1384 syncer::SyncError::DATATYPE_POLICY_ERROR, |
1367 "Delete directives not supported with encryption.", | 1385 "Delete directives not supported with encryption.", |
1368 syncer::HISTORY_DELETE_DIRECTIVES); | 1386 syncer::HISTORY_DELETE_DIRECTIVES); |
1369 FailedDataTypesHandler::TypeErrorMap error_map; | 1387 DisableDatatype(error); |
1370 error_map[error.model_type()] = error; | |
1371 failed_data_types_handler_.UpdateFailedDataTypes(error_map); | |
1372 ReconfigureDatatypeManager(); | |
1373 } | 1388 } |
1374 } | 1389 } |
1375 | 1390 |
1376 void ProfileSyncService::OnEncryptionComplete() { | 1391 void ProfileSyncService::OnEncryptionComplete() { |
1377 DVLOG(1) << "Encryption complete"; | 1392 DVLOG(1) << "Encryption complete"; |
1378 if (encryption_pending_ && encrypt_everything_) { | 1393 if (encryption_pending_ && encrypt_everything_) { |
1379 encryption_pending_ = false; | 1394 encryption_pending_ = false; |
1380 // This is to nudge the integration tests when encryption is | 1395 // This is to nudge the integration tests when encryption is |
1381 // finished. | 1396 // finished. |
1382 NotifyObservers(); | 1397 NotifyObservers(); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 sync_prefs_.SetKeepEverythingSynced(sync_everything); | 1785 sync_prefs_.SetKeepEverythingSynced(sync_everything); |
1771 | 1786 |
1772 failed_data_types_handler_.Reset(); | 1787 failed_data_types_handler_.Reset(); |
1773 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && | 1788 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && |
1774 encrypted_types_.Has(syncer::SESSIONS)) { | 1789 encrypted_types_.Has(syncer::SESSIONS)) { |
1775 syncer::SyncError error( | 1790 syncer::SyncError error( |
1776 FROM_HERE, | 1791 FROM_HERE, |
1777 syncer::SyncError::DATATYPE_POLICY_ERROR, | 1792 syncer::SyncError::DATATYPE_POLICY_ERROR, |
1778 "Delete directives not supported with encryption.", | 1793 "Delete directives not supported with encryption.", |
1779 syncer::HISTORY_DELETE_DIRECTIVES); | 1794 syncer::HISTORY_DELETE_DIRECTIVES); |
1780 FailedDataTypesHandler::TypeErrorMap error_map; | 1795 DisableDatatype(error); |
1781 error_map[error.model_type()] = error; | |
1782 failed_data_types_handler_.UpdateFailedDataTypes(error_map); | |
1783 } | 1796 } |
1784 ChangePreferredDataTypes(chosen_types); | 1797 ChangePreferredDataTypes(chosen_types); |
1785 AcknowledgeSyncedTypes(); | 1798 AcknowledgeSyncedTypes(); |
1786 NotifyObservers(); | 1799 NotifyObservers(); |
1787 } | 1800 } |
1788 | 1801 |
1789 void ProfileSyncService::ChangePreferredDataTypes( | 1802 void ProfileSyncService::ChangePreferredDataTypes( |
1790 syncer::ModelTypeSet preferred_types) { | 1803 syncer::ModelTypeSet preferred_types) { |
1791 | 1804 |
1792 DVLOG(1) << "ChangePreferredDataTypes invoked"; | 1805 DVLOG(1) << "ChangePreferredDataTypes invoked"; |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2679 browser_sync::SyncedDeviceTracker* device_tracker = | 2692 browser_sync::SyncedDeviceTracker* device_tracker = |
2680 backend_->GetSyncedDeviceTracker(); | 2693 backend_->GetSyncedDeviceTracker(); |
2681 if (device_tracker) | 2694 if (device_tracker) |
2682 device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_); | 2695 device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_); |
2683 } | 2696 } |
2684 } | 2697 } |
2685 | 2698 |
2686 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { | 2699 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { |
2687 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime(); | 2700 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime(); |
2688 } | 2701 } |
OLD | NEW |