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

Unified Diff: components/policy/core/common/cloud/cloud_policy_service.cc

Issue 2896863002: Add UMA histograms for time between policy fetches (Closed)
Patch Set: Rebase to ToT Created 3 years, 5 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
« no previous file with comments | « components/policy/core/common/cloud/cloud_policy_client.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/common/cloud/cloud_policy_service.cc
diff --git a/components/policy/core/common/cloud/cloud_policy_service.cc b/components/policy/core/common/cloud/cloud_policy_service.cc
index ca806791cabb47565222cfe668da19c6e30f2163..d1d638c401ae33aeb62cd8b48502fdaee2232cf0 100644
--- a/components/policy/core/common/cloud/cloud_policy_service.cc
+++ b/components/policy/core/common/cloud/cloud_policy_service.cc
@@ -8,6 +8,9 @@
#include "base/callback.h"
#include "base/logging.h"
+#include "base/metrics/histogram_macros.h"
+#include "base/time/time.h"
+#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/proto/device_management_backend.pb.h"
namespace em = enterprise_management;
@@ -115,6 +118,19 @@ void CloudPolicyService::OnStoreLoaded(CloudPolicyStore* store) {
base::Time policy_timestamp;
if (policy && policy->has_timestamp())
policy_timestamp = base::Time::FromJavaTime(policy->timestamp());
+
+ const base::Time& old_timestamp = client_->last_policy_timestamp();
+ if (!policy_timestamp.is_null() && !old_timestamp.is_null() &&
+ policy_timestamp != old_timestamp) {
+ const base::TimeDelta age = policy_timestamp - old_timestamp;
+ if (policy_type_ == dm_protocol::kChromeUserPolicyType) {
+ UMA_HISTOGRAM_CUSTOM_COUNTS("Enterprise.PolicyUpdatePeriod.User",
+ age.InDays(), 1, 1000, 100);
+ } else if (policy_type_ == dm_protocol::kChromeDevicePolicyType) {
+ UMA_HISTOGRAM_CUSTOM_COUNTS("Enterprise.PolicyUpdatePeriod.Device",
+ age.InDays(), 1, 1000, 100);
+ }
+ }
client_->set_last_policy_timestamp(policy_timestamp);
// Public key version.
« no previous file with comments | « components/policy/core/common/cloud/cloud_policy_client.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698