diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-27 21:51:38 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-27 21:51:38 +0000 |
commit | f33386d952654acfad4f62029ece49f0e7ecb200 (patch) | |
tree | 393228082a077af4cc68401aaa69238b6ec2e4b9 | |
parent | 1deeb72e5ad02e79b984db51233db43749a6936d (diff) | |
download | chromium_src-f33386d952654acfad4f62029ece49f0e7ecb200.zip chromium_src-f33386d952654acfad4f62029ece49f0e7ecb200.tar.gz chromium_src-f33386d952654acfad4f62029ece49f0e7ecb200.tar.bz2 |
Display per-type status in about:sync
This change merges the per-datatype throttling status, per-datatype
unrecoverable error status and the routing info into a single table on
about:sync's about tab.
In the future, we may be able to expand on this to provide even more
detailed information, such as the current model association status.
BUG=134698
TEST=
Review URL: https://chromiumcodereview.appspot.com/10657033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144572 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/sync_internals/about.html | 37 | ||||
-rw-r--r-- | chrome/browser/sync/failed_datatypes_handler.cc | 38 | ||||
-rw-r--r-- | chrome/browser/sync/failed_datatypes_handler.h | 12 | ||||
-rw-r--r-- | chrome/browser/sync/profile_sync_service.cc | 75 | ||||
-rw-r--r-- | chrome/browser/sync/profile_sync_service.h | 26 | ||||
-rw-r--r-- | chrome/browser/sync/sync_ui_util.cc | 31 |
6 files changed, 127 insertions, 92 deletions
diff --git a/chrome/browser/resources/sync_internals/about.html b/chrome/browser/resources/sync_internals/about.html index 10b9c92..3afb2cf 100644 --- a/chrome/browser/resources/sync_internals/about.html +++ b/chrome/browser/resources/sync_internals/about.html @@ -29,10 +29,6 @@ table.aboutDetails tr:nth-child(odd) { background: #eff3ff; } -table#routingInfo tr:nth-child(odd) { - background: #ccffcc; -} - div#aboutInfo div.section > td#detail { width: 50%; } @@ -41,6 +37,18 @@ div#aboutInfo div.section > td#value { width: 50%; } +table#typeInfo tr.error { + background: #ffcccc; +} + +table#typeInfo tr.warning { + background: #ffffcc; +} + +table#typeInfo tr.ok { + background: #ccffcc; +} + @-webkit-keyframes highlight1 { 0% { background: #ffff00; } 100% { background: #ffffff; } @@ -76,11 +84,11 @@ table.aboutDetails tr[highlighted]:nth-child(odd) { </div> <div class="section"> - <h2>Routing Info</h2> - <table id="routingInfo"> - <tr jsselect="routing_info"> - <td jscontent="model_type"/> - <td jscontent="group"/> + <h2>Type Info</h2> + <table id="typeInfo"> + <tr jsselect="type_status" jsvalues="class:$this.status"> + <td jscontent="name"/> + <td jscontent="value"/> </tr> </table> </div> @@ -91,17 +99,6 @@ table.aboutDetails tr[highlighted]:nth-child(odd) { </p> </div> - <div class="section" jsdisplay="failed_data_types_detected"> - <p> - <span class="err" jscontent="failed_data_types"></span> - </p> - </div> - - <div class="section" jsdisplay="throttled_data_types"> - <h2>Throttled Types</h2> - <span jscontent="throttled_data_types"></span> - </div> - <div class="section" jsdisplay="actionable_error_detected"> <p jsdisplay="actionable_error_detected"> <h2 jsdisplay="actionable_error_detected">Actionable Error</h2> diff --git a/chrome/browser/sync/failed_datatypes_handler.cc b/chrome/browser/sync/failed_datatypes_handler.cc index 4785e71..8432757 100644 --- a/chrome/browser/sync/failed_datatypes_handler.cc +++ b/chrome/browser/sync/failed_datatypes_handler.cc @@ -16,9 +16,9 @@ FailedDatatypesHandler::~FailedDatatypesHandler() { } syncable::ModelTypeSet GetTypesFromErrorsList( - const std::list<csync::SyncError>& errors) { + const std::vector<csync::SyncError>& errors) { syncable::ModelTypeSet result; - for (std::list<csync::SyncError>::const_iterator it = errors.begin(); + for (std::vector<csync::SyncError>::const_iterator it = errors.begin(); it != errors.end(); ++it) { DCHECK(!result.Has(it->type())); result.Put(it->type()); @@ -56,36 +56,14 @@ void FailedDatatypesHandler::OnUserChoseDatatypes() { runtime_errors_.clear(); } -std::string GetErrorStringFromErrors( - const std::list<csync::SyncError>& errors) { - std::string message; - for (std::list<csync::SyncError>::const_iterator it = errors.begin(); - it != errors.end(); ++it) { - if (it != errors.begin()) { - message += ", "; - } - message += std::string(syncable::ModelTypeToString(it->type())) + " " + - it->location().ToString() + ": " + it->message(); - } - return message; - -} +std::vector<csync::SyncError> FailedDatatypesHandler::GetAllErrors() const { + std::vector<csync::SyncError> result; -std::string FailedDatatypesHandler::GetErrorString() const { - std::string message; - - if (!startup_errors_.empty()) { - message = "Sync configuration failed when starting "; - message += GetErrorStringFromErrors(startup_errors_); - message += ". "; - } - - if (!runtime_errors_.empty()) { - message += "The following errors were encountered at runtime: "; - message += GetErrorStringFromErrors(runtime_errors_); - message += "."; + if (AnyFailedDatatype()) { + result.insert(result.end(), startup_errors_.begin(), startup_errors_.end()); + result.insert(result.end(), runtime_errors_.begin(), runtime_errors_.end()); } - return message; + return result; } bool FailedDatatypesHandler::AnyFailedDatatype() const { diff --git a/chrome/browser/sync/failed_datatypes_handler.h b/chrome/browser/sync/failed_datatypes_handler.h index 85c29bb..bad9311 100644 --- a/chrome/browser/sync/failed_datatypes_handler.h +++ b/chrome/browser/sync/failed_datatypes_handler.h @@ -36,21 +36,21 @@ class FailedDatatypesHandler { // the current list of failed types and retry them once more. void OnUserChoseDatatypes(); + // Returns a list of all the errors this class has recorded. + std::vector<csync::SyncError> GetAllErrors() const; + // Returns the types that are failing. syncable::ModelTypeSet GetFailedTypes() const; + private: // Returns if there are any failed types. bool AnyFailedDatatype() const; - // Gets the error string giving more info about each type that is failing. - std::string GetErrorString() const; - - private: // List of dataypes that failed at startup. - std::list<csync::SyncError> startup_errors_; + std::vector<csync::SyncError> startup_errors_; // List of datatypes that failed at runtime. - std::list<csync::SyncError> runtime_errors_; + std::vector<csync::SyncError> runtime_errors_; ProfileSyncService* service_; diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc index d2d8b3c..37444ed 100644 --- a/chrome/browser/sync/profile_sync_service.cc +++ b/chrome/browser/sync/profile_sync_service.cc @@ -72,9 +72,12 @@ using csync::JsBackend; using csync::JsController; using csync::JsEventDetails; using csync::JsEventHandler; +using csync::ModelSafeRoutingInfo; +using csync::SyncCredentials; using csync::SyncProtocolError; using csync::WeakHandle; -using csync::SyncCredentials; +using syncable::ModelType; +using syncable::ModelTypeSet; typedef GoogleServiceAuthError AuthError; @@ -1244,6 +1247,73 @@ void ProfileSyncService::GetModelSafeRoutingInfo( } } +Value* ProfileSyncService::GetTypeStatusMap() const { + ListValue* result = new ListValue(); + + if (!backend_.get() || !backend_initialized_) { + return result; + } + + std::vector<csync::SyncError> errors = + failed_datatypes_handler_.GetAllErrors(); + std::map<ModelType, csync::SyncError> error_map; + for (std::vector<csync::SyncError>::iterator it = errors.begin(); + it != errors.end(); ++it) { + error_map[it->type()] = *it; + } + + ModelTypeSet active_types; + ModelTypeSet passive_types; + ModelSafeRoutingInfo routing_info; + backend_->GetModelSafeRoutingInfo(&routing_info); + for (ModelSafeRoutingInfo::const_iterator it = routing_info.begin(); + it != routing_info.end(); ++it) { + if (it->second == csync::GROUP_PASSIVE) { + passive_types.Put(it->first); + } else { + active_types.Put(it->first); + } + } + + SyncBackendHost::Status detailed_status = backend_->GetDetailedStatus(); + ModelTypeSet &throttled_types(detailed_status.throttled_types); + + ModelTypeSet registered = GetRegisteredDataTypes(); + for (ModelTypeSet::Iterator it = registered.First(); it.Good(); it.Inc()) { + ModelType type = it.Get(); + DictionaryValue* type_status = new DictionaryValue(); + + result->Append(type_status); + type_status->SetString("name", ModelTypeToString(type)); + + if (error_map.find(type) != error_map.end()) { + const csync::SyncError &error = error_map.find(type)->second; + DCHECK(error.IsSet()); + std::string error_text = "Error: " + error.location().ToString() + + ", " + error.message(); + type_status->SetString("status", "error"); + type_status->SetString("value", error_text); + } else if (throttled_types.Has(type) && passive_types.Has(type)) { + type_status->SetString("status", "warning"); + type_status->SetString("value", "Passive, Throttled"); + } else if (passive_types.Has(type)) { + type_status->SetString("status", "warning"); + type_status->SetString("value", "Passive"); + } else if (throttled_types.Has(type)) { + type_status->SetString("status", "warning"); + type_status->SetString("value", "Throttled"); + } else if (active_types.Has(type)) { + type_status->SetString("status", "ok"); + type_status->SetString("value", "Active: " + + ModelSafeGroupToString(routing_info[type])); + } else { + type_status->SetString("status", "warning"); + type_status->SetString("value", "Disabled by User"); + } + } + return result; +} + void ProfileSyncService::ActivateDataType( syncable::ModelType type, csync::ModelSafeGroup group, ChangeProcessor* change_processor) { @@ -1624,7 +1694,8 @@ void ProfileSyncService::ReconfigureDatatypeManager() { } } -const FailedDatatypesHandler& ProfileSyncService::failed_datatypes_handler() { +const FailedDatatypesHandler& ProfileSyncService::failed_datatypes_handler() + const { return failed_datatypes_handler_; } diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h index f86ce30..b04fcd7 100644 --- a/chrome/browser/sync/profile_sync_service.h +++ b/chrome/browser/sync/profile_sync_service.h @@ -405,16 +405,21 @@ class ProfileSyncService : public browser_sync::SyncFrontend, // Used by ProfileSyncServiceHarness. May return NULL. browser_sync::BackendMigrator* GetBackendMigratorForTest(); - // Get the current routing information for all enabled model types. - // If a model type is not enabled (that is, if the syncer should not - // be trying to sync it), it is not in this map. + // TODO(sync): This is only used in tests. Can we remove it? + void GetModelSafeRoutingInfo(csync::ModelSafeRoutingInfo* out) const; + + // Returns a ListValue indicating the status of all registered types. + // + // The format is: + // [ {"name": <name>, "value": <value>, "status": <status> }, ... ] + // where <name> is a type's name, <value> is a string providing details for + // the type's status, and <status> is one of "error", "warning" or "ok" + // dpending on the type's current status. // - // TODO(akalin): This function is used by - // sync_ui_util::ConstructAboutInformation() and by some test - // classes. Figure out a different way to expose this info and - // remove this function. - void GetModelSafeRoutingInfo( - csync::ModelSafeRoutingInfo* out) const; + // This function is used by sync_ui_util.cc to help populate the about:sync + // page. It returns a ListValue rather than a DictionaryValye in part to make + // it easier to iterate over its elements when constructing that page. + Value* GetTypeStatusMap() const; // Overridden by tests. // TODO(zea): Remove these and have the dtc's call directly into the SBH. @@ -517,7 +522,8 @@ class ProfileSyncService : public browser_sync::SyncFrontend, SyncGlobalError* sync_global_error() { return sync_global_error_.get(); } - virtual const FailedDatatypesHandler& failed_datatypes_handler(); + // TODO(sync): This is only used in tests. Can we remove it? + const FailedDatatypesHandler& failed_datatypes_handler() const; browser_sync::DataTypeManager::ConfigureStatus configure_status() { return configure_status_; diff --git a/chrome/browser/sync/sync_ui_util.cc b/chrome/browser/sync/sync_ui_util.cc index 5194f5e..66b5ebd 100644 --- a/chrome/browser/sync/sync_ui_util.cc +++ b/chrome/browser/sync/sync_ui_util.cc @@ -733,18 +733,9 @@ void ConstructAboutInformation(ProfileSyncService* service, full_status.sync_protocol_error.url); sync_ui_util::AddStringSyncDetails(actionable_error, "Error Description", full_status.sync_protocol_error.error_description); - } else { - strings->Set("actionable_error_detected", - base::Value::CreateBooleanValue(false)); - } - - const FailedDatatypesHandler& failed_datatypes_handler = - service->failed_datatypes_handler(); - if (failed_datatypes_handler.AnyFailedDatatype()) { - strings->Set("failed_data_types_detected", - new base::FundamentalValue(true)); - strings->SetString("failed_data_types", - failed_datatypes_handler.GetErrorString()); + } else { + strings->Set("actionable_error_detected", + base::Value::CreateBooleanValue(false)); } if (service->HasUnrecoverableError()) { @@ -758,18 +749,10 @@ void ConstructAboutInformation(ProfileSyncService* service, ": " + service->unrecoverable_error_message(); strings->SetString("unrecoverable_error_message", unrecoverable_error_message); - } else if (service->sync_initialized()) { - csync::ModelSafeRoutingInfo routes; - service->GetModelSafeRoutingInfo(&routes); - ListValue* routing_info = new ListValue(); - strings->Set("routing_info", routing_info); - csync::ModelSafeRoutingInfo::const_iterator it = routes.begin(); - for (; it != routes.end(); ++it) { - DictionaryValue* val = new DictionaryValue; - val->SetString("model_type", ModelTypeToString(it->first)); - val->SetString("group", csync::ModelSafeGroupToString(it->second)); - routing_info->Append(val); - } + } + + if (service->sync_initialized()) { + strings->Set("type_status", service->GetTypeStatusMap()); } } } |