| Index: components/policy/core/common/policy_load_status.cc
|
| diff --git a/components/policy/core/common/policy_load_status.cc b/components/policy/core/common/policy_load_status.cc
|
| index 71c5059a7fd338f7897d0a4bf318e10b2337903a..22870beaa545feadcaaa2df65e71ff693ab61954 100644
|
| --- a/components/policy/core/common/policy_load_status.cc
|
| +++ b/components/policy/core/common/policy_load_status.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "components/policy/core/common/policy_load_status.h"
|
|
|
| +#include "base/bind.h"
|
| #include "base/metrics/histogram.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "components/policy/core/common/policy_types.h"
|
| @@ -14,20 +15,31 @@ namespace {
|
|
|
| const char kHistogramName[] = "Enterprise.PolicyLoadStatus";
|
|
|
| +void ReportPolicyLoadStatus(base::HistogramBase* histogram,
|
| + PolicyLoadStatus status) {
|
| + histogram->Add(status);
|
| +}
|
| +
|
| } // namespace
|
|
|
| -PolicyLoadStatusSample::PolicyLoadStatusSample()
|
| - : histogram_(base::LinearHistogram::FactoryGet(
|
| - kHistogramName, 1, POLICY_LOAD_STATUS_SIZE,
|
| - POLICY_LOAD_STATUS_SIZE + 1,
|
| - base::Histogram::kUmaTargetedHistogramFlag)) {
|
| +PolicyLoadStatusSample::PolicyLoadStatusSample(
|
| + const ReportCallback& report_callback)
|
| + : report_callback_(report_callback) {
|
| + // Report to a base::LinearHistogram by default.
|
| + if (report_callback_.is_null()) {
|
| + base::HistogramBase* histogram(base::LinearHistogram::FactoryGet(
|
| + kHistogramName, 1, POLICY_LOAD_STATUS_SIZE, POLICY_LOAD_STATUS_SIZE + 1,
|
| + base::Histogram::kUmaTargetedHistogramFlag));
|
| + report_callback_ = base::Bind(&ReportPolicyLoadStatus, histogram);
|
| + }
|
| +
|
| Add(POLICY_LOAD_STATUS_STARTED);
|
| }
|
|
|
| PolicyLoadStatusSample::~PolicyLoadStatusSample() {
|
| for (int i = 0; i < POLICY_LOAD_STATUS_SIZE; ++i) {
|
| if (status_bits_[i])
|
| - histogram_->Add(i);
|
| + report_callback_.Run(static_cast<PolicyLoadStatus>(i));
|
| }
|
| }
|
|
|
|
|