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

Side by Side Diff: chrome/browser/policy/cloud_policy_cache_base.cc

Issue 7105018: UMA metrics for cloud policies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win build, rebased Created 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/policy/cloud_policy_cache_base.h" 5 #include "chrome/browser/policy/cloud_policy_cache_base.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h"
10 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/policy/enterprise_metrics.h"
11 #include "chrome/browser/policy/policy_notifier.h" 13 #include "chrome/browser/policy/policy_notifier.h"
12 14
13 namespace policy { 15 namespace policy {
14 16
15 CloudPolicyCacheBase::CloudPolicyCacheBase() 17 CloudPolicyCacheBase::CloudPolicyCacheBase()
16 : notifier_(NULL), 18 : notifier_(NULL),
17 initialization_complete_(false), 19 initialization_complete_(false),
18 is_unmanaged_(false) { 20 is_unmanaged_(false) {
19 public_key_version_.version = 0; 21 public_key_version_.version = 0;
20 public_key_version_.valid = false; 22 public_key_version_.valid = false;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 bool initialization_was_not_complete = !initialization_complete_; 60 bool initialization_was_not_complete = !initialization_complete_;
59 is_unmanaged_ = false; 61 is_unmanaged_ = false;
60 PolicyMap mandatory_policy; 62 PolicyMap mandatory_policy;
61 PolicyMap recommended_policy; 63 PolicyMap recommended_policy;
62 base::Time temp_timestamp; 64 base::Time temp_timestamp;
63 PublicKeyVersion temp_public_key_version; 65 PublicKeyVersion temp_public_key_version;
64 bool ok = DecodePolicyResponse(policy, &mandatory_policy, &recommended_policy, 66 bool ok = DecodePolicyResponse(policy, &mandatory_policy, &recommended_policy,
65 &temp_timestamp, &temp_public_key_version); 67 &temp_timestamp, &temp_public_key_version);
66 if (!ok) { 68 if (!ok) {
67 LOG(WARNING) << "Decoding policy data failed."; 69 LOG(WARNING) << "Decoding policy data failed.";
70 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchInvalidPolicy,
71 kMetricPolicySize);
68 return false; 72 return false;
69 } 73 }
70 if (timestamp) { 74 if (timestamp) {
71 *timestamp = temp_timestamp; 75 *timestamp = temp_timestamp;
72 } 76 }
73 if (check_for_timestamp_validity && 77 if (check_for_timestamp_validity &&
74 temp_timestamp > base::Time::NowFromSystemTime()) { 78 temp_timestamp > base::Time::NowFromSystemTime()) {
75 LOG(WARNING) << "Rejected policy data, file is from the future."; 79 LOG(WARNING) << "Rejected policy data, file is from the future.";
80 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy,
81 kMetricPolicyFetchTimestampInFuture,
82 kMetricPolicySize);
76 return false; 83 return false;
77 } 84 }
78 public_key_version_.version = temp_public_key_version.version; 85 public_key_version_.version = temp_public_key_version.version;
79 public_key_version_.valid = temp_public_key_version.valid; 86 public_key_version_.valid = temp_public_key_version.valid;
80 87
81 const bool new_policy_differs = 88 const bool new_policy_differs =
82 !mandatory_policy_.Equals(mandatory_policy) || 89 !mandatory_policy_.Equals(mandatory_policy) ||
83 !recommended_policy_.Equals(recommended_policy); 90 !recommended_policy_.Equals(recommended_policy);
84 mandatory_policy_.Swap(&mandatory_policy); 91 mandatory_policy_.Swap(&mandatory_policy);
85 recommended_policy_.Swap(&recommended_policy); 92 recommended_policy_.Swap(&recommended_policy);
86 initialization_complete_ = true; 93 initialization_complete_ = true;
87 94
95 if (!new_policy_differs) {
96 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchNotModified,
97 kMetricPolicySize);
98 }
99
88 if (new_policy_differs || initialization_was_not_complete) { 100 if (new_policy_differs || initialization_was_not_complete) {
89 FOR_EACH_OBSERVER(Observer, observer_list_, OnCacheUpdate(this)); 101 FOR_EACH_OBSERVER(Observer, observer_list_, OnCacheUpdate(this));
90 } 102 }
91 InformNotifier(CloudPolicySubsystem::SUCCESS, 103 InformNotifier(CloudPolicySubsystem::SUCCESS,
92 CloudPolicySubsystem::NO_DETAILS); 104 CloudPolicySubsystem::NO_DETAILS);
93 return true; 105 return true;
94 } 106 }
95 107
96 void CloudPolicyCacheBase::SetUnmanagedInternal(const base::Time& timestamp) { 108 void CloudPolicyCacheBase::SetUnmanagedInternal(const base::Time& timestamp) {
97 is_unmanaged_ = true; 109 is_unmanaged_ = true;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 void CloudPolicyCacheBase::InformNotifier( 144 void CloudPolicyCacheBase::InformNotifier(
133 CloudPolicySubsystem::PolicySubsystemState state, 145 CloudPolicySubsystem::PolicySubsystemState state,
134 CloudPolicySubsystem::ErrorDetails error_details) { 146 CloudPolicySubsystem::ErrorDetails error_details) {
135 // TODO(jkummerow): To obsolete this NULL-check, make all uses of 147 // TODO(jkummerow): To obsolete this NULL-check, make all uses of
136 // UserPolicyCache explicitly set a notifier using |set_policy_notifier()|. 148 // UserPolicyCache explicitly set a notifier using |set_policy_notifier()|.
137 if (notifier_) 149 if (notifier_)
138 notifier_->Inform(state, error_details, PolicyNotifier::POLICY_CACHE); 150 notifier_->Inform(state, error_details, PolicyNotifier::POLICY_CACHE);
139 } 151 }
140 152
141 } // namespace policy 153 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/enterprise_enrollment_screen.cc ('k') | chrome/browser/policy/cloud_policy_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698