Index: chrome/browser/policy/device_policy_cache.cc |
diff --git a/chrome/browser/policy/device_policy_cache.cc b/chrome/browser/policy/device_policy_cache.cc |
index bb9f5339146baade3d10c68e1751dbd27db7f0dd..103e18a2f0ca222144286d827f5ee53d8f93c5df 100644 |
--- a/chrome/browser/policy/device_policy_cache.cc |
+++ b/chrome/browser/policy/device_policy_cache.cc |
@@ -16,6 +16,7 @@ |
#include "chrome/browser/policy/configuration_policy_pref_store.h" |
#include "chrome/browser/policy/device_policy_identity_strategy.h" |
#include "chrome/browser/policy/enterprise_install_attributes.h" |
+#include "chrome/browser/policy/enterprise_metrics.h" |
#include "chrome/browser/policy/policy_map.h" |
#include "chrome/browser/policy/proto/device_management_backend.pb.h" |
#include "chrome/browser/policy/proto/device_management_constants.h" |
@@ -109,6 +110,8 @@ Value* DecodeIntegerValue(google::protobuf::int64 value) { |
namespace policy { |
+namespace em = enterprise_management; |
+ |
DevicePolicyCache::DevicePolicyCache( |
DevicePolicyIdentityStrategy* identity_strategy, |
EnterpriseInstallAttributes* install_attributes) |
@@ -135,6 +138,7 @@ DevicePolicyCache::~DevicePolicyCache() { |
} |
void DevicePolicyCache::Load() { |
+ em::LogPolicyOperation(em::kPolicyLoadRequested); |
signed_settings_helper_->StartRetrievePolicyOp(this); |
} |
@@ -145,6 +149,7 @@ void DevicePolicyCache::SetPolicy(const em::PolicyFetchResponse& policy) { |
std::string registration_user(install_attributes_->GetRegistrationUser()); |
if (registration_user.empty()) { |
LOG(WARNING) << "Refusing to accept policy on non-enterprise device."; |
+ em::LogPolicyOperation(em::kPolicyFetchNonEnterpriseDevice); |
InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, |
CloudPolicySubsystem::POLICY_LOCAL_ERROR); |
return; |
@@ -154,6 +159,7 @@ void DevicePolicyCache::SetPolicy(const em::PolicyFetchResponse& policy) { |
em::PolicyData policy_data; |
if (!policy_data.ParseFromString(policy.policy_data())) { |
LOG(WARNING) << "Invalid policy protobuf"; |
+ em::LogPolicyOperation(em::kPolicyFetchInvalidPolicy); |
InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, |
CloudPolicySubsystem::POLICY_LOCAL_ERROR); |
return; |
@@ -162,6 +168,7 @@ void DevicePolicyCache::SetPolicy(const em::PolicyFetchResponse& policy) { |
if (registration_user != policy_data.username()) { |
LOG(WARNING) << "Refusing policy blob for " << policy_data.username() |
<< " which doesn't match " << registration_user; |
+ em::LogPolicyOperation(em::kPolicyFetchUserMismatch); |
InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, |
CloudPolicySubsystem::POLICY_LOCAL_ERROR); |
return; |
@@ -170,6 +177,7 @@ void DevicePolicyCache::SetPolicy(const em::PolicyFetchResponse& policy) { |
set_last_policy_refresh_time(base::Time::NowFromSystemTime()); |
// Start a store operation. |
+ em::LogPolicyOperation(em::kPolicyStoreRequested); |
new StorePolicyOperation(signed_settings_helper_, |
policy, |
callback_factory_.NewCallback( |
@@ -197,6 +205,7 @@ void DevicePolicyCache::OnRetrievePolicyCompleted( |
em::PolicyData policy_data; |
if (!policy_data.ParseFromString(policy.policy_data())) { |
LOG(WARNING) << "Failed to parse PolicyData protobuf."; |
+ em::LogPolicyOperation(em::kPolicyLoadFailed); |
InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, |
CloudPolicySubsystem::POLICY_LOCAL_ERROR); |
return; |
@@ -212,6 +221,7 @@ void DevicePolicyCache::OnRetrievePolicyCompleted( |
return; |
} |
if (!policy_data.has_username() || !policy_data.has_device_id()) { |
+ em::LogPolicyOperation(em::kPolicyLoadFailed); |
InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, |
CloudPolicySubsystem::POLICY_LOCAL_ERROR); |
return; |
@@ -224,15 +234,20 @@ void DevicePolicyCache::OnRetrievePolicyCompleted( |
} else { // In other words, starting_up_ == false. |
if (code != chromeos::SignedSettings::SUCCESS) { |
if (code == chromeos::SignedSettings::BAD_SIGNATURE) { |
+ em::LogPolicyOperation(em::kPolicyFetchBadSignature); |
InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, |
CloudPolicySubsystem::SIGNATURE_MISMATCH); |
} else { |
+ em::LogPolicyOperation(em::kPolicyFetchOtherFailed); |
InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, |
CloudPolicySubsystem::POLICY_LOCAL_ERROR); |
} |
return; |
} |
- SetPolicyInternal(policy, NULL, false); |
+ bool ok = SetPolicyInternal(policy, NULL, false); |
+ if (ok) { |
+ em::LogPolicyOperation(em::kPolicyFetchOK); |
+ } |
} |
} |
@@ -242,6 +257,7 @@ bool DevicePolicyCache::DecodePolicyData(const em::PolicyData& policy_data, |
em::ChromeDeviceSettingsProto policy; |
if (!policy.ParseFromString(policy_data.policy_value())) { |
LOG(WARNING) << "Failed to parse ChromeDeviceSettingsProto."; |
+ em::LogPolicyOperation(em::kPolicyFetchInvalidPolicy); |
kmixter1
2011/06/28 01:06:02
Is there a user policy equivalent to this or are u
Joao da Silva
2011/06/30 12:57:00
There is an equivalent. Actually both invalid user
|
return false; |
} |
DecodeDevicePolicy(policy, mandatory, recommended); |
@@ -252,10 +268,13 @@ void DevicePolicyCache::PolicyStoreOpCompleted( |
chromeos::SignedSettings::ReturnCode code) { |
DCHECK(CalledOnValidThread()); |
if (code != chromeos::SignedSettings::SUCCESS) { |
+ em::LogPolicyOperation(em::kPolicyStoreFailed); |
if (code == chromeos::SignedSettings::BAD_SIGNATURE) { |
+ em::LogPolicyOperation(em::kPolicyFetchBadSignature); |
InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, |
CloudPolicySubsystem::SIGNATURE_MISMATCH); |
} else { |
+ em::LogPolicyOperation(em::kPolicyFetchOtherFailed); |
InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, |
CloudPolicySubsystem::POLICY_LOCAL_ERROR); |
} |