Chromium Code Reviews| 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..db183e318c7d7a3b872786ae91f04322c53dd81c |
| --- /dev/null |
| +++ b/chrome/browser/policy/policy_load_status.cc |
| @@ -0,0 +1,71 @@ |
| +// 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; |
| +} |
| + |
| +} // namespace |
| + |
| +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
|
| + : histogram_(base::LinearHistogram::FactoryGet( |
| + GetHistogramName(scope, level), 0, POLICY_LOAD_STATUS_SIZE, |
| + POLICY_LOAD_STATUS_SIZE + 1, |
| + base::Histogram::kUmaTargetedHistogramFlag)) { |
| + Add(POLICY_LOAD_STATUS_STARTED); |
| +} |
| + |
| +PolicyLoadStatusSample::~PolicyLoadStatusSample() { |
| + for (int i = 0; i < POLICY_LOAD_STATUS_SIZE; ++i) { |
| + if (status_bits_[i]) { |
| + 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.
|
| + 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
|
| + } |
| + } |
| +} |
| + |
| +void PolicyLoadStatusSample::Add(PolicyLoadStatus status) { |
| + status_bits_[status] = true; |
| +} |
| + |
| +} // namespace policy |