[Tango->FCM] New statuses to allow better identify rediness of the invalidation service.
As of today, no status of the FCMInvalidationService is recorded if
service isn't started. It makes hard to spot the regression, which
happens when invalidation service can't be started. This CL introduces
new statuses, which will be recorded, when invalidation service was
unable to start.
BUG=924957
[email protected]
Change-Id: I5fcca7518df5f933b708cd9d0b31042aed734afd
Reviewed-on: https://chromium-review.googlesource.com/c/1483015
Commit-Queue: Tatiana Gornak <[email protected]>
Reviewed-by: Julian Pastarmov <[email protected]>
Reviewed-by: Jan Krcal <[email protected]>
Cr-Commit-Position: refs/heads/master@{#635084}
diff --git a/components/invalidation/impl/fcm_invalidation_service.cc b/components/invalidation/impl/fcm_invalidation_service.cc
index 006456b9..7933ff5 100644
--- a/components/invalidation/impl/fcm_invalidation_service.cc
+++ b/components/invalidation/impl/fcm_invalidation_service.cc
@@ -27,6 +27,10 @@
const char kApplicationName[] = "com.google.chrome.fcm.invalidations";
// Sender ID coming from the Firebase console.
const char kInvalidationGCMSenderId[] = "8181035976";
+
+void ReportInvalidatorState(syncer::InvalidatorState state) {
+ UMA_HISTOGRAM_ENUMERATION("Invalidations.StatusChanged", state);
+}
}
namespace invalidation {
@@ -59,8 +63,15 @@
void FCMInvalidationService::Init() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
- if (IsReadyToStart())
+ if (IsReadyToStart()) {
StartInvalidator();
+ } else {
+ if (identity_provider_->GetActiveAccountId().empty()) {
+ ReportInvalidatorState(syncer::NOT_STARTED_NO_ACTIVE_ACCOUNT);
+ } else {
+ ReportInvalidatorState(syncer::NOT_STARTED_NO_REFRESH_TOKEN);
+ }
+ }
identity_provider_->AddObserver(this);
}
@@ -162,6 +173,8 @@
if (is_ready_to_start) {
StartInvalidator();
+ } else {
+ ReportInvalidatorState(syncer::NOT_STARTED_NO_REFRESH_TOKEN);
}
}
@@ -183,7 +196,7 @@
void FCMInvalidationService::OnInvalidatorStateChange(
syncer::InvalidatorState state) {
- UMA_HISTOGRAM_ENUMERATION("Invalidations.StatusChanged", state);
+ ReportInvalidatorState(state);
invalidator_registrar_.UpdateInvalidatorState(state);
logger_.OnStateChange(state);
}
@@ -201,7 +214,7 @@
}
bool FCMInvalidationService::IsReadyToStart() {
- if (!identity_provider_->IsActiveAccountAvailable()) {
+ if (!identity_provider_->IsActiveAccountWithRefreshToken()) {
DVLOG(2) << "Not starting FCMInvalidationService: "
<< "active account is not available";
return false;
diff --git a/components/invalidation/impl/profile_identity_provider.cc b/components/invalidation/impl/profile_identity_provider.cc
index b7dbdb5..2bda764 100644
--- a/components/invalidation/impl/profile_identity_provider.cc
+++ b/components/invalidation/impl/profile_identity_provider.cc
@@ -72,7 +72,7 @@
return active_account_id_;
}
-bool ProfileIdentityProvider::IsActiveAccountAvailable() {
+bool ProfileIdentityProvider::IsActiveAccountWithRefreshToken() {
if (GetActiveAccountId().empty() || !identity_manager_ ||
!identity_manager_->HasAccountWithRefreshToken(GetActiveAccountId()))
return false;
diff --git a/components/invalidation/impl/profile_identity_provider.h b/components/invalidation/impl/profile_identity_provider.h
index aefbd56f..097034b 100644
--- a/components/invalidation/impl/profile_identity_provider.h
+++ b/components/invalidation/impl/profile_identity_provider.h
@@ -22,7 +22,7 @@
// IdentityProvider:
std::string GetActiveAccountId() override;
- bool IsActiveAccountAvailable() override;
+ bool IsActiveAccountWithRefreshToken() override;
std::unique_ptr<ActiveAccountAccessTokenFetcher> FetchAccessToken(
const std::string& oauth_consumer_name,
const identity::ScopeSet& scopes,
diff --git a/components/invalidation/impl/ticl_invalidation_service.cc b/components/invalidation/impl/ticl_invalidation_service.cc
index 48b991ec..a1229d6 100644
--- a/components/invalidation/impl/ticl_invalidation_service.cc
+++ b/components/invalidation/impl/ticl_invalidation_service.cc
@@ -332,7 +332,7 @@
std::string TiclInvalidationService::GetOwnerName() const { return "TICL"; }
bool TiclInvalidationService::IsReadyToStart() {
- if (!identity_provider_->IsActiveAccountAvailable()) {
+ if (!identity_provider_->IsActiveAccountWithRefreshToken()) {
DVLOG(2) << "Not starting TiclInvalidationService: "
<< "active account is not available";
return false;
diff --git a/components/invalidation/public/identity_provider.h b/components/invalidation/public/identity_provider.h
index a763163..9b7b2b60 100644
--- a/components/invalidation/public/identity_provider.h
+++ b/components/invalidation/public/identity_provider.h
@@ -68,7 +68,7 @@
// Returns true iff (1) there is an active account and (2) that account has
// a refresh token.
- virtual bool IsActiveAccountAvailable() = 0;
+ virtual bool IsActiveAccountWithRefreshToken() = 0;
// Starts an access token request for |oauth_consumer_name| and |scopes|. When
// the request completes, |callback| will be invoked with the access token
diff --git a/components/invalidation/public/invalidator_state.cc b/components/invalidation/public/invalidator_state.cc
index 405a7ec..e1ddab4 100644
--- a/components/invalidation/public/invalidator_state.cc
+++ b/components/invalidation/public/invalidator_state.cc
@@ -22,6 +22,10 @@
return "SUBSCRIPTION_FAILURE";
case STOPPED:
return "STOPPED";
+ case NOT_STARTED_NO_ACTIVE_ACCOUNT:
+ return "NOT_STARTED_NO_ACTIVE_ACCOUNT";
+ case NOT_STARTED_NO_REFRESH_TOKEN:
+ return "NOT_STARTED_NO_REFRESH_TOKEN";
}
}
diff --git a/components/invalidation/public/invalidator_state.h b/components/invalidation/public/invalidator_state.h
index c5a356b..6f1d6df 100644
--- a/components/invalidation/public/invalidator_state.h
+++ b/components/invalidation/public/invalidator_state.h
@@ -32,7 +32,13 @@
// Invalidator was stopped.
STOPPED = 5,
- kMaxValue = STOPPED,
+ // Starting was attempted, but failed due to absence of active account.
+ NOT_STARTED_NO_ACTIVE_ACCOUNT = 6,
+
+ // Starting was attempted, but failed due to absence of active account.
+ NOT_STARTED_NO_REFRESH_TOKEN = 7,
+
+ kMaxValue = NOT_STARTED_NO_REFRESH_TOKEN,
};
INVALIDATION_EXPORT const char* InvalidatorStateToString(