Commit 750b1f7a authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

about:sync-internals: Add fields for auth error and access token

A small step on the journey to making sync-internals useful for
investigating auth-related issues.

Bug: 889844
Change-Id: Ifa84cdb4e0f418e89b5207d4ea3cb1cb7d31b382
Reviewed-on: https://chromium-review.googlesource.com/c/1278628
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarMohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599244}
parent 4c5f63ac
......@@ -117,6 +117,7 @@ syncer::SyncTokenStatus SyncAuthManager::GetSyncTokenStatus() const {
DCHECK(partial_token_status_.next_token_request_time.is_null());
syncer::SyncTokenStatus token_status = partial_token_status_;
token_status.has_token = !access_token_.empty();
if (request_access_token_retry_timer_.IsRunning()) {
base::TimeDelta delta =
request_access_token_retry_timer_.desired_run_time() -
......
......@@ -180,7 +180,7 @@ class SyncAuthManager : public identity::IdentityManager::Observer {
// Info about the state of our access token, for display in the internals UI.
// "Partial" because this instance is not fully populated - in particular,
// |next_token_request_time| gets computed on demand.
// |have_token| and |next_token_request_time| get computed on demand.
syncer::SyncTokenStatus partial_token_status_;
base::WeakPtrFactory<SyncAuthManager> weak_ptr_factory_;
......
......@@ -323,12 +323,14 @@ std::unique_ptr<base::DictionaryValue> ConstructAboutInformation(
Section* section_identity = section_list.AddSection(kIdentityTitle);
section_identity->MarkSensitive();
Stat<std::string>* sync_id =
Stat<std::string>* sync_client_id =
section_identity->AddStringStat("Sync Client ID");
Stat<std::string>* invalidator_id =
section_identity->AddStringStat("Invalidator Client ID");
Stat<std::string>* username = section_identity->AddStringStat("Username");
Stat<bool>* user_is_primary = section_identity->AddBoolStat("Is Primary");
Stat<std::string>* auth_error = section_identity->AddStringStat("Auth Error");
// TODO(treib): Add the *time* of the auth error?
Section* section_credentials = section_list.AddSection("Credentials");
Stat<std::string>* request_token_time =
......@@ -337,6 +339,7 @@ std::unique_ptr<base::DictionaryValue> ConstructAboutInformation(
section_credentials->AddStringStat("Received Token");
Stat<std::string>* last_token_request_result =
section_credentials->AddStringStat("Last Token Request Result");
Stat<bool>* has_token = section_credentials->AddBoolStat("Has Token");
Stat<std::string>* next_token_request =
section_credentials->AddStringStat("Next Token Request");
......@@ -460,17 +463,20 @@ std::unique_ptr<base::DictionaryValue> ConstructAboutInformation(
// Identity.
if (is_status_valid && !full_status.sync_id.empty())
sync_id->Set(full_status.sync_id);
sync_client_id->Set(full_status.sync_id);
if (is_status_valid && !full_status.invalidator_client_id.empty())
invalidator_id->Set(full_status.invalidator_client_id);
username->Set(service->GetAuthenticatedAccountInfo().email);
user_is_primary->Set(service->IsAuthenticatedAccountPrimary());
std::string auth_error_str = service->GetAuthError().ToString();
auth_error->Set(auth_error_str.empty() ? "None" : auth_error_str);
// Credentials.
request_token_time->Set(GetTimeStr(token_status.token_request_time, "n/a"));
receive_token_time->Set(GetTimeStr(token_status.token_receive_time, "n/a"));
std::string err = token_status.last_get_token_error.error_message();
last_token_request_result->Set(err.empty() ? "OK" : err);
has_token->Set(token_status.has_token);
next_token_request->Set(
GetTimeStr(token_status.next_token_request_time, "not scheduled"));
......
......@@ -6,8 +6,6 @@
namespace syncer {
SyncTokenStatus::SyncTokenStatus()
: connection_status(CONNECTION_NOT_ATTEMPTED),
last_get_token_error(GoogleServiceAuthError::AuthErrorNone()) {}
SyncTokenStatus::SyncTokenStatus() = default;
} // namespace syncer
......@@ -15,17 +15,22 @@ namespace syncer {
struct SyncTokenStatus {
SyncTokenStatus();
// Sync server connection status reported by sync engine.
// Sync server connection status reported by the sync engine.
base::Time connection_status_update_time;
ConnectionStatus connection_status;
ConnectionStatus connection_status = CONNECTION_NOT_ATTEMPTED;
// Times when OAuth2 access token is requested and received.
// The last times when an OAuth2 access token was requested and received.
base::Time token_request_time;
base::Time token_receive_time;
// Error returned by OAuth2TokenService for token request and time when
// next request is scheduled.
// Whether we currently have an OAuth2 access token.
bool has_token = false;
// The error returned by OAuth2TokenService for the last token request.
GoogleServiceAuthError last_get_token_error;
// The time when the next token request is scheduled, or a null time if no
// request is scheduled.
base::Time next_token_request_time;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment