summaryrefslogtreecommitdiffstats
path: root/chrome/browser/policy/policy_load_status.cc
blob: 62cead273fbe6a6a9cf832082f58f8e3413bc85a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// 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/strings/stringprintf.h"
#include "chrome/browser/policy/policy_types.h"

namespace policy {

namespace {

const char kHistogramName[] = "Enterprise.PolicyLoadStatus";

}  // namespace

PolicyLoadStatusSample::PolicyLoadStatusSample()
    : histogram_(base::LinearHistogram::FactoryGet(
          kHistogramName, 1, 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])
      histogram_->Add(i);
  }
}

void PolicyLoadStatusSample::Add(PolicyLoadStatus status) {
  status_bits_[status] = true;
}

}  // namespace policy