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 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 | |
972 void ProfileSyncService::ReenableDatatype(syncer::ModelType type) { | 954 void ProfileSyncService::ReenableDatatype(syncer::ModelType type) { |
973 // Only reconfigure if the type actually had a data type or unready error. | 955 // Only reconfigure if the type actually had a data type or unready error. |
974 if (!failed_data_types_handler_.ResetDataTypeErrorFor(type) && | 956 if (!failed_data_types_handler_.ResetDataTypeErrorFor(type) && |
975 !failed_data_types_handler_.ResetUnreadyErrorFor(type)) { | 957 !failed_data_types_handler_.ResetUnreadyErrorFor(type)) { |
976 return; | 958 return; |
977 } | 959 } |
978 | 960 |
979 // If the type is no longer enabled, don't bother reconfiguring. | 961 // If the type is no longer enabled, don't bother reconfiguring. |
980 // TODO(zea): something else should encapsulate the notion of "whether a type | 962 // TODO(zea): something else should encapsulate the notion of "whether a type |
981 // should be enabled". | 963 // should be enabled". |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 | 1359 |
1378 // If sessions are encrypted, full history sync is not possible, and | 1360 // If sessions are encrypted, full history sync is not possible, and |
1379 // delete directives are unnecessary. | 1361 // delete directives are unnecessary. |
1380 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && | 1362 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && |
1381 encrypted_types_.Has(syncer::SESSIONS)) { | 1363 encrypted_types_.Has(syncer::SESSIONS)) { |
1382 syncer::SyncError error( | 1364 syncer::SyncError error( |
1383 FROM_HERE, | 1365 FROM_HERE, |
1384 syncer::SyncError::DATATYPE_POLICY_ERROR, | 1366 syncer::SyncError::DATATYPE_POLICY_ERROR, |
1385 "Delete directives not supported with encryption.", | 1367 "Delete directives not supported with encryption.", |
1386 syncer::HISTORY_DELETE_DIRECTIVES); | 1368 syncer::HISTORY_DELETE_DIRECTIVES); |
1387 DisableDatatype(error); | 1369 FailedDataTypesHandler::TypeErrorMap error_map; |
| 1370 error_map[error.model_type()] = error; |
| 1371 failed_data_types_handler_.UpdateFailedDataTypes(error_map); |
| 1372 ReconfigureDatatypeManager(); |
1388 } | 1373 } |
1389 } | 1374 } |
1390 | 1375 |
1391 void ProfileSyncService::OnEncryptionComplete() { | 1376 void ProfileSyncService::OnEncryptionComplete() { |
1392 DVLOG(1) << "Encryption complete"; | 1377 DVLOG(1) << "Encryption complete"; |
1393 if (encryption_pending_ && encrypt_everything_) { | 1378 if (encryption_pending_ && encrypt_everything_) { |
1394 encryption_pending_ = false; | 1379 encryption_pending_ = false; |
1395 // This is to nudge the integration tests when encryption is | 1380 // This is to nudge the integration tests when encryption is |
1396 // finished. | 1381 // finished. |
1397 NotifyObservers(); | 1382 NotifyObservers(); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1785 sync_prefs_.SetKeepEverythingSynced(sync_everything); | 1770 sync_prefs_.SetKeepEverythingSynced(sync_everything); |
1786 | 1771 |
1787 failed_data_types_handler_.Reset(); | 1772 failed_data_types_handler_.Reset(); |
1788 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && | 1773 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && |
1789 encrypted_types_.Has(syncer::SESSIONS)) { | 1774 encrypted_types_.Has(syncer::SESSIONS)) { |
1790 syncer::SyncError error( | 1775 syncer::SyncError error( |
1791 FROM_HERE, | 1776 FROM_HERE, |
1792 syncer::SyncError::DATATYPE_POLICY_ERROR, | 1777 syncer::SyncError::DATATYPE_POLICY_ERROR, |
1793 "Delete directives not supported with encryption.", | 1778 "Delete directives not supported with encryption.", |
1794 syncer::HISTORY_DELETE_DIRECTIVES); | 1779 syncer::HISTORY_DELETE_DIRECTIVES); |
1795 DisableDatatype(error); | 1780 FailedDataTypesHandler::TypeErrorMap error_map; |
| 1781 error_map[error.model_type()] = error; |
| 1782 failed_data_types_handler_.UpdateFailedDataTypes(error_map); |
1796 } | 1783 } |
1797 ChangePreferredDataTypes(chosen_types); | 1784 ChangePreferredDataTypes(chosen_types); |
1798 AcknowledgeSyncedTypes(); | 1785 AcknowledgeSyncedTypes(); |
1799 NotifyObservers(); | 1786 NotifyObservers(); |
1800 } | 1787 } |
1801 | 1788 |
1802 void ProfileSyncService::ChangePreferredDataTypes( | 1789 void ProfileSyncService::ChangePreferredDataTypes( |
1803 syncer::ModelTypeSet preferred_types) { | 1790 syncer::ModelTypeSet preferred_types) { |
1804 | 1791 |
1805 DVLOG(1) << "ChangePreferredDataTypes invoked"; | 1792 DVLOG(1) << "ChangePreferredDataTypes invoked"; |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2660 browser_sync::SyncedDeviceTracker* device_tracker = | 2647 browser_sync::SyncedDeviceTracker* device_tracker = |
2661 backend_->GetSyncedDeviceTracker(); | 2648 backend_->GetSyncedDeviceTracker(); |
2662 if (device_tracker) | 2649 if (device_tracker) |
2663 device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_); | 2650 device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_); |
2664 } | 2651 } |
2665 } | 2652 } |
2666 | 2653 |
2667 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { | 2654 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { |
2668 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime(); | 2655 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime(); |
2669 } | 2656 } |
OLD | NEW |