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

Unified Diff: chrome/browser/policy/policy_load_status.cc

Issue 14294008: Add UMA histograms for policy loading. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/policy_load_status.cc
diff --git a/chrome/browser/policy/policy_load_status.cc b/chrome/browser/policy/policy_load_status.cc
new file mode 100644
index 0000000000000000000000000000000000000000..aa1de8c1ed2b45ed7e1a480d9a8f640c4b532f14
--- /dev/null
+++ b/chrome/browser/policy/policy_load_status.cc
@@ -0,0 +1,61 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/policy/policy_load_status.h"
+
+#include "base/metrics/histogram.h"
+#include "base/stringprintf.h"
+#include "chrome/browser/policy/policy_types.h"
+
+namespace policy {
+
+namespace {
+
+// Histogram Name constants.
+const char kHistogramName[] = "Enterprise.PolicyLoadStatus";
+const char kHistogramNameNone[] = "none";
+const char kHistogramNameScopeMachine[] = "machine";
+const char kHistogramNameScopeUser[] = "user";
+const char kHistogramNameLevelMandatory[] = "mandatory";
+const char kHistogramNameLevelRecommended[] = "recommended";
+
+// Gets the name of the histogram to send the sample to.
+std::string GetHistogramName(int scope, int level) {
+ const char* scope_name = kHistogramNameNone;
+ switch (scope) {
+ case POLICY_SCOPE_MACHINE:
+ scope_name = kHistogramNameScopeMachine;
+ break;
+ case POLICY_SCOPE_USER:
+ scope_name = kHistogramNameScopeUser;
+ break;
+ }
+
+ const char* level_name = kHistogramNameNone;
+ switch (level) {
+ case POLICY_LEVEL_MANDATORY:
+ level_name = kHistogramNameLevelMandatory;
+ break;
+ case POLICY_LEVEL_RECOMMENDED:
+ level_name = kHistogramNameLevelRecommended;
+ break;
+ }
+
+ return std::string(kHistogramName) + "_" + scope_name + "_" + level_name;
+}
+
+}
Joao da Silva 2013/04/16 17:31:04 // namespace
Mattias Nissler (ping if slow) 2013/04/16 18:51:14 Done.
+
+PolicyLoadStatusSample::PolicyLoadStatusSample(int scope, int level)
+ : histogram_(base::LinearHistogram::FactoryGet(
+ GetHistogramName(scope, level), 1, POLICY_LOAD_STATUS_SIZE,
+ POLICY_LOAD_STATUS_SIZE, base::Histogram::kUmaTargetedHistogramFlag)) {
+ Add(POLICY_LOAD_STATUS_STARTED);
+}
+
+void PolicyLoadStatusSample::Add(PolicyLoadStatus status) {
+ histogram_->Add(status);
+}
+
+} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698