OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/policy/policy_load_status.h" | |
6 | |
7 #include "base/metrics/histogram.h" | |
8 #include "base/stringprintf.h" | |
9 #include "chrome/browser/policy/policy_types.h" | |
10 | |
11 namespace policy { | |
12 | |
13 namespace { | |
14 | |
15 // Histogram Name constants. | |
16 const char kHistogramName[] = "Enterprise.PolicyLoadStatus"; | |
17 const char kHistogramNameNone[] = "none"; | |
18 const char kHistogramNameScopeMachine[] = "machine"; | |
19 const char kHistogramNameScopeUser[] = "user"; | |
20 const char kHistogramNameLevelMandatory[] = "mandatory"; | |
21 const char kHistogramNameLevelRecommended[] = "recommended"; | |
22 | |
23 // Gets the name of the histogram to send the sample to. | |
24 std::string GetHistogramName(int scope, int level) { | |
25 const char* scope_name = kHistogramNameNone; | |
26 switch (scope) { | |
27 case POLICY_SCOPE_MACHINE: | |
28 scope_name = kHistogramNameScopeMachine; | |
29 break; | |
30 case POLICY_SCOPE_USER: | |
31 scope_name = kHistogramNameScopeUser; | |
32 break; | |
33 } | |
34 | |
35 const char* level_name = kHistogramNameNone; | |
36 switch (level) { | |
37 case POLICY_LEVEL_MANDATORY: | |
38 level_name = kHistogramNameLevelMandatory; | |
39 break; | |
40 case POLICY_LEVEL_RECOMMENDED: | |
41 level_name = kHistogramNameLevelRecommended; | |
42 break; | |
43 } | |
44 | |
45 return std::string(kHistogramName) + "_" + scope_name + "_" + level_name; | |
46 } | |
47 | |
48 } | |
Joao da Silva
2013/04/16 17:31:04
// namespace
Mattias Nissler (ping if slow)
2013/04/16 18:51:14
Done.
| |
49 | |
50 PolicyLoadStatusSample::PolicyLoadStatusSample(int scope, int level) | |
51 : histogram_(base::LinearHistogram::FactoryGet( | |
52 GetHistogramName(scope, level), 1, POLICY_LOAD_STATUS_SIZE, | |
53 POLICY_LOAD_STATUS_SIZE, base::Histogram::kUmaTargetedHistogramFlag)) { | |
54 Add(POLICY_LOAD_STATUS_STARTED); | |
55 } | |
56 | |
57 void PolicyLoadStatusSample::Add(PolicyLoadStatus status) { | |
58 histogram_->Add(status); | |
59 } | |
60 | |
61 } // namespace policy | |
OLD | NEW |