| Index: chrome/browser/policy/user_policy_cache.cc
|
| diff --git a/chrome/browser/policy/user_policy_cache.cc b/chrome/browser/policy/user_policy_cache.cc
|
| index 6d0a53edb90d11437ca986ddc402764237ae56ce..2e3873c54320114a962ae4056fb09e4431bd7aee 100644
|
| --- a/chrome/browser/policy/user_policy_cache.cc
|
| +++ b/chrome/browser/policy/user_policy_cache.cc
|
| @@ -13,6 +13,7 @@
|
| #include "base/task.h"
|
| #include "base/values.h"
|
| #include "chrome/browser/policy/configuration_policy_pref_store.h"
|
| +#include "chrome/browser/policy/enterprise_metrics.h"
|
| #include "chrome/browser/policy/policy_map.h"
|
| #include "chrome/browser/policy/proto/cloud_policy.pb.h"
|
| #include "chrome/browser/policy/proto/device_management_local.pb.h"
|
| @@ -22,6 +23,8 @@
|
|
|
| namespace policy {
|
|
|
| +namespace em = enterprise_management;
|
| +
|
| // Decodes a CloudPolicySettings object into two maps with mandatory and
|
| // recommended settings, respectively. The implementation is generated code
|
| // in policy/cloud_policy_generated.cc.
|
| @@ -69,6 +72,7 @@ UserPolicyCache::DiskCache::DiskCache(
|
|
|
| void UserPolicyCache::DiskCache::Load() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + em::LogPolicyOperation(em::kPolicyLoadRequested);
|
| BrowserThread::PostTask(
|
| BrowserThread::FILE, FROM_HERE,
|
| NewRunnableMethod(this, &DiskCache::LoadOnFileThread));
|
| @@ -77,6 +81,7 @@ void UserPolicyCache::DiskCache::Load() {
|
| void UserPolicyCache::DiskCache::Store(
|
| const em::CachedCloudPolicyResponse& policy) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + em::LogPolicyOperation(em::kPolicyStoreRequested);
|
| BrowserThread::PostTask(
|
| BrowserThread::FILE, FROM_HERE,
|
| NewRunnableMethod(this, &DiskCache::StoreOnFileThread, policy));
|
| @@ -92,6 +97,7 @@ void UserPolicyCache::DiskCache::LoadOnFileThread() {
|
| if (!file_util::ReadFileToString(backing_file_path_, &data)) {
|
| LOG(WARNING) << "Failed to read policy data from "
|
| << backing_file_path_.value();
|
| + em::LogPolicyOperation(em::kPolicyLoadFailed);
|
| return;
|
| }
|
|
|
| @@ -100,6 +106,7 @@ void UserPolicyCache::DiskCache::LoadOnFileThread() {
|
| if (!cached_response.ParseFromArray(data.c_str(), data.size())) {
|
| LOG(WARNING) << "Failed to parse policy data read from "
|
| << backing_file_path_.value();
|
| + em::LogPolicyOperation(em::kPolicyLoadFailed);
|
| return;
|
| }
|
|
|
| @@ -124,18 +131,21 @@ void UserPolicyCache::DiskCache::StoreOnFileThread(
|
| std::string data;
|
| if (!policy.SerializeToString(&data)) {
|
| LOG(WARNING) << "Failed to serialize policy data";
|
| + em::LogPolicyOperation(em::kPolicyStoreFailed);
|
| return;
|
| }
|
|
|
| if (!file_util::CreateDirectory(backing_file_path_.DirName())) {
|
| LOG(WARNING) << "Failed to create directory "
|
| << backing_file_path_.DirName().value();
|
| + em::LogPolicyOperation(em::kPolicyStoreFailed);
|
| return;
|
| }
|
|
|
| int size = data.size();
|
| if (file_util::WriteFile(backing_file_path_, data.c_str(), size) != size) {
|
| LOG(WARNING) << "Failed to write " << backing_file_path_.value();
|
| + em::LogPolicyOperation(em::kPolicyStoreFailed);
|
| return;
|
| }
|
| }
|
| @@ -159,6 +169,7 @@ void UserPolicyCache::SetPolicy(const em::PolicyFetchResponse& policy) {
|
| base::Time timestamp;
|
| if (!SetPolicyInternal(policy, ×tamp, false))
|
| return;
|
| + em::LogPolicyOperation(em::kPolicyFetchOK);
|
|
|
| if (timestamp > base::Time::NowFromSystemTime() +
|
| base::TimeDelta::FromMinutes(1)) {
|
|
|