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

Side by Side Diff: chrome/browser/policy/user_policy_cache.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/user_policy_cache.h" 5 #include "chrome/browser/policy/user_policy_cache.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/histogram.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/policy/browser_policy_connector.h" 15 #include "chrome/browser/policy/browser_policy_connector.h"
15 #include "chrome/browser/policy/cloud_policy_provider.h" 16 #include "chrome/browser/policy/cloud_policy_provider.h"
17 #include "chrome/browser/policy/enterprise_metrics.h"
16 #include "chrome/browser/policy/policy_map.h" 18 #include "chrome/browser/policy/policy_map.h"
17 #include "chrome/browser/policy/proto/cloud_policy.pb.h" 19 #include "chrome/browser/policy/proto/cloud_policy.pb.h"
18 #include "chrome/browser/policy/proto/device_management_local.pb.h" 20 #include "chrome/browser/policy/proto/device_management_local.pb.h"
19 #include "chrome/browser/policy/proto/old_generic_format.pb.h" 21 #include "chrome/browser/policy/proto/old_generic_format.pb.h"
20 #include "policy/configuration_policy_type.h" 22 #include "policy/configuration_policy_type.h"
21 23
22 namespace policy { 24 namespace policy {
23 25
24 // Decodes a CloudPolicySettings object into two maps with mandatory and 26 // Decodes a CloudPolicySettings object into two maps with mandatory and
25 // recommended settings, respectively. The implementation is generated code 27 // recommended settings, respectively. The implementation is generated code
(...skipping 14 matching lines...) Expand all
40 void UserPolicyCache::Load() { 42 void UserPolicyCache::Load() {
41 disk_cache_->Load(); 43 disk_cache_->Load();
42 } 44 }
43 45
44 void UserPolicyCache::SetPolicy(const em::PolicyFetchResponse& policy) { 46 void UserPolicyCache::SetPolicy(const em::PolicyFetchResponse& policy) {
45 base::Time now = base::Time::NowFromSystemTime(); 47 base::Time now = base::Time::NowFromSystemTime();
46 set_last_policy_refresh_time(now); 48 set_last_policy_refresh_time(now);
47 base::Time timestamp; 49 base::Time timestamp;
48 if (!SetPolicyInternal(policy, &timestamp, false)) 50 if (!SetPolicyInternal(policy, &timestamp, false))
49 return; 51 return;
52 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchOK,
53 kMetricPolicySize);
50 54
51 if (timestamp > base::Time::NowFromSystemTime() + 55 if (timestamp > base::Time::NowFromSystemTime() +
52 base::TimeDelta::FromMinutes(1)) { 56 base::TimeDelta::FromMinutes(1)) {
53 LOG(WARNING) << "Server returned policy with timestamp from the future, " 57 LOG(WARNING) << "Server returned policy with timestamp from the future, "
54 "not persisting to disk."; 58 "not persisting to disk.";
55 return; 59 return;
56 } 60 }
57 61
58 em::CachedCloudPolicyResponse cached_policy; 62 em::CachedCloudPolicyResponse cached_policy;
59 cached_policy.mutable_cloud_policy()->CopyFrom(policy); 63 cached_policy.mutable_cloud_policy()->CopyFrom(policy);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 return list; 239 return list;
236 } 240 }
237 default: 241 default:
238 NOTREACHED() << "Unhandled value type"; 242 NOTREACHED() << "Unhandled value type";
239 } 243 }
240 244
241 return NULL; 245 return NULL;
242 } 246 }
243 247
244 } // namespace policy 248 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/enterprise_metrics.cc ('k') | chrome/browser/policy/user_policy_disk_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698