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

Side by Side Diff: components/policy/core/common/policy_load_status.cc

Issue 2860973002: Allow PolicyLoadStatusSample to override reporting method (Closed)
Patch Set: Cleanups and class rename. Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/policy/core/common/policy_load_status.h" 5 #include "components/policy/core/common/policy_load_status.h"
6 6
7 #include "base/bind.h"
7 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
8 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
9 #include "components/policy/core/common/policy_types.h" 10 #include "components/policy/core/common/policy_types.h"
10 11
11 namespace policy { 12 namespace policy {
12 13
13 namespace { 14 namespace {
14 15
15 const char kHistogramName[] = "Enterprise.PolicyLoadStatus"; 16 const char kHistogramName[] = "Enterprise.PolicyLoadStatus";
16 17
17 } // namespace 18 } // namespace
18 19
19 PolicyLoadStatusSample::PolicyLoadStatusSample() 20 PolicyLoadStatusSampler::PolicyLoadStatusSampler() {
20 : histogram_(base::LinearHistogram::FactoryGet(
21 kHistogramName, 1, POLICY_LOAD_STATUS_SIZE,
22 POLICY_LOAD_STATUS_SIZE + 1,
23 base::Histogram::kUmaTargetedHistogramFlag)) {
24 Add(POLICY_LOAD_STATUS_STARTED); 21 Add(POLICY_LOAD_STATUS_STARTED);
25 } 22 }
26 23
27 PolicyLoadStatusSample::~PolicyLoadStatusSample() { 24 PolicyLoadStatusSampler::~PolicyLoadStatusSampler() {}
25
26 void PolicyLoadStatusSampler::Add(PolicyLoadStatus status) {
27 status_bits_[status] = true;
28 }
29
30 PolicyLoadStatusUmaReporter::PolicyLoadStatusUmaReporter() {}
31
32 PolicyLoadStatusUmaReporter::~PolicyLoadStatusUmaReporter() {
33 base::HistogramBase* histogram(base::LinearHistogram::FactoryGet(
34 kHistogramName, 1, POLICY_LOAD_STATUS_SIZE, POLICY_LOAD_STATUS_SIZE + 1,
35 base::Histogram::kUmaTargetedHistogramFlag));
36
28 for (int i = 0; i < POLICY_LOAD_STATUS_SIZE; ++i) { 37 for (int i = 0; i < POLICY_LOAD_STATUS_SIZE; ++i) {
29 if (status_bits_[i]) 38 if (GetStatusSet()[i])
30 histogram_->Add(i); 39 histogram->Add(i);
31 } 40 }
32 } 41 }
33 42
34 void PolicyLoadStatusSample::Add(PolicyLoadStatus status) {
35 status_bits_[status] = true;
36 }
37
38 } // namespace policy 43 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/policy_load_status.h ('k') | components/policy/core/common/policy_loader_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698