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

Side by Side Diff: components/browser_sync/profile_sync_service.cc

Issue 2834453006: [Sync] Update Type Info section of sync-internals. (Closed)
Patch Set: Reworked some of the variables in GetTypeStatusMap(). Created 3 years, 8 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 "components/browser_sync/profile_sync_service.h" 5 #include "components/browser_sync/profile_sync_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 } 1776 }
1777 1777
1778 std::unique_ptr<base::Value> ProfileSyncService::GetTypeStatusMap() { 1778 std::unique_ptr<base::Value> ProfileSyncService::GetTypeStatusMap() {
1779 DCHECK(thread_checker_.CalledOnValidThread()); 1779 DCHECK(thread_checker_.CalledOnValidThread());
1780 auto result = base::MakeUnique<base::ListValue>(); 1780 auto result = base::MakeUnique<base::ListValue>();
1781 1781
1782 if (!engine_ || !engine_initialized_) { 1782 if (!engine_ || !engine_initialized_) {
1783 return std::move(result); 1783 return std::move(result);
1784 } 1784 }
1785 1785
1786 DataTypeStatusTable::TypeErrorMap error_map = 1786 SyncEngine::Status detailed_status = engine_->GetDetailedStatus();
1787 const ModelTypeSet& throttled_types(detailed_status.throttled_types);
1788 const ModelTypeSet& backed_off_types(detailed_status.backed_off_types);
1789
1790 std::unique_ptr<base::DictionaryValue> type_status_header(
1791 new base::DictionaryValue());
1792 type_status_header->SetString("status", "header");
1793 type_status_header->SetString("name", "Model Type");
1794 type_status_header->SetString("num_entries", "Total Entries");
1795 type_status_header->SetString("num_live", "Live Entries");
1796 type_status_header->SetString("message", "Message");
1797 type_status_header->SetString("state", "State");
1798 type_status_header->SetString("group_type", "Group Type");
1799 result->Append(std::move(type_status_header));
1800
1801 const DataTypeStatusTable::TypeErrorMap error_map =
1787 data_type_status_table_.GetAllErrors(); 1802 data_type_status_table_.GetAllErrors();
1788 ModelTypeSet active_types;
1789 ModelTypeSet passive_types;
1790 ModelSafeRoutingInfo routing_info; 1803 ModelSafeRoutingInfo routing_info;
1791 engine_->GetModelSafeRoutingInfo(&routing_info); 1804 engine_->GetModelSafeRoutingInfo(&routing_info);
1792 for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin(); 1805 const ModelTypeSet registered = GetRegisteredDataTypes();
1793 it != routing_info.end(); ++it) {
1794 if (it->second == syncer::GROUP_PASSIVE) {
1795 passive_types.Put(it->first);
1796 } else {
1797 active_types.Put(it->first);
1798 }
1799 }
1800
1801 SyncEngine::Status detailed_status = engine_->GetDetailedStatus();
1802 ModelTypeSet& throttled_types(detailed_status.throttled_types);
1803 ModelTypeSet& backed_off_types(detailed_status.backed_off_types);
1804 ModelTypeSet registered = GetRegisteredDataTypes();
1805 std::unique_ptr<base::DictionaryValue> type_status_header(
1806 new base::DictionaryValue());
1807
1808 type_status_header->SetString("name", "Model Type");
1809 type_status_header->SetString("status", "header");
1810 type_status_header->SetString("value", "Group Type");
1811 type_status_header->SetString("num_entries", "Total Entries");
1812 type_status_header->SetString("num_live", "Live Entries");
1813 result->Append(std::move(type_status_header));
1814
1815 std::unique_ptr<base::DictionaryValue> type_status;
1816 for (ModelTypeSet::Iterator it = registered.First(); it.Good(); it.Inc()) { 1806 for (ModelTypeSet::Iterator it = registered.First(); it.Good(); it.Inc()) {
1817 ModelType type = it.Get(); 1807 ModelType type = it.Get();
1818 1808
1819 type_status = base::MakeUnique<base::DictionaryValue>(); 1809 auto type_status = base::MakeUnique<base::DictionaryValue>();
1820 type_status->SetString("name", ModelTypeToString(type)); 1810 type_status->SetString("name", ModelTypeToString(type));
1811 type_status->SetString("group_type",
1812 ModelSafeGroupToString(routing_info[type]));
1821 1813
1822 if (error_map.find(type) != error_map.end()) { 1814 if (error_map.find(type) != error_map.end()) {
1823 const syncer::SyncError& error = error_map.find(type)->second; 1815 const syncer::SyncError& error = error_map.find(type)->second;
1824 DCHECK(error.IsSet()); 1816 DCHECK(error.IsSet());
1825 switch (error.GetSeverity()) { 1817 switch (error.GetSeverity()) {
1826 case syncer::SyncError::SYNC_ERROR_SEVERITY_ERROR: 1818 case syncer::SyncError::SYNC_ERROR_SEVERITY_ERROR:
1827 type_status->SetString("status", "error"); 1819 type_status->SetString("status", "error");
1828 type_status->SetString( 1820 type_status->SetString(
1829 "value", "Error: " + error.location().ToString() + ", " + 1821 "message", "Error: " + error.location().ToString() + ", " +
1830 error.GetMessagePrefix() + error.message()); 1822 error.GetMessagePrefix() + error.message());
1831 break; 1823 break;
1832 case syncer::SyncError::SYNC_ERROR_SEVERITY_INFO: 1824 case syncer::SyncError::SYNC_ERROR_SEVERITY_INFO:
1833 type_status->SetString("status", "disabled"); 1825 type_status->SetString("status", "disabled");
1834 type_status->SetString("value", error.message()); 1826 type_status->SetString("message", error.message());
1835 break;
1836 default:
1837 NOTREACHED() << "Unexpected error severity.";
1838 break; 1827 break;
1839 } 1828 }
1840 } else if (syncer::IsProxyType(type) && passive_types.Has(type)) {
1841 // Show a proxy type in "ok" state unless it is disabled by user.
1842 DCHECK(!throttled_types.Has(type));
1843 type_status->SetString("status", "ok");
1844 type_status->SetString("value", "Passive");
1845 } else if (throttled_types.Has(type) && passive_types.Has(type)) {
1846 type_status->SetString("status", "warning");
1847 type_status->SetString("value", "Passive, Throttled");
1848 } else if (backed_off_types.Has(type) && passive_types.Has(type)) {
1849 type_status->SetString("status", "warning");
1850 type_status->SetString("value", "Passive, Backed off");
1851 } else if (passive_types.Has(type)) {
1852 type_status->SetString("status", "warning");
1853 type_status->SetString("value", "Passive");
1854 } else if (throttled_types.Has(type)) { 1829 } else if (throttled_types.Has(type)) {
1855 type_status->SetString("status", "warning"); 1830 type_status->SetString("status", "warning");
1856 type_status->SetString("value", "Throttled"); 1831 type_status->SetString("message", " Throttled");
1857 } else if (backed_off_types.Has(type)) { 1832 } else if (backed_off_types.Has(type)) {
1858 type_status->SetString("status", "warning"); 1833 type_status->SetString("status", "warning");
1859 type_status->SetString("value", "Backed off"); 1834 type_status->SetString("message", "Backed off");
1860 } else if (active_types.Has(type)) { 1835 } else if (routing_info.find(type) != routing_info.end()) {
1861 type_status->SetString("status", "ok"); 1836 type_status->SetString("status", "ok");
1862 type_status->SetString( 1837 type_status->SetString("message", "");
1863 "value", "Active: " + ModelSafeGroupToString(routing_info[type]));
1864 } else { 1838 } else {
1865 type_status->SetString("status", "warning"); 1839 type_status->SetString("status", "warning");
1866 type_status->SetString("value", "Disabled by User"); 1840 type_status->SetString("message", "Disabled by User");
1867 } 1841 }
1868 1842
1869 const auto& dtc_iter = data_type_controllers_.find(type); 1843 const auto& dtc_iter = data_type_controllers_.find(type);
1870 if (dtc_iter != data_type_controllers_.end()) { 1844 if (dtc_iter != data_type_controllers_.end()) {
1871 // OnDatatypeStatusCounterUpdated that posts back to the UI thread so that 1845 // OnDatatypeStatusCounterUpdated that posts back to the UI thread so that
1872 // real results can't get overwritten by the empty counters set at the end 1846 // real results can't get overwritten by the empty counters set at the end
1873 // of this method. 1847 // of this method.
1874 dtc_iter->second->GetStatusCounters(BindToCurrentThread( 1848 dtc_iter->second->GetStatusCounters(BindToCurrentThread(
1875 base::Bind(&ProfileSyncService::OnDatatypeStatusCounterUpdated, 1849 base::Bind(&ProfileSyncService::OnDatatypeStatusCounterUpdated,
1876 base::Unretained(this)))); 1850 base::Unretained(this))));
1851 type_status->SetString("state", DataTypeController::StateToString(
1852 dtc_iter->second->state()));
1877 } 1853 }
1878 1854
1879 result->Append(std::move(type_status)); 1855 result->Append(std::move(type_status));
1880 } 1856 }
1881 return std::move(result); 1857 return std::move(result);
1882 } 1858 }
1883 1859
1884 void ProfileSyncService::RequestAccessToken() { 1860 void ProfileSyncService::RequestAccessToken() {
1885 // Only one active request at a time. 1861 // Only one active request at a time.
1886 if (access_token_request_ != nullptr) 1862 if (access_token_request_ != nullptr)
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 return; 2426 return;
2451 2427
2452 DCHECK(startup_controller_->IsSetupInProgress()); 2428 DCHECK(startup_controller_->IsSetupInProgress());
2453 startup_controller_->SetSetupInProgress(false); 2429 startup_controller_->SetSetupInProgress(false);
2454 2430
2455 if (IsEngineInitialized()) 2431 if (IsEngineInitialized())
2456 ReconfigureDatatypeManager(); 2432 ReconfigureDatatypeManager();
2457 NotifyObservers(); 2433 NotifyObservers();
2458 } 2434 }
2459 } // namespace browser_sync 2435 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/sync_internals_browsertest.js ('k') | components/sync/driver/data_type_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698