diff options
author | kaiwang@chromium.org <kaiwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-01 21:34:08 +0000 |
---|---|---|
committer | kaiwang@chromium.org <kaiwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-01 21:34:08 +0000 |
commit | 34d062327516ae2496646d4c4d644e0e12386a3d (patch) | |
tree | d92e5703447f10aea57b1bdcfea060600252be9b /net/disk_cache | |
parent | ba125e774ed899bd119bcd9abd47dab68857315b (diff) | |
download | chromium_src-34d062327516ae2496646d4c4d644e0e12386a3d.zip chromium_src-34d062327516ae2496646d4c4d644e0e12386a3d.tar.gz chromium_src-34d062327516ae2496646d4c4d644e0e12386a3d.tar.bz2 |
This is a major refactor of Histogram related code:
1. Remove duplicated code from histogram.h/.cc,
including validating related code and BucketRanges related.
2. Constness of BucketRanges from Histograms, to prevent accidentally modification and provide a simpler interface.
3. Add/move tests.
Review URL: https://chromiumcodereview.appspot.com/10834011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149495 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r-- | net/disk_cache/stats_histogram.cc | 12 | ||||
-rw-r--r-- | net/disk_cache/stats_histogram.h | 11 |
2 files changed, 7 insertions, 16 deletions
diff --git a/net/disk_cache/stats_histogram.cc b/net/disk_cache/stats_histogram.cc index 66c8e50..d3bab34 100644 --- a/net/disk_cache/stats_histogram.cc +++ b/net/disk_cache/stats_histogram.cc @@ -33,20 +33,16 @@ StatsHistogram* StatsHistogram::FactoryGet(const std::string& name) { // To avoid racy destruction at shutdown, the following will be leaked. StatsHistogram* stats_histogram = new StatsHistogram(name, minimum, maximum, bucket_count); - stats_histogram->InitializeBucketRange(); stats_histogram->SetFlags(kUmaTargetedHistogramFlag); histogram = StatisticsRecorder::RegisterOrDeleteDuplicate(stats_histogram); } DCHECK(HISTOGRAM == histogram->histogram_type()); - DCHECK(histogram->HasConstructorArguments(minimum, maximum, bucket_count)); + 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<StatsHistogram*>(histogram); - // Validate upcast by seeing that we're probably providing the checksum. - CHECK_EQ(return_histogram->StatsHistogram::CalculateRangeChecksum(), - return_histogram->CalculateRangeChecksum()); return return_histogram; } @@ -87,10 +83,4 @@ Histogram::Inconsistencies StatsHistogram::FindCorruption( return NO_INCONSISTENCIES; // This class won't monitor inconsistencies. } -uint32 StatsHistogram::CalculateRangeChecksum() const { - // We don't calculate checksums, so at least establish a unique constant. - const uint32 kStatsHistogramChecksum = 0x0cecce; - return kStatsHistogramChecksum; -} - } // namespace disk_cache diff --git a/net/disk_cache/stats_histogram.h b/net/disk_cache/stats_histogram.h index 97b2d401..f3af304 100644 --- a/net/disk_cache/stats_histogram.h +++ b/net/disk_cache/stats_histogram.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// 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. @@ -29,9 +29,11 @@ class StatsHistogram : public base::Histogram { } }; - StatsHistogram(const std::string& name, Sample minimum, - Sample maximum, size_t bucket_count) - : Histogram(name, minimum, maximum, bucket_count), init_(false) {} + StatsHistogram(const std::string& name, + Sample minimum, + Sample maximum, + size_t bucket_count) + : Histogram(name, minimum, maximum, bucket_count, NULL), init_(false) {} virtual ~StatsHistogram(); static StatsHistogram* FactoryGet(const std::string& name); @@ -44,7 +46,6 @@ class StatsHistogram : public base::Histogram { virtual void SnapshotSample(SampleSet* sample) const OVERRIDE; virtual Inconsistencies FindCorruption( const SampleSet& snapshot) const OVERRIDE; - virtual uint32 CalculateRangeChecksum() const OVERRIDE; private: bool init_; |