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 } // namespace | |
49 | |
50 PolicyLoadStatusSample::PolicyLoadStatusSample(int scope, int level) | |
jar (doing other things)
2013/04/16 19:32:11
Just to be sure I'm following.... you'll potential
Mattias Nissler (ping if slow)
2013/04/17 10:16:35
Correct, the intent was to distinguish load operat
| |
51 : histogram_(base::LinearHistogram::FactoryGet( | |
52 GetHistogramName(scope, level), 0, POLICY_LOAD_STATUS_SIZE, | |
53 POLICY_LOAD_STATUS_SIZE + 1, | |
54 base::Histogram::kUmaTargetedHistogramFlag)) { | |
55 Add(POLICY_LOAD_STATUS_STARTED); | |
56 } | |
57 | |
58 PolicyLoadStatusSample::~PolicyLoadStatusSample() { | |
59 for (int i = 0; i < POLICY_LOAD_STATUS_SIZE; ++i) { | |
60 if (status_bits_[i]) { | |
61 LOG(ERROR) << "sampling " << i; | |
jar (doing other things)
2013/04/16 19:32:11
nit: use DLOG, as this probably won't be helpful t
Joao da Silva
2013/04/16 19:32:57
Please remove this, or make it a VLOG.
Mattias Nissler (ping if slow)
2013/04/17 10:16:35
Doh, debugging artifact. Fixed.
| |
62 histogram_->Add(i); | |
jar (doing other things)
2013/04/16 19:32:11
I was curious about why you put this into a bit ve
Mattias Nissler (ping if slow)
2013/04/17 10:16:35
Yes, that's exactly the reason. We may loop over m
| |
63 } | |
64 } | |
65 } | |
66 | |
67 void PolicyLoadStatusSample::Add(PolicyLoadStatus status) { | |
68 status_bits_[status] = true; | |
69 } | |
70 | |
71 } // namespace policy | |
OLD | NEW |