summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_about_handler.cc
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-15 20:54:24 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-15 20:54:24 +0000
commitf1e6e0218795cf635c877a60dbd5e8be784b381d (patch)
tree9b11d48476580205972516bc2765586ca280d002 /chrome/browser/browser_about_handler.cc
parent9062e85d56308d06cfb0926b0eedee313283a44d (diff)
downloadchromium_src-f1e6e0218795cf635c877a60dbd5e8be784b381d.zip
chromium_src-f1e6e0218795cf635c877a60dbd5e8be784b381d.tar.gz
chromium_src-f1e6e0218795cf635c877a60dbd5e8be784b381d.tar.bz2
[Sync] fix about:sync crash with unrecoverable error
If the client had encountered an unrecoverable error typing about:sync would crash because the client code would try to dereference the backendhost for the purpose of printing the model group information(by this time backendhost would have been released). The fix is to bail out of printing the model information if the client had encountered an unrecoverable error. however we would still print the client had encountered an urecoverable error and the line number etc. In the process moved a bunch of code related to collecting about information for sync, from browser_about_handler.cc to sync_ui_util.cc. The refactoing helps us in unit testing by passing in a mock service object. BUG=55503 TEST=Wrote a new unit test for it. ConstructAboutInformationWithUnrecoverableErrorTest. Also tested by pretending one of the datatypes generated an unrecoverable error in the debugger. Original patch by lipalani@google.com Original review: http://codereview.chromium.org/3715002 Review URL: http://codereview.chromium.org/3810011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62789 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_about_handler.cc')
-rw-r--r--chrome/browser/browser_about_handler.cc97
1 files changed, 3 insertions, 94 deletions
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc
index a93dd91c..38f27a6 100644
--- a/chrome/browser/browser_about_handler.cc
+++ b/chrome/browser/browser_about_handler.cc
@@ -42,6 +42,7 @@
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/common/about_handler.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_version_info.h"
@@ -675,38 +676,7 @@ std::string AboutVersion(DictionaryValue* localized_strings) {
version_html, localized_strings, "t" /* template root node id */);
}
-static void AddBoolSyncDetail(ListValue* details, const std::string& stat_name,
- bool stat_value) {
- DictionaryValue* val = new DictionaryValue;
- val->SetString("stat_name", stat_name);
- val->SetBoolean("stat_value", stat_value);
- details->Append(val);
-}
-
-static void AddIntSyncDetail(ListValue* details, const std::string& stat_name,
- int64 stat_value) {
- DictionaryValue* val = new DictionaryValue;
- val->SetString("stat_name", stat_name);
- val->SetString("stat_value", base::FormatNumber(stat_value));
- details->Append(val);
-}
-static std::string MakeSyncAuthErrorText(
- const GoogleServiceAuthError::State& state) {
- switch (state) {
- case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS:
- case GoogleServiceAuthError::ACCOUNT_DELETED:
- case GoogleServiceAuthError::ACCOUNT_DISABLED:
- case GoogleServiceAuthError::SERVICE_UNAVAILABLE:
- return "INVALID_GAIA_CREDENTIALS";
- case GoogleServiceAuthError::USER_NOT_SIGNED_UP:
- return "USER_NOT_SIGNED_UP";
- case GoogleServiceAuthError::CONNECTION_FAILED:
- return "CONNECTION_FAILED";
- default:
- return std::string();
- }
-}
std::string AboutSync() {
FilePath user_data_dir;
@@ -717,71 +687,10 @@ std::string AboutSync() {
ProfileSyncService* service = profile->GetProfileSyncService();
DictionaryValue strings;
- if (!service || !service->HasSyncSetupCompleted()) {
+ if (!service) {
strings.SetString("summary", "SYNC DISABLED");
} else {
- SyncManager::Status full_status(service->QueryDetailedSyncStatus());
-
- strings.SetString("service_url", service->sync_service_url().spec());
- strings.SetString("summary",
- ProfileSyncService::BuildSyncStatusSummaryText(
- full_status.summary));
-
- strings.Set("authenticated",
- new FundamentalValue(full_status.authenticated));
- strings.SetString("auth_problem",
- MakeSyncAuthErrorText(service->GetAuthError().state()));
-
- strings.SetString("time_since_sync", service->GetLastSyncedTimeString());
-
- ListValue* details = new ListValue();
- strings.Set("details", details);
- AddBoolSyncDetail(details, "Server Up", full_status.server_up);
- AddBoolSyncDetail(details, "Server Reachable",
- full_status.server_reachable);
- AddBoolSyncDetail(details, "Server Broken", full_status.server_broken);
- AddBoolSyncDetail(details, "Notifications Enabled",
- full_status.notifications_enabled);
- AddIntSyncDetail(details, "Notifications Received",
- full_status.notifications_received);
- AddIntSyncDetail(details, "Notifications Sent",
- full_status.notifications_sent);
- AddIntSyncDetail(details, "Unsynced Count", full_status.unsynced_count);
- AddIntSyncDetail(details, "Conflicting Count",
- full_status.conflicting_count);
- AddBoolSyncDetail(details, "Syncing", full_status.syncing);
- AddBoolSyncDetail(details, "Initial Sync Ended",
- full_status.initial_sync_ended);
- AddBoolSyncDetail(details, "Syncer Stuck", full_status.syncer_stuck);
- AddIntSyncDetail(details, "Updates Available",
- full_status.updates_available);
- AddIntSyncDetail(details, "Updates Received", full_status.updates_received);
- AddBoolSyncDetail(details, "Disk Full", full_status.disk_full);
- AddBoolSyncDetail(details, "Invalid Store", full_status.invalid_store);
- AddIntSyncDetail(details, "Max Consecutive Errors",
- full_status.max_consecutive_errors);
-
- if (service->unrecoverable_error_detected()) {
- strings.Set("unrecoverable_error_detected", new FundamentalValue(true));
- strings.SetString("unrecoverable_error_message",
- service->unrecoverable_error_message());
- tracked_objects::Location loc(service->unrecoverable_error_location());
- std::string location_str;
- loc.Write(true, true, &location_str);
- strings.SetString("unrecoverable_error_location", location_str);
- }
-
- browser_sync::ModelSafeRoutingInfo routes;
- service->backend()->GetModelSafeRoutingInfo(&routes);
- ListValue* routing_info = new ListValue();
- strings.Set("routing_info", routing_info);
- browser_sync::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", ModelSafeGroupToString(it->second));
- routing_info->Append(val);
- }
+ sync_ui_util::ConstructAboutInformation(service, &strings);
}
static const base::StringPiece sync_html(