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

Unified Diff: chrome/browser/sync/sync_ui_util.cc

Issue 10694013: Shade uninitialized about:sync fields (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix one more test error Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/sync_ui_util.cc
diff --git a/chrome/browser/sync/sync_ui_util.cc b/chrome/browser/sync/sync_ui_util.cc
index f597154c8f310a4f7a99437e59bf92e6b9c01b35..5455aa50490a23c82212aac43daffebc798636ff 100644
--- a/chrome/browser/sync/sync_ui_util.cc
+++ b/chrome/browser/sync/sync_ui_util.cc
@@ -209,7 +209,8 @@ MessageType GetStatusInfo(ProfileSyncService* service,
}
if (service->HasSyncSetupCompleted()) {
- ProfileSyncService::Status status(service->QueryDetailedSyncStatus());
+ ProfileSyncService::Status status;
+ service->QueryDetailedSyncStatus(&status);
const AuthError& auth_error = service->GetAuthError();
// The order or priority is going to be: 1. Unrecoverable errors.
@@ -277,7 +278,8 @@ MessageType GetStatusInfo(ProfileSyncService* service,
// or provide a link to continue with setup.
result_type = PRE_SYNCED;
if (service->FirstSetupInProgress()) {
- ProfileSyncService::Status status(service->QueryDetailedSyncStatus());
+ ProfileSyncService::Status status;
+ service->QueryDetailedSyncStatus(&status);
const AuthError& auth_error = service->GetAuthError();
if (status_label) {
status_label->assign(
@@ -299,7 +301,8 @@ MessageType GetStatusInfo(ProfileSyncService* service,
}
} else if (service->HasUnrecoverableError()) {
result_type = SYNC_ERROR;
- ProfileSyncService::Status status(service->QueryDetailedSyncStatus());
+ ProfileSyncService::Status status;
+ service->QueryDetailedSyncStatus(&status);
if (ShouldShowActionOnUI(status.sync_protocol_error)) {
if (status_label) {
GetStatusForActionableError(status.sync_protocol_error,
@@ -435,31 +438,39 @@ string16 GetSyncMenuLabel(
void AddBoolSyncDetail(ListValue* details,
const std::string& stat_name,
- bool stat_value) {
+ bool stat_value,
+ bool is_valid) {
DictionaryValue* val = new DictionaryValue;
val->SetString("stat_name", stat_name);
val->SetBoolean("stat_value", stat_value);
+ val->SetBoolean("is_valid", is_valid);
details->Append(val);
}
-void AddStringSyncDetails(ListValue* details, const std::string& stat_name,
- const string16& stat_value) {
+void AddStringSyncDetails(ListValue* details,
+ const std::string& stat_name,
+ const string16& stat_value,
+ bool is_valid) {
DictionaryValue* val = new DictionaryValue;
val->SetString("stat_name", stat_name);
val->SetString("stat_value", stat_value);
+ val->SetBoolean("is_valid", is_valid);
details->Append(val);
}
-void AddStringSyncDetails(ListValue* details, const std::string& stat_name,
- const std::string& stat_value) {
+void AddStringSyncDetails(ListValue* details,
+ const std::string& stat_name,
+ const std::string& stat_value,
+ bool is_valid) {
DictionaryValue* val = new DictionaryValue;
val->SetString("stat_name", stat_name);
val->SetString("stat_value", stat_value);
+ val->SetBoolean("is_valid", is_valid);
details->Append(val);
}
ListValue* AddSyncDetailsSection(ListValue* details,
- const std::string& name) {
+ const std::string& name) {
DictionaryValue* val = new DictionaryValue;
details->Append(val);
val->SetString("title", name);
@@ -468,11 +479,14 @@ ListValue* AddSyncDetailsSection(ListValue* details,
return list;
}
-void AddIntSyncDetail(ListValue* details, const std::string& stat_name,
- int64 stat_value) {
+void AddIntSyncDetail(ListValue* details,
+ const std::string& stat_name,
+ int64 stat_value,
+ bool is_valid) {
DictionaryValue* val = new DictionaryValue;
val->SetString("stat_name", stat_name);
val->SetString("stat_value", base::FormatNumber(stat_value));
+ val->SetBoolean("is_valid", is_valid);
details->Append(val);
}
@@ -512,14 +526,16 @@ void ConstructAboutInformation(ProfileSyncService* service,
CHECK(strings);
if (!service) {
sync_ui_util::AddStringSyncDetails(sync_summary, "Summary",
- "Sync service does not exist");
+ "Sync service does not exist", true);
} else {
// This bypasses regular inter-thread communication mechanisms to grab a
// very recent snapshot from the syncer thread. It should be up to date
// with the last snapshot emitted by the syncer. Keep in mind, though, that
// not all events that update these values will ping the UI thread, so you
// might not see all intermediate values.
- syncer::SyncStatus full_status(service->QueryDetailedSyncStatus());
+ syncer::SyncStatus full_status;
+ bool is_status_valid = service->QueryDetailedSyncStatus(&full_status);
+ bool sync_initialized = service->sync_initialized();
// This is a cache of the last snapshot of type SYNC_CYCLE_ENDED where
// !snapshot.has_more_to_sync(). In other words, it's the last in this
@@ -533,139 +549,168 @@ void ConstructAboutInformation(ProfileSyncService* service,
//
// |snapshot| could be NULL if sync is not yet initialized.
const syncer::sessions::SyncSessionSnapshot& snapshot =
- service->sync_initialized() ?
+ sync_initialized ?
service->GetLastSessionSnapshot() :
syncer::sessions::SyncSessionSnapshot();
sync_ui_util::AddStringSyncDetails(sync_summary, "Summary",
- service->QuerySyncStatusSummary());
+ service->QuerySyncStatusSummary(), true);
ListValue* version_info = AddSyncDetailsSection(details, "Version Info");
sync_ui_util::AddStringSyncDetails(version_info, "Client Version",
- GetVersionString());
+ GetVersionString(), true);
sync_ui_util::AddStringSyncDetails(version_info, "Server URL",
- service->sync_service_url().spec());
+ service->sync_service_url().spec(),
+ true);
ListValue* user_state = AddSyncDetailsSection(details, "Credentials");
sync_ui_util::AddStringSyncDetails(user_state, "Client ID",
- full_status.unique_id.empty() ? "none" : full_status.unique_id);
+ full_status.unique_id.empty() ? "none" : full_status.unique_id,
+ is_status_valid);
sync_ui_util::AddStringSyncDetails(
user_state, "Username",
- service->signin() ? service->signin()->GetAuthenticatedUsername() : "");
+ service->signin() ? service->signin()->GetAuthenticatedUsername() : "",
+ true);
sync_ui_util::AddBoolSyncDetail(
- user_state, "Sync Token Available", service->IsSyncTokenAvailable());
+ user_state, "Sync Token Available", service->IsSyncTokenAvailable(),
+ true);
ListValue* local_state = AddSyncDetailsSection(details, "Local State");
sync_ui_util::AddStringSyncDetails(local_state, "Last Synced",
- service->GetLastSyncedTimeString());
+ service->GetLastSyncedTimeString(),
+ true);
// Some global status indicators. These will change only in exceptional
// circumstances, like encryption changes, new data types, throttling, etc.
sync_ui_util::AddBoolSyncDetail(local_state,
"Sync First-Time Setup Complete",
- service->HasSyncSetupCompleted());
- sync_ui_util::AddBoolSyncDetail(local_state, "Initial Download Complete",
- full_status.initial_sync_ended);
+ service->HasSyncSetupCompleted(),
+ true);
sync_ui_util::AddBoolSyncDetail(local_state, "Sync Backend Initialized",
- service->sync_initialized());
+ sync_initialized,
+ true);
+ sync_ui_util::AddBoolSyncDetail(local_state, "Initial Download Complete",
+ full_status.initial_sync_ended,
+ is_status_valid);
// Whether or not we're currently syncing. Will almost always be false
// because we do not usually update about:sync until a sync cycle has
// completed.
sync_ui_util::AddBoolSyncDetail(local_state, "Syncing",
- full_status.syncing);
+ full_status.syncing,
+ is_status_valid);
// Network status indicators.
ListValue* network = AddSyncDetailsSection(details, "Network");
sync_ui_util::AddBoolSyncDetail(network, "Throttled",
- snapshot.is_silenced());
+ snapshot.is_silenced(),
+ snapshot.is_initialized());
sync_ui_util::AddBoolSyncDetail(network, "Notifications Enabled",
- full_status.notifications_enabled);
+ full_status.notifications_enabled,
+ is_status_valid);
// Encryption status indicators.
- //
+ ListValue* encryption = AddSyncDetailsSection(details, "Encryption");
+
// Only safe to call IsUsingSecondaryPassphrase() if the backend is
// initialized already - otherwise, we have no idea whether we are
// using a secondary passphrase or not.
- ListValue* encryption = AddSyncDetailsSection(details, "Encryption");
- if (service->sync_initialized()) {
- sync_ui_util::AddBoolSyncDetail(encryption,
- "Explicit Passphrase",
- service->IsUsingSecondaryPassphrase());
- }
+ sync_ui_util::AddBoolSyncDetail(
+ encryption, "Explicit Passphrase",
+ sync_initialized ? service->IsUsingSecondaryPassphrase() : false,
+ sync_initialized);
+ // The passphrase required value is cleared when the backend is shutdown, so
+ // we don't trust it unless sync_initialized is true.
sync_ui_util::AddBoolSyncDetail(encryption,
"Passphrase Required",
- service->IsPassphraseRequired());
+ service->IsPassphraseRequired(),
+ sync_initialized);
sync_ui_util::AddBoolSyncDetail(encryption,
"Cryptographer Ready",
- full_status.cryptographer_ready);
+ full_status.cryptographer_ready,
+ is_status_valid);
sync_ui_util::AddBoolSyncDetail(encryption,
"Cryptographer Has Pending Keys",
- full_status.crypto_has_pending_keys);
+ full_status.crypto_has_pending_keys,
+ is_status_valid);
sync_ui_util::AddStringSyncDetails(encryption,
"Encrypted Types",
- syncable::ModelTypeSetToString(full_status.encrypted_types));
-
+ syncable::ModelTypeSetToString(full_status.encrypted_types),
+ is_status_valid);
ListValue* cycles = AddSyncDetailsSection(
details, "Status from Last Completed Session");
sync_ui_util::AddStringSyncDetails(
cycles, "Sync Source",
syncer::GetUpdatesSourceString(
- snapshot.source().updates_source));
+ snapshot.source().updates_source),
+ snapshot.is_initialized());
sync_ui_util::AddStringSyncDetails(
cycles, "Download Step Result",
GetSyncerErrorString(
- snapshot.model_neutral_state().last_download_updates_result));
+ snapshot.model_neutral_state().last_download_updates_result),
+ snapshot.is_initialized());
sync_ui_util::AddStringSyncDetails(
cycles, "Commit Step Result",
- GetSyncerErrorString(snapshot.model_neutral_state().commit_result));
+ GetSyncerErrorString(snapshot.model_neutral_state().commit_result),
+ snapshot.is_initialized());
// Strictly increasing counters.
ListValue* counters = AddSyncDetailsSection(details, "Running Totals");
sync_ui_util::AddIntSyncDetail(counters,
"Notifications Received",
- full_status.notifications_received);
-
+ full_status.notifications_received,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(counters,
"Cycles Without Updates",
- full_status.empty_get_updates);
+ full_status.empty_get_updates,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(counters,
"Cycles With Updates",
- full_status.nonempty_get_updates);
+ full_status.nonempty_get_updates,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(counters,
"Cycles Without Commits",
- full_status.sync_cycles_without_commits);
+ full_status.sync_cycles_without_commits,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(counters,
"Cycles With Commits",
- full_status.sync_cycles_with_commits);
+ full_status.sync_cycles_with_commits,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(counters,
"Cycles Without Commits or Updates",
- full_status.useless_sync_cycles);
+ full_status.useless_sync_cycles,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(counters,
"Cycles With Commit or Update",
- full_status.useful_sync_cycles);
-
+ full_status.useful_sync_cycles,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(counters,
"Updates Downloaded",
- full_status.updates_received);
+ full_status.updates_received,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(
counters, "Tombstone Updates",
- full_status.tombstone_updates_received);
+ full_status.tombstone_updates_received,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(
counters, "Reflected Updates",
- full_status.reflected_updates_received);
+ full_status.reflected_updates_received,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(
counters, "Successful Commits",
- full_status.num_commits_total);
+ full_status.num_commits_total,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(
counters, "Conflict Resolved: Client Wins",
- full_status.num_local_overwrites_total);
+ full_status.num_local_overwrites_total,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(
counters, "Conflict Resolved: Server Wins",
- full_status.num_server_overwrites_total);
+ full_status.num_server_overwrites_total,
+ is_status_valid);
// This is counted when we prepare the commit message.
ListValue* transient_cycle = AddSyncDetailsSection(
@@ -674,32 +719,40 @@ void ConstructAboutInformation(ProfileSyncService* service,
// These are counted during the ApplyUpdates step.
sync_ui_util::AddIntSyncDetail(
transient_cycle, "Encryption Conflicts",
- full_status.encryption_conflicts);
+ full_status.encryption_conflicts,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(
transient_cycle, "Hierarchy Conflicts",
- full_status.hierarchy_conflicts);
+ full_status.hierarchy_conflicts,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(
transient_cycle, "Simple Conflicts",
- full_status.simple_conflicts);
+ full_status.simple_conflicts,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(
transient_cycle, "Server Conflicts",
- full_status.server_conflicts);
+ full_status.server_conflicts,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(
transient_cycle, "Committed Items",
- full_status.committed_count);
+ full_status.committed_count,
+ is_status_valid);
sync_ui_util::AddIntSyncDetail(
transient_cycle, "Updates Remaining",
- full_status.updates_available);
+ full_status.updates_available,
+ is_status_valid);
ListValue* transient_session = AddSyncDetailsSection(
details, "Transient Counters (last cycle of last completed session)");
sync_ui_util::AddIntSyncDetail(
transient_session, "Updates Downloaded",
- snapshot.model_neutral_state().num_updates_downloaded_total);
+ snapshot.model_neutral_state().num_updates_downloaded_total,
+ snapshot.is_initialized());
sync_ui_util::AddIntSyncDetail(
transient_session, "Committed Count",
- snapshot.model_neutral_state().num_successful_commits);
+ snapshot.model_neutral_state().num_successful_commits,
+ snapshot.is_initialized());
// This counter is stale. The warnings related to the snapshot still
// apply, see the comments near call to GetLastSessionSnapshot() above.
@@ -707,40 +760,38 @@ void ConstructAboutInformation(ProfileSyncService* service,
// local changes affecting this count will not be displayed until the
// syncer has attempted to commit those changes.
sync_ui_util::AddIntSyncDetail(transient_session, "Entries",
- snapshot.num_entries());
-
- if (!full_status.throttled_types.Empty()) {
- strings->Set("throttled_data_types", base::Value::CreateStringValue(
- ModelTypeSetToString(full_status.throttled_types)));
- }
-
- // Now set the actionable errors.
- if ((full_status.sync_protocol_error.error_type !=
- syncer::UNKNOWN_ERROR) &&
- (full_status.sync_protocol_error.error_type !=
- syncer::SYNC_SUCCESS)) {
- strings->Set("actionable_error_detected",
- base::Value::CreateBooleanValue(true));
- ListValue* actionable_error = new ListValue();
- strings->Set("actionable_error", actionable_error);
- sync_ui_util::AddStringSyncDetails(actionable_error, "Error Type",
- syncer::GetSyncErrorTypeString(
- full_status.sync_protocol_error.error_type));
- sync_ui_util::AddStringSyncDetails(actionable_error, "Action",
- syncer::GetClientActionString(
- full_status.sync_protocol_error.action));
- sync_ui_util::AddStringSyncDetails(actionable_error, "url",
- 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));
- }
+ snapshot.num_entries(),
+ snapshot.is_initialized());
+
+ // We don't need to check is_status_valid here.
+ // full_status.sync_protocol_error is exported directly from the
+ // ProfileSyncService, even if the backend doesn't exist.
+ const bool actionable_error_detected =
+ full_status.sync_protocol_error.error_type != syncer::UNKNOWN_ERROR &&
+ full_status.sync_protocol_error.error_type != syncer::SYNC_SUCCESS;
+
+ strings->Set("actionable_error_detected",
+ new base::FundamentalValue(actionable_error_detected));
+
+ // We won't display this unless actionable_error_detected is set, so there's
+ // no harm in exporting it anyway.
+ ListValue* actionable_error = new ListValue();
+ strings->Set("actionable_error", actionable_error);
+ sync_ui_util::AddStringSyncDetails(actionable_error, "Error Type",
+ syncer::GetSyncErrorTypeString(
+ full_status.sync_protocol_error.error_type), true);
+ sync_ui_util::AddStringSyncDetails(actionable_error, "Action",
+ syncer::GetClientActionString(
+ full_status.sync_protocol_error.action), true);
+ sync_ui_util::AddStringSyncDetails(actionable_error, "url",
+ full_status.sync_protocol_error.url, true);
+ sync_ui_util::AddStringSyncDetails(actionable_error, "Error Description",
+ full_status.sync_protocol_error.error_description, true);
+
+ strings->Set("unrecoverable_error_detected",
+ new base::FundamentalValue(service->HasUnrecoverableError()));
if (service->HasUnrecoverableError()) {
- strings->Set("unrecoverable_error_detected",
- new base::FundamentalValue(true));
tracked_objects::Location loc(service->unrecoverable_error_location());
std::string location_str;
loc.Write(true, true, &location_str);
@@ -751,9 +802,7 @@ void ConstructAboutInformation(ProfileSyncService* service,
unrecoverable_error_message);
}
- if (service->sync_initialized()) {
- strings->Set("type_status", service->GetTypeStatusMap());
- }
+ strings->Set("type_status", service->GetTypeStatusMap());
}
}

Powered by Google App Engine
This is Rietveld 408576698