blob: 9d44545b3768030bb2871a523a695857619ab379 [file] [log] [blame]
// Copyright (c) 2011 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.
#pragma once
#include <string>
#include "base/metrics/histogram.h"
namespace disk_cache {
class Stats;
// This class provides support for sending the disk cache size stats as a UMA
// histogram. We'll provide our own storage and management for the data, and a
// SampleSet with a copy of our data.
// Class derivation of Histogram "deprecated," and should not be copied, and
// may eventually go away.
class StatsHistogram : public base::Histogram {
class StatsSamples : public SampleSet {
Counts* GetCounts() {
return &counts_;
StatsHistogram(const std::string& name, Sample minimum,
Sample maximum, size_t bucket_count)
: Histogram(name, minimum, maximum, bucket_count), init_(false) {}
virtual ~StatsHistogram();
static StatsHistogram* FactoryGet(const std::string& name);
// We'll be reporting data from the given set of cache stats.
bool Init(const Stats* stats);
virtual Sample ranges(size_t i) const OVERRIDE;
virtual size_t bucket_count() const OVERRIDE;
virtual void SnapshotSample(SampleSet* sample) const OVERRIDE;
virtual Inconsistencies FindCorruption(
const SampleSet& snapshot) const OVERRIDE;
virtual uint32 CalculateRangeChecksum() const OVERRIDE;
bool init_;
static const Stats* stats_;
} // namespace disk_cache