Home | History | Annotate | Download | only in metrics
      1 // Copyright (c) 2012 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/common/metrics/metrics_service_base.h"
      6 
      7 #include <cstdlib>
      8 
      9 #include "chrome/common/metrics/metrics_log_base.h"
     10 
     11 using base::Histogram;
     12 
     13 MetricsServiceBase::MetricsServiceBase()
     14     : histogram_snapshot_manager_(this) {
     15 }
     16 
     17 MetricsServiceBase::~MetricsServiceBase() {
     18 }
     19 
     20 // static
     21 const char MetricsServiceBase::kServerUrl[] =
     22     "https://clients4.google.com/uma/v2";
     23 
     24 // static
     25 const char MetricsServiceBase::kMimeType[] = "application/vnd.chrome.uma";
     26 
     27 void MetricsServiceBase::RecordCurrentHistograms() {
     28   DCHECK(log_manager_.current_log());
     29   histogram_snapshot_manager_.PrepareDeltas(base::Histogram::kNoFlags, true);
     30 }
     31 
     32 void MetricsServiceBase::RecordDelta(
     33     const base::HistogramBase& histogram,
     34     const base::HistogramSamples& snapshot) {
     35   log_manager_.current_log()->RecordHistogramDelta(histogram.histogram_name(),
     36                                                    snapshot);
     37 }
     38 
     39 void MetricsServiceBase::InconsistencyDetected(
     40     base::HistogramBase::Inconsistency problem) {
     41   UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowser",
     42                             problem, base::HistogramBase::NEVER_EXCEEDED_VALUE);
     43 }
     44 
     45 void MetricsServiceBase::UniqueInconsistencyDetected(
     46     base::HistogramBase::Inconsistency problem) {
     47   UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowserUnique",
     48                             problem, base::HistogramBase::NEVER_EXCEEDED_VALUE);
     49 }
     50 
     51 void MetricsServiceBase::InconsistencyDetectedInLoggedCount(int amount) {
     52   UMA_HISTOGRAM_COUNTS("Histogram.InconsistentSnapshotBrowser",
     53                        std::abs(amount));
     54 }
     55