Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 388003002: Sync: Display non-severe errors on about:sync in gray color rather than red. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed failing unit test, added extra test case, addressed CR feedback. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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::DisableDatatype( 960 void ProfileSyncService::DisableDatatype(const syncer::SyncError& error) {
961 syncer::ModelType type,
962 const tracked_objects::Location& from_here,
963 std::string message) {
964 // First deactivate the type so that no further server changes are 961 // First deactivate the type so that no further server changes are
965 // passed onto the change processor. 962 // passed onto the change processor.
966 DeactivateDataType(type); 963 DeactivateDataType(error.model_type());
967
968 syncer::SyncError error(from_here,
969 syncer::SyncError::DATATYPE_ERROR,
970 message,
971 type);
972 964
973 std::map<syncer::ModelType, syncer::SyncError> errors; 965 std::map<syncer::ModelType, syncer::SyncError> errors;
974 errors[type] = error; 966 errors[error.model_type()] = error;
975 967
976 // Update this before posting a task. So if a configure happens before 968 // 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. 969 // the task that we are going to post, this type would still be disabled.
978 failed_data_types_handler_.UpdateFailedDataTypes(errors); 970 failed_data_types_handler_.UpdateFailedDataTypes(errors);
979 971
980 base::MessageLoop::current()->PostTask(FROM_HERE, 972 base::MessageLoop::current()->PostTask(FROM_HERE,
981 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, 973 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager,
982 weak_factory_.GetWeakPtr())); 974 weak_factory_.GetWeakPtr()));
983 } 975 }
984 976
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 DVLOG(1) << "Encrypted types changed to " 1367 DVLOG(1) << "Encrypted types changed to "
1376 << syncer::ModelTypeSetToString(encrypted_types_) 1368 << syncer::ModelTypeSetToString(encrypted_types_)
1377 << " (encrypt everything is set to " 1369 << " (encrypt everything is set to "
1378 << (encrypt_everything_ ? "true" : "false") << ")"; 1370 << (encrypt_everything_ ? "true" : "false") << ")";
1379 DCHECK(encrypted_types_.Has(syncer::PASSWORDS)); 1371 DCHECK(encrypted_types_.Has(syncer::PASSWORDS));
1380 1372
1381 // If sessions are encrypted, full history sync is not possible, and 1373 // If sessions are encrypted, full history sync is not possible, and
1382 // delete directives are unnecessary. 1374 // delete directives are unnecessary.
1383 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && 1375 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) &&
1384 encrypted_types_.Has(syncer::SESSIONS)) { 1376 encrypted_types_.Has(syncer::SESSIONS)) {
1385 DisableDatatype(syncer::HISTORY_DELETE_DIRECTIVES, 1377 syncer::SyncError error(
1386 FROM_HERE, 1378 FROM_HERE,
1387 "Delete directives not supported with encryption."); 1379 syncer::SyncError::DATATYPE_POLICY_ERROR,
1380 "Delete directives not supported with encryption.",
1381 syncer::HISTORY_DELETE_DIRECTIVES);
1382 DisableDatatype(error);
1388 } 1383 }
1389 } 1384 }
1390 1385
1391 void ProfileSyncService::OnEncryptionComplete() { 1386 void ProfileSyncService::OnEncryptionComplete() {
1392 DVLOG(1) << "Encryption complete"; 1387 DVLOG(1) << "Encryption complete";
1393 if (encryption_pending_ && encrypt_everything_) { 1388 if (encryption_pending_ && encrypt_everything_) {
1394 encryption_pending_ = false; 1389 encryption_pending_ = false;
1395 // This is to nudge the integration tests when encryption is 1390 // This is to nudge the integration tests when encryption is
1396 // finished. 1391 // finished.
1397 NotifyObservers(); 1392 NotifyObservers();
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 NOTREACHED(); 1778 NOTREACHED();
1784 return; 1779 return;
1785 } 1780 }
1786 1781
1787 UpdateSelectedTypesHistogram(sync_everything, chosen_types); 1782 UpdateSelectedTypesHistogram(sync_everything, chosen_types);
1788 sync_prefs_.SetKeepEverythingSynced(sync_everything); 1783 sync_prefs_.SetKeepEverythingSynced(sync_everything);
1789 1784
1790 failed_data_types_handler_.Reset(); 1785 failed_data_types_handler_.Reset();
1791 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && 1786 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) &&
1792 encrypted_types_.Has(syncer::SESSIONS)) { 1787 encrypted_types_.Has(syncer::SESSIONS)) {
1793 DisableDatatype(syncer::HISTORY_DELETE_DIRECTIVES, 1788 syncer::SyncError error(
1794 FROM_HERE, 1789 FROM_HERE,
1795 "Delete directives not supported with encryption."); 1790 syncer::SyncError::DATATYPE_POLICY_ERROR,
1791 "Delete directives not supported with encryption.",
1792 syncer::HISTORY_DELETE_DIRECTIVES);
1793 DisableDatatype(error);
1796 } 1794 }
1797 ChangePreferredDataTypes(chosen_types); 1795 ChangePreferredDataTypes(chosen_types);
1798 AcknowledgeSyncedTypes(); 1796 AcknowledgeSyncedTypes();
1799 NotifyObservers(); 1797 NotifyObservers();
1800 } 1798 }
1801 1799
1802 void ProfileSyncService::ChangePreferredDataTypes( 1800 void ProfileSyncService::ChangePreferredDataTypes(
1803 syncer::ModelTypeSet preferred_types) { 1801 syncer::ModelTypeSet preferred_types) {
1804 1802
1805 DVLOG(1) << "ChangePreferredDataTypes invoked"; 1803 DVLOG(1) << "ChangePreferredDataTypes invoked";
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 scoped_ptr<base::DictionaryValue> type_status; 2028 scoped_ptr<base::DictionaryValue> type_status;
2031 for (ModelTypeSet::Iterator it = registered.First(); it.Good(); it.Inc()) { 2029 for (ModelTypeSet::Iterator it = registered.First(); it.Good(); it.Inc()) {
2032 ModelType type = it.Get(); 2030 ModelType type = it.Get();
2033 2031
2034 type_status.reset(new base::DictionaryValue()); 2032 type_status.reset(new base::DictionaryValue());
2035 type_status->SetString("name", ModelTypeToString(type)); 2033 type_status->SetString("name", ModelTypeToString(type));
2036 2034
2037 if (error_map.find(type) != error_map.end()) { 2035 if (error_map.find(type) != error_map.end()) {
2038 const syncer::SyncError &error = error_map.find(type)->second; 2036 const syncer::SyncError &error = error_map.find(type)->second;
2039 DCHECK(error.IsSet()); 2037 DCHECK(error.IsSet());
2040 std::string error_text = "Error: " + error.location().ToString() + 2038 switch (error.GetSeverity()) {
2041 ", " + error.message(); 2039 case syncer::SyncError::SYNC_ERROR_SEVERITY_ERROR: {
2042 type_status->SetString("status", "error"); 2040 std::string error_text = "Error: " + error.location().ToString() +
2043 type_status->SetString("value", error_text); 2041 ", " + error.GetMessagePrefix() + error.message();
2042 type_status->SetString("status", "error");
2043 type_status->SetString("value", error_text);
2044 }
2045 break;
2046 case syncer::SyncError::SYNC_ERROR_SEVERITY_INFO:
2047 type_status->SetString("status", "disabled");
2048 type_status->SetString("value", error.message());
2049 break;
2050 default:
2051 NOTREACHED() << "Unexpected error severity.";
2052 break;
2053 }
2044 } else if (syncer::IsProxyType(type) && passive_types.Has(type)) { 2054 } else if (syncer::IsProxyType(type) && passive_types.Has(type)) {
2045 // Show a proxy type in "ok" state unless it is disabled by user. 2055 // Show a proxy type in "ok" state unless it is disabled by user.
2046 DCHECK(!throttled_types.Has(type)); 2056 DCHECK(!throttled_types.Has(type));
2047 type_status->SetString("status", "ok"); 2057 type_status->SetString("status", "ok");
2048 type_status->SetString("value", "Passive"); 2058 type_status->SetString("value", "Passive");
2049 } else if (throttled_types.Has(type) && passive_types.Has(type)) { 2059 } else if (throttled_types.Has(type) && passive_types.Has(type)) {
2050 type_status->SetString("status", "warning"); 2060 type_status->SetString("status", "warning");
2051 type_status->SetString("value", "Passive, Throttled"); 2061 type_status->SetString("value", "Passive, Throttled");
2052 } else if (passive_types.Has(type)) { 2062 } else if (passive_types.Has(type)) {
2053 type_status->SetString("status", "warning"); 2063 type_status->SetString("status", "warning");
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
2648 browser_sync::SyncedDeviceTracker* device_tracker = 2658 browser_sync::SyncedDeviceTracker* device_tracker =
2649 backend_->GetSyncedDeviceTracker(); 2659 backend_->GetSyncedDeviceTracker();
2650 if (device_tracker) 2660 if (device_tracker)
2651 device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_); 2661 device_tracker->UpdateLocalDeviceBackupTime(*last_backup_time_);
2652 } 2662 }
2653 } 2663 }
2654 2664
2655 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const { 2665 base::Time ProfileSyncService::GetDeviceBackupTimeForTesting() const {
2656 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime(); 2666 return backend_->GetSyncedDeviceTracker()->GetLocalDeviceBackupTime();
2657 } 2667 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.h ('k') | chrome/browser/sync/profile_sync_service_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698