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 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
941 | 941 |
942 // Shut all data types down. | 942 // Shut all data types down. |
943 base::MessageLoop::current()->PostTask(FROM_HERE, | 943 base::MessageLoop::current()->PostTask(FROM_HERE, |
944 base::Bind(&ProfileSyncService::ShutdownImpl, | 944 base::Bind(&ProfileSyncService::ShutdownImpl, |
945 weak_factory_.GetWeakPtr(), | 945 weak_factory_.GetWeakPtr(), |
946 delete_sync_database ? | 946 delete_sync_database ? |
947 browser_sync::SyncBackendHost::DISABLE_AND_CLAIM_THREAD : | 947 browser_sync::SyncBackendHost::DISABLE_AND_CLAIM_THREAD : |
948 browser_sync::SyncBackendHost::STOP_AND_CLAIM_THREAD)); | 948 browser_sync::SyncBackendHost::STOP_AND_CLAIM_THREAD)); |
949 } | 949 } |
950 | 950 |
951 // TODO(zea): Move this logic into the DataTypeController/DataTypeManager. | |
952 void ProfileSyncService::DisableDatatype(const syncer::SyncError& error) { | |
953 // First deactivate the type so that no further server changes are | |
954 // passed onto the change processor. | |
955 DeactivateDataType(error.model_type()); | |
956 | |
957 std::map<syncer::ModelType, syncer::SyncError> errors; | |
958 errors[error.model_type()] = error; | |
959 | |
960 // Update this before posting a task. So if a configure happens before | |
961 // the task that we are going to post, this type would still be disabled. | |
962 failed_data_types_handler_.UpdateFailedDataTypes(errors); | |
963 | |
964 base::MessageLoop::current()->PostTask(FROM_HERE, | |
965 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, | |
966 weak_factory_.GetWeakPtr())); | |
967 } | |
968 | |
969 void ProfileSyncService::ReenableDatatype(syncer::ModelType type) { | 951 void ProfileSyncService::ReenableDatatype(syncer::ModelType type) { |
970 // Only reconfigure if the type actually had a data type or unready error. | 952 // Only reconfigure if the type actually had a data type or unready error. |
971 if (!failed_data_types_handler_.ResetDataTypeErrorFor(type) && | 953 if (!failed_data_types_handler_.ResetDataTypeErrorFor(type) && |
972 !failed_data_types_handler_.ResetUnreadyErrorFor(type)) { | 954 !failed_data_types_handler_.ResetUnreadyErrorFor(type)) { |
973 return; | 955 return; |
974 } | 956 } |
975 | 957 |
976 // If the type is no longer enabled, don't bother reconfiguring. | 958 // If the type is no longer enabled, don't bother reconfiguring. |
977 // TODO(zea): something else should encapsulate the notion of "whether a type | 959 // TODO(zea): something else should encapsulate the notion of "whether a type |
978 // should be enabled". | 960 // should be enabled". |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1374 | 1356 |
1375 // If sessions are encrypted, full history sync is not possible, and | 1357 // If sessions are encrypted, full history sync is not possible, and |
1376 // delete directives are unnecessary. | 1358 // delete directives are unnecessary. |
1377 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && | 1359 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && |
1378 encrypted_types_.Has(syncer::SESSIONS)) { | 1360 encrypted_types_.Has(syncer::SESSIONS)) { |
1379 syncer::SyncError error( | 1361 syncer::SyncError error( |
1380 FROM_HERE, | 1362 FROM_HERE, |
1381 syncer::SyncError::DATATYPE_POLICY_ERROR, | 1363 syncer::SyncError::DATATYPE_POLICY_ERROR, |
1382 "Delete directives not supported with encryption.", | 1364 "Delete directives not supported with encryption.", |
1383 syncer::HISTORY_DELETE_DIRECTIVES); | 1365 syncer::HISTORY_DELETE_DIRECTIVES); |
1384 DisableDatatype(error); | 1366 FailedDataTypesHandler::TypeErrorMap error_map; |
1367 error_map[error.model_type()] = error; | |
1368 failed_data_types_handler_.UpdateFailedDataTypes(error_map); | |
haitaol1
2014/08/07 00:49:48
Is reconfiguration needed?
Nicolas Zea
2014/08/07 18:14:54
Yep, good catch.
| |
1385 } | 1369 } |
1386 } | 1370 } |
1387 | 1371 |
1388 void ProfileSyncService::OnEncryptionComplete() { | 1372 void ProfileSyncService::OnEncryptionComplete() { |
1389 DVLOG(1) << "Encryption complete"; | 1373 DVLOG(1) << "Encryption complete"; |
1390 if (encryption_pending_ && encrypt_everything_) { | 1374 if (encryption_pending_ && encrypt_everything_) { |
1391 encryption_pending_ = false; | 1375 encryption_pending_ = false; |
1392 // This is to nudge the integration tests when encryption is | 1376 // This is to nudge the integration tests when encryption is |
1393 // finished. | 1377 // finished. |
1394 NotifyObservers(); | 1378 NotifyObservers(); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1782 sync_prefs_.SetKeepEverythingSynced(sync_everything); | 1766 sync_prefs_.SetKeepEverythingSynced(sync_everything); |
1783 | 1767 |
1784 failed_data_types_handler_.Reset(); | 1768 failed_data_types_handler_.Reset(); |
1785 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && | 1769 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && |
1786 encrypted_types_.Has(syncer::SESSIONS)) { | 1770 encrypted_types_.Has(syncer::SESSIONS)) { |
1787 syncer::SyncError error( | 1771 syncer::SyncError error( |
1788 FROM_HERE, | 1772 FROM_HERE, |
1789 syncer::SyncError::DATATYPE_POLICY_ERROR, | 1773 syncer::SyncError::DATATYPE_POLICY_ERROR, |
1790 "Delete directives not supported with encryption.", | 1774 "Delete directives not supported with encryption.", |
1791 syncer::HISTORY_DELETE_DIRECTIVES); | 1775 syncer::HISTORY_DELETE_DIRECTIVES); |
1792 DisableDatatype(error); | 1776 FailedDataTypesHandler::TypeErrorMap error_map; |
1777 error_map[error.model_type()] = error; | |
1778 failed_data_types_handler_.UpdateFailedDataTypes(error_map); | |
1793 } | 1779 } |
1794 ChangePreferredDataTypes(chosen_types); | 1780 ChangePreferredDataTypes(chosen_types); |
1795 AcknowledgeSyncedTypes(); | 1781 AcknowledgeSyncedTypes(); |
1796 NotifyObservers(); | 1782 NotifyObservers(); |
1797 } | 1783 } |
1798 | 1784 |
1799 void ProfileSyncService::ChangePreferredDataTypes( | 1785 void ProfileSyncService::ChangePreferredDataTypes( |
1800 syncer::ModelTypeSet preferred_types) { | 1786 syncer::ModelTypeSet preferred_types) { |
1801 | 1787 |
1802 DVLOG(1) << "ChangePreferredDataTypes invoked"; | 1788 DVLOG(1) << "ChangePreferredDataTypes invoked"; |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2657 browser_sync::SyncedDeviceTracker* device_tracker = | 2643 browser_sync::SyncedDeviceTracker* device_tracker = |
2658 backend_->GetSyncedDeviceTracker(); | 2644 backend_->GetSyncedDeviceTracker(); |
2659 if (device_tracker) | 2645 if (device_tracker) |
2660 device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_); | 2646 device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_); |
2661 } | 2647 } |
2662 } | 2648 } |
2663 | 2649 |
2664 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { | 2650 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { |
2665 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime(); | 2651 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime(); |
2666 } | 2652 } |
OLD | NEW |