From db1156813ca4e0c82a36bb1ded160f00f579b1c6 Mon Sep 17 00:00:00 2001 From: "gavinp@chromium.org" Date: Wed, 26 Feb 2014 20:23:43 +0000 Subject: Reorganize net/disk_cache into backend specific directories. We want to unlink the blockfile cache on Android, and it seems that we'll want more platforms with more varieties of backend in the future. So let's move the backend into its own subdirectory as we start to untangle the dependencies from tests/etc... into their respective backends. This initial checkin isn't perfect; in particular the tests have a lot of v2 specific dependencies still. R=rvargas@chromium.org, cbentzel, rvargas BUG=331062 Review URL: https://codereview.chromium.org/121643003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253581 0039d316-1c4b-4281-b951-d872f2087c98 --- net/disk_cache/stats_histogram.cc | 94 --------------------------------------- 1 file changed, 94 deletions(-) delete mode 100644 net/disk_cache/stats_histogram.cc (limited to 'net/disk_cache/stats_histogram.cc') diff --git a/net/disk_cache/stats_histogram.cc b/net/disk_cache/stats_histogram.cc deleted file mode 100644 index 2a67550..0000000 --- a/net/disk_cache/stats_histogram.cc +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 2012 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 "net/disk_cache/stats_histogram.h" - -#include "base/debug/leak_annotations.h" -#include "base/logging.h" -#include "base/metrics/bucket_ranges.h" -#include "base/metrics/histogram_base.h" -#include "base/metrics/sample_vector.h" -#include "base/metrics/statistics_recorder.h" -#include "net/disk_cache/stats.h" - -namespace disk_cache { - -using base::BucketRanges; -using base::Histogram; -using base::HistogramSamples; -using base::SampleVector; -using base::StatisticsRecorder; - -StatsHistogram::StatsHistogram(const std::string& name, - Sample minimum, - Sample maximum, - const BucketRanges* ranges, - const Stats* stats) - : Histogram(name, minimum, maximum, ranges), - stats_(stats) {} - -StatsHistogram::~StatsHistogram() {} - -// static -void StatsHistogram::InitializeBucketRanges(const Stats* stats, - BucketRanges* ranges) { - for (size_t i = 0; i < ranges->size(); ++i) { - ranges->set_range(i, stats->GetBucketRange(i)); - } - ranges->ResetChecksum(); -} - -StatsHistogram* StatsHistogram::FactoryGet(const std::string& name, - const Stats* stats) { - Sample minimum = 1; - Sample maximum = disk_cache::Stats::kDataSizesLength - 1; - size_t bucket_count = disk_cache::Stats::kDataSizesLength; - HistogramBase* histogram = StatisticsRecorder::FindHistogram(name); - if (!histogram) { - DCHECK(stats); - - // To avoid racy destruction at shutdown, the following will be leaked. - BucketRanges* ranges = new BucketRanges(bucket_count + 1); - InitializeBucketRanges(stats, ranges); - const BucketRanges* registered_ranges = - StatisticsRecorder::RegisterOrDeleteDuplicateRanges(ranges); - - // To avoid racy destruction at shutdown, the following will be leaked. - StatsHistogram* stats_histogram = - new StatsHistogram(name, minimum, maximum, registered_ranges, stats); - stats_histogram->SetFlags(kUmaTargetedHistogramFlag); - histogram = StatisticsRecorder::RegisterOrDeleteDuplicate(stats_histogram); - } - - DCHECK(base::HISTOGRAM == histogram->GetHistogramType()); - DCHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count)); - - // We're preparing for an otherwise unsafe upcast by ensuring we have the - // proper class type. - StatsHistogram* return_histogram = static_cast(histogram); - return return_histogram; -} - -void StatsHistogram::Disable() { - stats_ = NULL; -} - -scoped_ptr StatsHistogram::SnapshotSamples() const { - scoped_ptr samples(new SampleVector(bucket_ranges())); - if (stats_) - stats_->Snapshot(samples.get()); - - // Only report UMA data once. - StatsHistogram* mutable_me = const_cast(this); - mutable_me->ClearFlags(kUmaTargetedHistogramFlag); - - return samples.PassAs(); -} - -int StatsHistogram::FindCorruption(const HistogramSamples& samples) const { - // This class won't monitor inconsistencies. - return HistogramBase::NO_INCONSISTENCIES; -} - -} // namespace disk_cache -- cgit v1.1