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

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: Addressed comments, 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_.valid = false; 21 public_key_version_.valid = false;
20 } 22 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 bool initialization_was_not_complete = !initialization_complete_; 59 bool initialization_was_not_complete = !initialization_complete_;
58 is_unmanaged_ = false; 60 is_unmanaged_ = false;
59 PolicyMap mandatory_policy; 61 PolicyMap mandatory_policy;
60 PolicyMap recommended_policy; 62 PolicyMap recommended_policy;
61 base::Time temp_timestamp; 63 base::Time temp_timestamp;
62 PublicKeyVersion temp_public_key_version; 64 PublicKeyVersion temp_public_key_version;
63 bool ok = DecodePolicyResponse(policy, &mandatory_policy, &recommended_policy, 65 bool ok = DecodePolicyResponse(policy, &mandatory_policy, &recommended_policy,
64 &temp_timestamp, &temp_public_key_version); 66 &temp_timestamp, &temp_public_key_version);
65 if (!ok) { 67 if (!ok) {
66 LOG(WARNING) << "Decoding policy data failed."; 68 LOG(WARNING) << "Decoding policy data failed.";
69 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchInvalidPolicy,
70 kMetricPolicySize);
67 return false; 71 return false;
68 } 72 }
69 if (timestamp) { 73 if (timestamp) {
70 *timestamp = temp_timestamp; 74 *timestamp = temp_timestamp;
71 } 75 }
72 if (check_for_timestamp_validity && 76 if (check_for_timestamp_validity &&
73 temp_timestamp > base::Time::NowFromSystemTime()) { 77 temp_timestamp > base::Time::NowFromSystemTime()) {
74 LOG(WARNING) << "Rejected policy data, file is from the future."; 78 LOG(WARNING) << "Rejected policy data, file is from the future.";
79 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy,
80 kMetricPolicyFetchTimestampInFuture,
81 kMetricPolicySize);
75 return false; 82 return false;
76 } 83 }
77 public_key_version_.version = temp_public_key_version.version; 84 public_key_version_.version = temp_public_key_version.version;
78 public_key_version_.valid = temp_public_key_version.valid; 85 public_key_version_.valid = temp_public_key_version.valid;
79 86
80 const bool new_policy_differs = 87 const bool new_policy_differs =
81 !mandatory_policy_.Equals(mandatory_policy) || 88 !mandatory_policy_.Equals(mandatory_policy) ||
82 !recommended_policy_.Equals(recommended_policy); 89 !recommended_policy_.Equals(recommended_policy);
83 mandatory_policy_.Swap(&mandatory_policy); 90 mandatory_policy_.Swap(&mandatory_policy);
84 recommended_policy_.Swap(&recommended_policy); 91 recommended_policy_.Swap(&recommended_policy);
85 initialization_complete_ = true; 92 initialization_complete_ = true;
86 93
94 if (!new_policy_differs) {
95 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchNotModified,
96 kMetricPolicySize);
97 }
98
87 if (new_policy_differs || initialization_was_not_complete) { 99 if (new_policy_differs || initialization_was_not_complete) {
88 FOR_EACH_OBSERVER(Observer, observer_list_, OnCacheUpdate(this)); 100 FOR_EACH_OBSERVER(Observer, observer_list_, OnCacheUpdate(this));
89 } 101 }
90 InformNotifier(CloudPolicySubsystem::SUCCESS, 102 InformNotifier(CloudPolicySubsystem::SUCCESS,
91 CloudPolicySubsystem::NO_DETAILS); 103 CloudPolicySubsystem::NO_DETAILS);
92 return true; 104 return true;
93 } 105 }
94 106
95 void CloudPolicyCacheBase::SetUnmanagedInternal(const base::Time& timestamp) { 107 void CloudPolicyCacheBase::SetUnmanagedInternal(const base::Time& timestamp) {
96 is_unmanaged_ = true; 108 is_unmanaged_ = true;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 void CloudPolicyCacheBase::InformNotifier( 143 void CloudPolicyCacheBase::InformNotifier(
132 CloudPolicySubsystem::PolicySubsystemState state, 144 CloudPolicySubsystem::PolicySubsystemState state,
133 CloudPolicySubsystem::ErrorDetails error_details) { 145 CloudPolicySubsystem::ErrorDetails error_details) {
134 // TODO(jkummerow): To obsolete this NULL-check, make all uses of 146 // TODO(jkummerow): To obsolete this NULL-check, make all uses of
135 // UserPolicyCache explicitly set a notifier using |set_policy_notifier()|. 147 // UserPolicyCache explicitly set a notifier using |set_policy_notifier()|.
136 if (notifier_) 148 if (notifier_)
137 notifier_->Inform(state, error_details, PolicyNotifier::POLICY_CACHE); 149 notifier_->Inform(state, error_details, PolicyNotifier::POLICY_CACHE);
138 } 150 }
139 151
140 } // namespace policy 152 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698