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

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

Issue 2896863002: Add UMA histograms for time between policy fetches (Closed)
Patch Set: Created 3 years, 7 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 | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')
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..b66f958b5ed8686a3500e29d5af9f432d4f88004 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) {
+ base::TimeDelta age = policy_timestamp - old_timestamp;
bartfab (slow) 2017/06/12 15:01:58 Nit: const
Denis Kuznetsov (DE-MUC) 2017/07/03 10:20:00 Done.
+ 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 | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698