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 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 // Shut all data types down. | 950 // Shut all data types down. |
951 base::MessageLoop::current()->PostTask(FROM_HERE, | 951 base::MessageLoop::current()->PostTask(FROM_HERE, |
952 base::Bind(&ProfileSyncService::ShutdownImpl, | 952 base::Bind(&ProfileSyncService::ShutdownImpl, |
953 weak_factory_.GetWeakPtr(), | 953 weak_factory_.GetWeakPtr(), |
954 delete_sync_database ? | 954 delete_sync_database ? |
955 browser_sync::SyncBackendHost::DISABLE_AND_CLAIM_THREAD : | 955 browser_sync::SyncBackendHost::DISABLE_AND_CLAIM_THREAD : |
956 browser_sync::SyncBackendHost::STOP_AND_CLAIM_THREAD)); | 956 browser_sync::SyncBackendHost::STOP_AND_CLAIM_THREAD)); |
957 } | 957 } |
958 | 958 |
959 // TODO(zea): Move this logic into the DataTypeController/DataTypeManager. | 959 // TODO(zea): Move this logic into the DataTypeController/DataTypeManager. |
960 void ProfileSyncService::DisableBrokenDatatype( | 960 void ProfileSyncService::DisableDatatype( |
961 syncer::ModelType type, | 961 syncer::ModelType type, |
962 const tracked_objects::Location& from_here, | 962 const tracked_objects::Location& from_here, |
963 std::string message) { | 963 std::string message) { |
964 // First deactivate the type so that no further server changes are | 964 // First deactivate the type so that no further server changes are |
965 // passed onto the change processor. | 965 // passed onto the change processor. |
966 DeactivateDataType(type); | 966 DeactivateDataType(type); |
967 | 967 |
968 syncer::SyncError error(from_here, | 968 syncer::SyncError error(from_here, |
969 syncer::SyncError::DATATYPE_ERROR, | 969 syncer::SyncError::DATATYPE_ERROR, |
970 message, | 970 message, |
971 type); | 971 type); |
972 | 972 |
973 std::map<syncer::ModelType, syncer::SyncError> errors; | 973 std::map<syncer::ModelType, syncer::SyncError> errors; |
974 errors[type] = error; | 974 errors[type] = error; |
975 | 975 |
976 // Update this before posting a task. So if a configure happens before | 976 // Update this before posting a task. So if a configure happens before |
977 // the task that we are going to post, this type would still be disabled. | 977 // the task that we are going to post, this type would still be disabled. |
978 failed_data_types_handler_.UpdateFailedDataTypes(errors); | 978 failed_data_types_handler_.UpdateFailedDataTypes(errors); |
979 | 979 |
980 base::MessageLoop::current()->PostTask(FROM_HERE, | 980 base::MessageLoop::current()->PostTask(FROM_HERE, |
981 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, | 981 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, |
982 weak_factory_.GetWeakPtr())); | 982 weak_factory_.GetWeakPtr())); |
983 } | 983 } |
984 | 984 |
| 985 void ProfileSyncService::ReenableDatatype(syncer::ModelType type) { |
| 986 // Only reconfigure if the type actually had a data type or unready error. |
| 987 if (!failed_data_types_handler_.ResetDataTypeErrorFor(type) && |
| 988 !failed_data_types_handler_.ResetUnreadyErrorFor(type)) { |
| 989 return; |
| 990 } |
| 991 |
| 992 // If the type is no longer enabled, don't bother reconfiguring. |
| 993 // TODO(zea): something else should encapsulate the notion of "whether a type |
| 994 // should be enabled". |
| 995 if (!syncer::CoreTypes().Has(type) && !GetPreferredDataTypes().Has(type)) |
| 996 return; |
| 997 |
| 998 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 999 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, |
| 1000 weak_factory_.GetWeakPtr())); |
| 1001 } |
| 1002 |
985 void ProfileSyncService::UpdateBackendInitUMA(bool success) { | 1003 void ProfileSyncService::UpdateBackendInitUMA(bool success) { |
986 if (backend_mode_ != SYNC) | 1004 if (backend_mode_ != SYNC) |
987 return; | 1005 return; |
988 | 1006 |
989 is_first_time_sync_configure_ = !HasSyncSetupCompleted(); | 1007 is_first_time_sync_configure_ = !HasSyncSetupCompleted(); |
990 | 1008 |
991 if (is_first_time_sync_configure_) { | 1009 if (is_first_time_sync_configure_) { |
992 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success); | 1010 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeFirstTimeSuccess", success); |
993 } else { | 1011 } else { |
994 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeRestoreSuccess", success); | 1012 UMA_HISTOGRAM_BOOLEAN("Sync.BackendInitializeRestoreSuccess", success); |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1350 DVLOG(1) << "Encrypted types changed to " | 1368 DVLOG(1) << "Encrypted types changed to " |
1351 << syncer::ModelTypeSetToString(encrypted_types_) | 1369 << syncer::ModelTypeSetToString(encrypted_types_) |
1352 << " (encrypt everything is set to " | 1370 << " (encrypt everything is set to " |
1353 << (encrypt_everything_ ? "true" : "false") << ")"; | 1371 << (encrypt_everything_ ? "true" : "false") << ")"; |
1354 DCHECK(encrypted_types_.Has(syncer::PASSWORDS)); | 1372 DCHECK(encrypted_types_.Has(syncer::PASSWORDS)); |
1355 | 1373 |
1356 // If sessions are encrypted, full history sync is not possible, and | 1374 // If sessions are encrypted, full history sync is not possible, and |
1357 // delete directives are unnecessary. | 1375 // delete directives are unnecessary. |
1358 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && | 1376 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && |
1359 encrypted_types_.Has(syncer::SESSIONS)) { | 1377 encrypted_types_.Has(syncer::SESSIONS)) { |
1360 DisableBrokenDatatype(syncer::HISTORY_DELETE_DIRECTIVES, | 1378 DisableDatatype(syncer::HISTORY_DELETE_DIRECTIVES, |
1361 FROM_HERE, | 1379 FROM_HERE, |
1362 "Delete directives not supported with encryption."); | 1380 "Delete directives not supported with encryption."); |
1363 } | 1381 } |
1364 } | 1382 } |
1365 | 1383 |
1366 void ProfileSyncService::OnEncryptionComplete() { | 1384 void ProfileSyncService::OnEncryptionComplete() { |
1367 DVLOG(1) << "Encryption complete"; | 1385 DVLOG(1) << "Encryption complete"; |
1368 if (encryption_pending_ && encrypt_everything_) { | 1386 if (encryption_pending_ && encrypt_everything_) { |
1369 encryption_pending_ = false; | 1387 encryption_pending_ = false; |
1370 // This is to nudge the integration tests when encryption is | 1388 // This is to nudge the integration tests when encryption is |
1371 // finished. | 1389 // finished. |
1372 NotifyObservers(); | 1390 NotifyObservers(); |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 NOTREACHED(); | 1774 NOTREACHED(); |
1757 return; | 1775 return; |
1758 } | 1776 } |
1759 | 1777 |
1760 UpdateSelectedTypesHistogram(sync_everything, chosen_types); | 1778 UpdateSelectedTypesHistogram(sync_everything, chosen_types); |
1761 sync_prefs_.SetKeepEverythingSynced(sync_everything); | 1779 sync_prefs_.SetKeepEverythingSynced(sync_everything); |
1762 | 1780 |
1763 failed_data_types_handler_.Reset(); | 1781 failed_data_types_handler_.Reset(); |
1764 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && | 1782 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && |
1765 encrypted_types_.Has(syncer::SESSIONS)) { | 1783 encrypted_types_.Has(syncer::SESSIONS)) { |
1766 DisableBrokenDatatype(syncer::HISTORY_DELETE_DIRECTIVES, | 1784 DisableDatatype(syncer::HISTORY_DELETE_DIRECTIVES, |
1767 FROM_HERE, | 1785 FROM_HERE, |
1768 "Delete directives not supported with encryption."); | 1786 "Delete directives not supported with encryption."); |
1769 } | 1787 } |
1770 ChangePreferredDataTypes(chosen_types); | 1788 ChangePreferredDataTypes(chosen_types); |
1771 AcknowledgeSyncedTypes(); | 1789 AcknowledgeSyncedTypes(); |
1772 NotifyObservers(); | 1790 NotifyObservers(); |
1773 } | 1791 } |
1774 | 1792 |
1775 void ProfileSyncService::ChangePreferredDataTypes( | 1793 void ProfileSyncService::ChangePreferredDataTypes( |
1776 syncer::ModelTypeSet preferred_types) { | 1794 syncer::ModelTypeSet preferred_types) { |
1777 | 1795 |
1778 DVLOG(1) << "ChangePreferredDataTypes invoked"; | 1796 DVLOG(1) << "ChangePreferredDataTypes invoked"; |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2533 if (first_sync_time.is_null()) | 2551 if (first_sync_time.is_null()) |
2534 return; | 2552 return; |
2535 | 2553 |
2536 clear_browsing_data_.Run(profile_, first_sync_time, base::Time::Now()); | 2554 clear_browsing_data_.Run(profile_, first_sync_time, base::Time::Now()); |
2537 } | 2555 } |
2538 | 2556 |
2539 void ProfileSyncService::SetClearingBrowseringDataForTesting( | 2557 void ProfileSyncService::SetClearingBrowseringDataForTesting( |
2540 base::Callback<void(Profile*, base::Time, base::Time)> c) { | 2558 base::Callback<void(Profile*, base::Time, base::Time)> c) { |
2541 clear_browsing_data_ = c; | 2559 clear_browsing_data_ = c; |
2542 } | 2560 } |
OLD | NEW |