Index: chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc |
diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc |
index 6d51de5cfb6fef8003eb94d27980c29c335a4028..6ad2e07a9c9d7453fce94b9b588b7e78fcfd39eb 100644 |
--- a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc |
+++ b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc |
@@ -8,6 +8,8 @@ |
#include "base/bind_helpers.h" |
#include "base/logging.h" |
#include "base/message_loop/message_loop_proxy.h" |
+#include "base/metrics/histogram.h" |
+#include "base/metrics/sparse_histogram.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h" |
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h" |
@@ -24,6 +26,28 @@ namespace em = enterprise_management; |
namespace policy { |
+namespace { |
+ |
+// UMA histogram names. |
+const char kUMADelayInitialization[] = |
+ "Enterprise.UserPolicyChromeOS.DelayInitialization"; |
+const char kUMAInitialFetchClientError[] = |
+ "Enterprise.UserPolicyChromeOS.InitialFetch.ClientError"; |
+const char kUMAInitialFetchDelayClientRegister[] = |
+ "Enterprise.UserPolicyChromeOS.InitialFetch.DelayClientRegister"; |
+const char kUMAInitialFetchDelayOAuth2Token[] = |
+ "Enterprise.UserPolicyChromeOS.InitialFetch.DelayOAuth2Token"; |
+const char kUMAInitialFetchDelayPolicyFetch[] = |
+ "Enterprise.UserPolicyChromeOS.InitialFetch.DelayPolicyFetch"; |
+const char kUMAInitialFetchDelayTotal[] = |
+ "Enterprise.UserPolicyChromeOS.InitialFetch.DelayTotal"; |
+const char kUMAInitialFetchOAuth2Error[] = |
+ "Enterprise.UserPolicyChromeOS.InitialFetch.OAuth2Error"; |
+const char kUMAInitialFetchOAuth2NetworkError[] = |
+ "Enterprise.UserPolicyChromeOS.InitialFetch.OAuth2NetworkError"; |
+ |
+} // namespace |
+ |
UserCloudPolicyManagerChromeOS::UserCloudPolicyManagerChromeOS( |
scoped_ptr<CloudPolicyStore> store, |
scoped_ptr<ResourceCache> resource_cache, |
@@ -33,6 +57,7 @@ UserCloudPolicyManagerChromeOS::UserCloudPolicyManagerChromeOS( |
store.get()), |
store_(store.Pass()), |
wait_for_policy_fetch_(wait_for_policy_fetch) { |
+ time_init_started_ = base::Time::Now(); |
if (resource_cache) { |
// TODO(joaodasilva): Move the backend from the FILE thread to the blocking |
// pool. |
@@ -130,6 +155,11 @@ void UserCloudPolicyManagerChromeOS::OnInitializationCompleted( |
CloudPolicyService* cloud_policy_service) { |
DCHECK_EQ(service(), cloud_policy_service); |
cloud_policy_service->RemoveObserver(this); |
+ |
+ time_init_completed_ = base::Time::Now(); |
+ UMA_HISTOGRAM_TIMES(kUMADelayInitialization, |
+ time_init_completed_ - time_init_started_); |
+ |
// If the CloudPolicyClient isn't registered at this stage then it needs an |
// OAuth token for the initial registration. |
// |
@@ -171,7 +201,14 @@ void UserCloudPolicyManagerChromeOS::OnPolicyFetched( |
void UserCloudPolicyManagerChromeOS::OnRegistrationStateChanged( |
CloudPolicyClient* cloud_policy_client) { |
DCHECK_EQ(client(), cloud_policy_client); |
+ |
if (wait_for_policy_fetch_) { |
+ time_client_registered_ = base::Time::Now(); |
+ if (!time_token_available_.is_null()) { |
+ UMA_HISTOGRAM_TIMES(kUMAInitialFetchDelayClientRegister, |
+ time_client_registered_ - time_token_available_); |
+ } |
+ |
// If we're blocked on the policy fetch, now is a good time to issue it. |
if (client()->is_registered()) { |
service()->RefreshPolicy( |
@@ -190,6 +227,11 @@ void UserCloudPolicyManagerChromeOS::OnClientError( |
CloudPolicyClient* cloud_policy_client) { |
DCHECK_EQ(client(), cloud_policy_client); |
CancelWaitForPolicyFetch(); |
+ |
+ if (wait_for_policy_fetch_) { |
+ UMA_HISTOGRAM_SPARSE_SLOWLY(kUMAInitialFetchClientError, |
+ cloud_policy_client->status()); |
+ } |
} |
void UserCloudPolicyManagerChromeOS::OnComponentCloudPolicyRefreshNeeded() { |
@@ -225,6 +267,13 @@ void UserCloudPolicyManagerChromeOS::OnOAuth2PolicyTokenFetched( |
const std::string& policy_token, |
const GoogleServiceAuthError& error) { |
DCHECK(!client()->is_registered()); |
+ |
+ time_token_available_ = base::Time::Now(); |
+ if (wait_for_policy_fetch_) { |
+ UMA_HISTOGRAM_TIMES(kUMAInitialFetchDelayOAuth2Token, |
+ time_token_available_ - time_init_completed_); |
+ } |
+ |
if (error.state() == GoogleServiceAuthError::NONE) { |
// Start client registration. Either OnRegistrationStateChanged() or |
// OnClientError() will be called back. |
@@ -233,6 +282,14 @@ void UserCloudPolicyManagerChromeOS::OnOAuth2PolicyTokenFetched( |
} else { |
// Failed to get a token, stop waiting and use an empty policy. |
CancelWaitForPolicyFetch(); |
+ |
+ UMA_HISTOGRAM_ENUMERATION(kUMAInitialFetchOAuth2Error, |
+ error.state(), |
+ GoogleServiceAuthError::NUM_STATES); |
+ if (error.state() == GoogleServiceAuthError::CONNECTION_FAILED) { |
+ UMA_HISTOGRAM_SPARSE_SLOWLY(kUMAInitialFetchOAuth2NetworkError, |
+ error.network_error()); |
+ } |
} |
token_fetcher_.reset(); |
@@ -240,6 +297,11 @@ void UserCloudPolicyManagerChromeOS::OnOAuth2PolicyTokenFetched( |
void UserCloudPolicyManagerChromeOS::OnInitialPolicyFetchComplete( |
bool success) { |
+ |
+ const base::Time now = base::Time::Now(); |
+ UMA_HISTOGRAM_TIMES(kUMAInitialFetchDelayPolicyFetch, |
+ now - time_client_registered_); |
+ UMA_HISTOGRAM_TIMES(kUMAInitialFetchDelayTotal, now - time_init_started_); |
CancelWaitForPolicyFetch(); |
} |