Commit fe699dfe authored by tnagel@chromium.org's avatar tnagel@chromium.org

Add UMA for policy load result on enrolled Chrome OS devices.

Log only one entry per session to reduce distortion due to potentially different usage patterns depending on the policy load result.  To facilitate correct accounting, the status of DeviceSettingsService is switched to STORE_VALIDATION_ERROR once retries for STORE_TEMP_VALIDATION_ERROR have been exhausted.

BUG=376331

Review URL: https://codereview.chromium.org/295103013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272949 0039d316-1c4b-4281-b951-d872f2087c98
parent 734c4276
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/metrics/histogram.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "chrome/browser/chromeos/policy/device_policy_decoder_chromeos.h" #include "chrome/browser/chromeos/policy/device_policy_decoder_chromeos.h"
#include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h"
...@@ -22,6 +23,7 @@ DeviceCloudPolicyStoreChromeOS::DeviceCloudPolicyStoreChromeOS( ...@@ -22,6 +23,7 @@ DeviceCloudPolicyStoreChromeOS::DeviceCloudPolicyStoreChromeOS(
: device_settings_service_(device_settings_service), : device_settings_service_(device_settings_service),
install_attributes_(install_attributes), install_attributes_(install_attributes),
background_task_runner_(background_task_runner), background_task_runner_(background_task_runner),
uma_done_(false),
weak_factory_(this) { weak_factory_(this) {
device_settings_service_->AddObserver(this); device_settings_service_->AddObserver(this);
} }
...@@ -133,6 +135,20 @@ void DeviceCloudPolicyStoreChromeOS::UpdateFromService() { ...@@ -133,6 +135,20 @@ void DeviceCloudPolicyStoreChromeOS::UpdateFromService() {
return; return;
} }
// Fill UMA histogram once per session. Skip temp validation error because it
// is not a definitive result (policy load will be retried).
const chromeos::DeviceSettingsService::Status status =
device_settings_service_->status();
if (!uma_done_ &&
status != chromeos::DeviceSettingsService::STORE_TEMP_VALIDATION_ERROR) {
uma_done_ = true;
const bool has_dm_token =
status == chromeos::DeviceSettingsService::STORE_SUCCESS &&
device_settings_service_->policy_data() &&
device_settings_service_->policy_data()->has_request_token();
UMA_HISTOGRAM_BOOLEAN("Enterprise.EnrolledPolicyHasDMToken", has_dm_token);
}
switch (device_settings_service_->status()) { switch (device_settings_service_->status()) {
case chromeos::DeviceSettingsService::STORE_SUCCESS: { case chromeos::DeviceSettingsService::STORE_SUCCESS: {
status_ = STATUS_OK; status_ = STATUS_OK;
......
...@@ -76,6 +76,9 @@ class DeviceCloudPolicyStoreChromeOS ...@@ -76,6 +76,9 @@ class DeviceCloudPolicyStoreChromeOS
scoped_refptr<base::SequencedTaskRunner> background_task_runner_; scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
// Ensure that UMA stats are only reported once per browser start.
bool uma_done_;
base::WeakPtrFactory<DeviceCloudPolicyStoreChromeOS> weak_factory_; base::WeakPtrFactory<DeviceCloudPolicyStoreChromeOS> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyStoreChromeOS); DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyStoreChromeOS);
......
...@@ -362,6 +362,10 @@ void DeviceSettingsService::HandleCompletedOperation( ...@@ -362,6 +362,10 @@ void DeviceSettingsService::HandleCompletedOperation(
FROM_HERE, FROM_HERE,
base::Bind(&DeviceSettingsService::Load, base::Unretained(this)), base::Bind(&DeviceSettingsService::Load, base::Unretained(this)),
base::TimeDelta::FromMilliseconds(kLoadRetryDelayMs)); base::TimeDelta::FromMilliseconds(kLoadRetryDelayMs));
} else {
// Once we've given up retrying, the validation error is not temporary
// anymore.
store_status_ = STORE_VALIDATION_ERROR;
} }
} }
} }
......
...@@ -4930,6 +4930,16 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -4930,6 +4930,16 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary> </summary>
</histogram> </histogram>
<histogram name="Enterprise.EnrolledPolicyHasDMToken" enum="Boolean">
<owner>tnagel@chromium.org</owner>
<summary>
Whether loading of device policy from file on an enterprise-enrolled
(checked against install_attributes.pb) Chrome OS device yields an
enterprise policy with a DM token. Filled once during session startup,
after first successful device policy read.
</summary>
</histogram>
<histogram name="Enterprise.Enrollment" enum="EnterpriseEnrollmentType"> <histogram name="Enterprise.Enrollment" enum="EnterpriseEnrollmentType">
<owner>joaodasilva@chromium.org</owner> <owner>joaodasilva@chromium.org</owner>
<summary> <summary>
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