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

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: 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 delete_sync_database ? 950 delete_sync_database ?
951 browser_sync::SyncBackendHost::DISABLE_AND_CLAIM_THREAD : 951 browser_sync::SyncBackendHost::DISABLE_AND_CLAIM_THREAD :
952 browser_sync::SyncBackendHost::STOP_AND_CLAIM_THREAD)); 952 browser_sync::SyncBackendHost::STOP_AND_CLAIM_THREAD));
953 } 953 }
954 954
955 // TODO(zea): Move this logic into the DataTypeController/DataTypeManager. 955 // TODO(zea): Move this logic into the DataTypeController/DataTypeManager.
956 void ProfileSyncService::DisableDatatype( 956 void ProfileSyncService::DisableDatatype(
957 syncer::ModelType type, 957 syncer::ModelType type,
958 const tracked_objects::Location& from_here, 958 const tracked_objects::Location& from_here,
959 std::string message) { 959 std::string message) {
960 DisableDatatype(type, syncer::SyncError::DATATYPE_ERROR, from_here, message);
961 }
962
963 void ProfileSyncService::DisableDatatype(
964 syncer::ModelType type,
965 syncer::SyncError::ErrorType error_type,
966 const tracked_objects::Location& from_here,
967 std::string message) {
968 DCHECK(error_type == syncer::SyncError::DATATYPE_ERROR ||
969 error_type == syncer::SyncError::DATATYPE_POLICY_ERROR);
970
960 // First deactivate the type so that no further server changes are 971 // First deactivate the type so that no further server changes are
961 // passed onto the change processor. 972 // passed onto the change processor.
962 DeactivateDataType(type); 973 DeactivateDataType(type);
963 974
964 syncer::SyncError error(from_here, 975 syncer::SyncError error(from_here, error_type, message, type);
965 syncer::SyncError::DATATYPE_ERROR,
966 message,
967 type);
968 976
969 std::map<syncer::ModelType, syncer::SyncError> errors; 977 std::map<syncer::ModelType, syncer::SyncError> errors;
970 errors[type] = error; 978 errors[type] = error;
971 979
972 // Update this before posting a task. So if a configure happens before 980 // Update this before posting a task. So if a configure happens before
973 // the task that we are going to post, this type would still be disabled. 981 // the task that we are going to post, this type would still be disabled.
974 failed_data_types_handler_.UpdateFailedDataTypes(errors); 982 failed_data_types_handler_.UpdateFailedDataTypes(errors);
975 983
976 base::MessageLoop::current()->PostTask(FROM_HERE, 984 base::MessageLoop::current()->PostTask(FROM_HERE,
977 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager, 985 base::Bind(&ProfileSyncService::ReconfigureDatatypeManager,
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 << syncer::ModelTypeSetToString(encrypted_types_) 1373 << syncer::ModelTypeSetToString(encrypted_types_)
1366 << " (encrypt everything is set to " 1374 << " (encrypt everything is set to "
1367 << (encrypt_everything_ ? "true" : "false") << ")"; 1375 << (encrypt_everything_ ? "true" : "false") << ")";
1368 DCHECK(encrypted_types_.Has(syncer::PASSWORDS)); 1376 DCHECK(encrypted_types_.Has(syncer::PASSWORDS));
1369 1377
1370 // If sessions are encrypted, full history sync is not possible, and 1378 // If sessions are encrypted, full history sync is not possible, and
1371 // delete directives are unnecessary. 1379 // delete directives are unnecessary.
1372 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && 1380 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) &&
1373 encrypted_types_.Has(syncer::SESSIONS)) { 1381 encrypted_types_.Has(syncer::SESSIONS)) {
1374 DisableDatatype(syncer::HISTORY_DELETE_DIRECTIVES, 1382 DisableDatatype(syncer::HISTORY_DELETE_DIRECTIVES,
1383 syncer::SyncError::DATATYPE_POLICY_ERROR,
1375 FROM_HERE, 1384 FROM_HERE,
1376 "Delete directives not supported with encryption."); 1385 "Delete directives not supported with encryption.");
1377 } 1386 }
1378 } 1387 }
1379 1388
1380 void ProfileSyncService::OnEncryptionComplete() { 1389 void ProfileSyncService::OnEncryptionComplete() {
1381 DVLOG(1) << "Encryption complete"; 1390 DVLOG(1) << "Encryption complete";
1382 if (encryption_pending_ && encrypt_everything_) { 1391 if (encryption_pending_ && encrypt_everything_) {
1383 encryption_pending_ = false; 1392 encryption_pending_ = false;
1384 // This is to nudge the integration tests when encryption is 1393 // This is to nudge the integration tests when encryption is
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1773 return; 1782 return;
1774 } 1783 }
1775 1784
1776 UpdateSelectedTypesHistogram(sync_everything, chosen_types); 1785 UpdateSelectedTypesHistogram(sync_everything, chosen_types);
1777 sync_prefs_.SetKeepEverythingSynced(sync_everything); 1786 sync_prefs_.SetKeepEverythingSynced(sync_everything);
1778 1787
1779 failed_data_types_handler_.Reset(); 1788 failed_data_types_handler_.Reset();
1780 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) && 1789 if (GetActiveDataTypes().Has(syncer::HISTORY_DELETE_DIRECTIVES) &&
1781 encrypted_types_.Has(syncer::SESSIONS)) { 1790 encrypted_types_.Has(syncer::SESSIONS)) {
1782 DisableDatatype(syncer::HISTORY_DELETE_DIRECTIVES, 1791 DisableDatatype(syncer::HISTORY_DELETE_DIRECTIVES,
1792 syncer::SyncError::DATATYPE_POLICY_ERROR,
1783 FROM_HERE, 1793 FROM_HERE,
1784 "Delete directives not supported with encryption."); 1794 "Delete directives not supported with encryption.");
1785 } 1795 }
1786 ChangePreferredDataTypes(chosen_types); 1796 ChangePreferredDataTypes(chosen_types);
1787 AcknowledgeSyncedTypes(); 1797 AcknowledgeSyncedTypes();
1788 NotifyObservers(); 1798 NotifyObservers();
1789 } 1799 }
1790 1800
1791 void ProfileSyncService::ChangePreferredDataTypes( 1801 void ProfileSyncService::ChangePreferredDataTypes(
1792 syncer::ModelTypeSet preferred_types) { 1802 syncer::ModelTypeSet preferred_types) {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 scoped_ptr<base::DictionaryValue> type_status; 2029 scoped_ptr<base::DictionaryValue> type_status;
2020 for (ModelTypeSet::Iterator it = registered.First(); it.Good(); it.Inc()) { 2030 for (ModelTypeSet::Iterator it = registered.First(); it.Good(); it.Inc()) {
2021 ModelType type = it.Get(); 2031 ModelType type = it.Get();
2022 2032
2023 type_status.reset(new base::DictionaryValue()); 2033 type_status.reset(new base::DictionaryValue());
2024 type_status->SetString("name", ModelTypeToString(type)); 2034 type_status->SetString("name", ModelTypeToString(type));
2025 2035
2026 if (error_map.find(type) != error_map.end()) { 2036 if (error_map.find(type) != error_map.end()) {
2027 const syncer::SyncError &error = error_map.find(type)->second; 2037 const syncer::SyncError &error = error_map.find(type)->second;
2028 DCHECK(error.IsSet()); 2038 DCHECK(error.IsSet());
2029 std::string error_text = "Error: " + error.location().ToString() + 2039 switch (error.severity()) {
2030 ", " + error.message(); 2040 case logging::LOG_ERROR: {
2031 type_status->SetString("status", "error"); 2041 std::string error_text = "Error: " + error.location().ToString() +
2032 type_status->SetString("value", error_text); 2042 ", " + error.type_message_prefix() + error.message();
2043 type_status->SetString("status", "error");
2044 type_status->SetString("value", error_text);
2045 }
2046 break;
2047 case logging::LOG_INFO:
2048 type_status->SetString("status", "disabled");
2049 type_status->SetString("value", error.message());
2050 break;
2051 default:
2052 NOTREACHED() << "Unexpected error severity.";
2053 break;
2054 }
2033 } else if (syncer::IsProxyType(type) && passive_types.Has(type)) { 2055 } else if (syncer::IsProxyType(type) && passive_types.Has(type)) {
2034 // Show a proxy type in "ok" state unless it is disabled by user. 2056 // Show a proxy type in "ok" state unless it is disabled by user.
2035 DCHECK(!throttled_types.Has(type)); 2057 DCHECK(!throttled_types.Has(type));
2036 type_status->SetString("status", "ok"); 2058 type_status->SetString("status", "ok");
2037 type_status->SetString("value", "Passive"); 2059 type_status->SetString("value", "Passive");
2038 } else if (throttled_types.Has(type) && passive_types.Has(type)) { 2060 } else if (throttled_types.Has(type) && passive_types.Has(type)) {
2039 type_status->SetString("status", "warning"); 2061 type_status->SetString("status", "warning");
2040 type_status->SetString("value", "Passive, Throttled"); 2062 type_status->SetString("value", "Passive, Throttled");
2041 } else if (passive_types.Has(type)) { 2063 } else if (passive_types.Has(type)) {
2042 type_status->SetString("status", "warning"); 2064 type_status->SetString("status", "warning");
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
2590 } 2612 }
2591 return result; 2613 return result;
2592 } 2614 }
2593 2615
2594 void ProfileSyncService::StartStopBackupForTesting() { 2616 void ProfileSyncService::StartStopBackupForTesting() {
2595 if (backend_mode_ == BACKUP) 2617 if (backend_mode_ == BACKUP)
2596 ShutdownImpl(browser_sync::SyncBackendHost::STOP_AND_CLAIM_THREAD); 2618 ShutdownImpl(browser_sync::SyncBackendHost::STOP_AND_CLAIM_THREAD);
2597 else 2619 else
2598 backup_rollback_controller_.Start(base::TimeDelta()); 2620 backup_rollback_controller_.Start(base::TimeDelta());
2599 } 2621 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698