Connect SparseHistogram with the rest of stats system
With this CL, SparseHistogram is usable with SparseHistogram::FactoryGet. Next step is to implement a Histogram like macro and implement WriteHTMLGraph and WriteAscii to have a nice output. BUG=139612 Review URL: https://chromiumcodereview.appspot.com/12207058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185451 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
base/metrics
histogram.cchistogram.hhistogram_base.cchistogram_base.hhistogram_base_unittest.cchistogram_flattener.hhistogram_snapshot_manager.cchistogram_snapshot_manager.hhistogram_unittest.ccsparse_histogram.ccstatistics_recorder.ccstatistics_recorder.h
chrome
browser
common
test
content
browser
common
renderer
dbus
net
disk_cache
socket_stream
url_request
@ -84,29 +84,6 @@ typedef HistogramBase::Sample Sample;
|
||||
// static
|
||||
const size_t Histogram::kBucketCount_MAX = 16384u;
|
||||
|
||||
// TODO(rtenneti): delete this code after debugging.
|
||||
void CheckCorruption(const Histogram& histogram, bool new_histogram) {
|
||||
const std::string& histogram_name = histogram.histogram_name();
|
||||
char histogram_name_buf[128];
|
||||
base::strlcpy(histogram_name_buf,
|
||||
histogram_name.c_str(),
|
||||
arraysize(histogram_name_buf));
|
||||
base::debug::Alias(histogram_name_buf);
|
||||
|
||||
bool debug_new_histogram[1];
|
||||
debug_new_histogram[0] = new_histogram;
|
||||
base::debug::Alias(debug_new_histogram);
|
||||
|
||||
Sample previous_range = -1; // Bottom range is always 0.
|
||||
for (size_t index = 0; index < histogram.bucket_count(); ++index) {
|
||||
int new_range = histogram.ranges(index);
|
||||
CHECK_LT(previous_range, new_range);
|
||||
previous_range = new_range;
|
||||
}
|
||||
|
||||
CHECK(histogram.bucket_ranges()->HasValidChecksum());
|
||||
}
|
||||
|
||||
HistogramBase* Histogram::FactoryGet(const string& name,
|
||||
Sample minimum,
|
||||
Sample maximum,
|
||||
@ -116,7 +93,7 @@ HistogramBase* Histogram::FactoryGet(const string& name,
|
||||
InspectConstructionArguments(name, &minimum, &maximum, &bucket_count);
|
||||
DCHECK(valid_arguments);
|
||||
|
||||
Histogram* histogram = StatisticsRecorder::FindHistogram(name);
|
||||
HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
|
||||
if (!histogram) {
|
||||
// To avoid racy destruction at shutdown, the following will be leaked.
|
||||
BucketRanges* ranges = new BucketRanges(bucket_count + 1);
|
||||
@ -126,16 +103,13 @@ HistogramBase* Histogram::FactoryGet(const string& name,
|
||||
|
||||
Histogram* tentative_histogram =
|
||||
new Histogram(name, minimum, maximum, bucket_count, registered_ranges);
|
||||
CheckCorruption(*tentative_histogram, true);
|
||||
|
||||
tentative_histogram->SetFlags(flags);
|
||||
histogram =
|
||||
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
|
||||
}
|
||||
// TODO(rtenneti): delete this code after debugging.
|
||||
CheckCorruption(*histogram, false);
|
||||
|
||||
CHECK_EQ(HISTOGRAM, histogram->GetHistogramType());
|
||||
DCHECK_EQ(HISTOGRAM, histogram->GetHistogramType());
|
||||
CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
|
||||
return histogram;
|
||||
}
|
||||
@ -200,8 +174,7 @@ void Histogram::InitializeBucketRanges(Sample minimum,
|
||||
// static
|
||||
const int Histogram::kCommonRaceBasedCountMismatch = 5;
|
||||
|
||||
Histogram::Inconsistencies Histogram::FindCorruption(
|
||||
const HistogramSamples& samples) const {
|
||||
int Histogram::FindCorruption(const HistogramSamples& samples) const {
|
||||
int inconsistencies = NO_INCONSISTENCIES;
|
||||
Sample previous_range = -1; // Bottom range is always 0.
|
||||
for (size_t index = 0; index < bucket_count(); ++index) {
|
||||
@ -230,7 +203,7 @@ Histogram::Inconsistencies Histogram::FindCorruption(
|
||||
inconsistencies |= COUNT_LOW_ERROR;
|
||||
}
|
||||
}
|
||||
return static_cast<Inconsistencies>(inconsistencies);
|
||||
return inconsistencies;
|
||||
}
|
||||
|
||||
Sample Histogram::ranges(size_t i) const {
|
||||
@ -599,7 +572,7 @@ HistogramBase* LinearHistogram::FactoryGetWithRangeDescription(
|
||||
name, &minimum, &maximum, &bucket_count);
|
||||
DCHECK(valid_arguments);
|
||||
|
||||
Histogram* histogram = StatisticsRecorder::FindHistogram(name);
|
||||
HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
|
||||
if (!histogram) {
|
||||
// To avoid racy destruction at shutdown, the following will be leaked.
|
||||
BucketRanges* ranges = new BucketRanges(bucket_count + 1);
|
||||
@ -610,7 +583,6 @@ HistogramBase* LinearHistogram::FactoryGetWithRangeDescription(
|
||||
LinearHistogram* tentative_histogram =
|
||||
new LinearHistogram(name, minimum, maximum, bucket_count,
|
||||
registered_ranges);
|
||||
CheckCorruption(*tentative_histogram, true);
|
||||
|
||||
// Set range descriptions.
|
||||
if (descriptions) {
|
||||
@ -624,10 +596,8 @@ HistogramBase* LinearHistogram::FactoryGetWithRangeDescription(
|
||||
histogram =
|
||||
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
|
||||
}
|
||||
// TODO(rtenneti): delete this code after debugging.
|
||||
CheckCorruption(*histogram, false);
|
||||
|
||||
CHECK_EQ(LINEAR_HISTOGRAM, histogram->GetHistogramType());
|
||||
DCHECK_EQ(LINEAR_HISTOGRAM, histogram->GetHistogramType());
|
||||
CHECK(histogram->HasConstructionArguments(minimum, maximum, bucket_count));
|
||||
return histogram;
|
||||
}
|
||||
@ -710,7 +680,7 @@ HistogramBase* LinearHistogram::DeserializeInfoImpl(PickleIterator* iter) {
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
HistogramBase* BooleanHistogram::FactoryGet(const string& name, int32 flags) {
|
||||
Histogram* histogram = StatisticsRecorder::FindHistogram(name);
|
||||
HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
|
||||
if (!histogram) {
|
||||
// To avoid racy destruction at shutdown, the following will be leaked.
|
||||
BucketRanges* ranges = new BucketRanges(4);
|
||||
@ -720,16 +690,13 @@ HistogramBase* BooleanHistogram::FactoryGet(const string& name, int32 flags) {
|
||||
|
||||
BooleanHistogram* tentative_histogram =
|
||||
new BooleanHistogram(name, registered_ranges);
|
||||
CheckCorruption(*tentative_histogram, true);
|
||||
|
||||
tentative_histogram->SetFlags(flags);
|
||||
histogram =
|
||||
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
|
||||
}
|
||||
// TODO(rtenneti): delete this code after debugging.
|
||||
CheckCorruption(*histogram, false);
|
||||
|
||||
CHECK_EQ(BOOLEAN_HISTOGRAM, histogram->GetHistogramType());
|
||||
DCHECK_EQ(BOOLEAN_HISTOGRAM, histogram->GetHistogramType());
|
||||
return histogram;
|
||||
}
|
||||
|
||||
@ -772,7 +739,7 @@ HistogramBase* CustomHistogram::FactoryGet(const string& name,
|
||||
int32 flags) {
|
||||
CHECK(ValidateCustomRanges(custom_ranges));
|
||||
|
||||
Histogram* histogram = StatisticsRecorder::FindHistogram(name);
|
||||
HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
|
||||
if (!histogram) {
|
||||
BucketRanges* ranges = CreateBucketRangesFromCustomRanges(custom_ranges);
|
||||
const BucketRanges* registered_ranges =
|
||||
@ -781,17 +748,14 @@ HistogramBase* CustomHistogram::FactoryGet(const string& name,
|
||||
// To avoid racy destruction at shutdown, the following will be leaked.
|
||||
CustomHistogram* tentative_histogram =
|
||||
new CustomHistogram(name, registered_ranges);
|
||||
CheckCorruption(*tentative_histogram, true);
|
||||
|
||||
tentative_histogram->SetFlags(flags);
|
||||
|
||||
histogram =
|
||||
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
|
||||
}
|
||||
// TODO(rtenneti): delete this code after debugging.
|
||||
CheckCorruption(*histogram, false);
|
||||
|
||||
CHECK_EQ(histogram->GetHistogramType(), CUSTOM_HISTOGRAM);
|
||||
DCHECK_EQ(histogram->GetHistogramType(), CUSTOM_HISTOGRAM);
|
||||
return histogram;
|
||||
}
|
||||
|
||||
|
@ -369,16 +369,6 @@ class BASE_EXPORT Histogram : public HistogramBase {
|
||||
|
||||
typedef std::vector<Count> Counts;
|
||||
|
||||
enum Inconsistencies {
|
||||
NO_INCONSISTENCIES = 0x0,
|
||||
RANGE_CHECKSUM_ERROR = 0x1,
|
||||
BUCKET_ORDER_ERROR = 0x2,
|
||||
COUNT_HIGH_ERROR = 0x4,
|
||||
COUNT_LOW_ERROR = 0x8,
|
||||
|
||||
NEVER_EXCEEDED_VALUE = 0x10
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// For a valid histogram, input should follow these restrictions:
|
||||
// minimum > 0 (if a minimum below 1 is specified, it will implicitly be
|
||||
@ -423,7 +413,7 @@ class BASE_EXPORT Histogram : public HistogramBase {
|
||||
// produce a false-alarm if a race occurred in the reading of the data during
|
||||
// a SnapShot process, but should otherwise be false at all times (unless we
|
||||
// have memory over-writes, or DRAM failures).
|
||||
virtual Inconsistencies FindCorruption(const HistogramSamples& samples) const;
|
||||
virtual int FindCorruption(const HistogramSamples& samples) const OVERRIDE;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Accessors for factory constuction, serialization and testing.
|
||||
|
@ -100,6 +100,11 @@ bool HistogramBase::SerializeInfo(Pickle* pickle) const {
|
||||
return SerializeInfoImpl(pickle);
|
||||
}
|
||||
|
||||
int HistogramBase::FindCorruption(const HistogramSamples& samples) const {
|
||||
// Not supported by default.
|
||||
return NO_INCONSISTENCIES;
|
||||
}
|
||||
|
||||
void HistogramBase::WriteJSON(std::string* output) const {
|
||||
Count count;
|
||||
scoped_ptr<ListValue> buckets(new ListValue());
|
||||
|
@ -70,6 +70,17 @@ class BASE_EXPORT HistogramBase {
|
||||
kHexRangePrintingFlag = 0x8000,
|
||||
};
|
||||
|
||||
// Histogram data inconsistency types.
|
||||
enum Inconsistency {
|
||||
NO_INCONSISTENCIES = 0x0,
|
||||
RANGE_CHECKSUM_ERROR = 0x1,
|
||||
BUCKET_ORDER_ERROR = 0x2,
|
||||
COUNT_HIGH_ERROR = 0x4,
|
||||
COUNT_LOW_ERROR = 0x8,
|
||||
|
||||
NEVER_EXCEEDED_VALUE = 0x10
|
||||
};
|
||||
|
||||
explicit HistogramBase(const std::string& name);
|
||||
virtual ~HistogramBase();
|
||||
|
||||
@ -103,6 +114,10 @@ class BASE_EXPORT HistogramBase {
|
||||
// does not serialize the samples.
|
||||
bool SerializeInfo(Pickle* pickle) const;
|
||||
|
||||
// Try to find out data corruption from histogram and the samples.
|
||||
// The returned value is a combination of Inconsistency enum.
|
||||
virtual int FindCorruption(const HistogramSamples& samples) const;
|
||||
|
||||
// Snapshot the current complete set of sample data.
|
||||
// Override with atomic/locked snapshot if needed.
|
||||
virtual scoped_ptr<HistogramSamples> SnapshotSamples() const = 0;
|
||||
|
@ -167,6 +167,25 @@ TEST_F(HistogramBaseTest, DeserializeCustomHistogram) {
|
||||
EXPECT_EQ(0, deserialized->flags());
|
||||
}
|
||||
|
||||
// TODO(kaiwang): Add SparseHistogram test.
|
||||
TEST_F(HistogramBaseTest, DeserializeSparseHistogram) {
|
||||
HistogramBase* histogram = SparseHistogram::FactoryGet(
|
||||
"TestHistogram", HistogramBase::kIPCSerializationSourceFlag);
|
||||
|
||||
Pickle pickle;
|
||||
ASSERT_TRUE(histogram->SerializeInfo(&pickle));
|
||||
|
||||
PickleIterator iter(pickle);
|
||||
HistogramBase* deserialized = DeserializeHistogramInfo(&iter);
|
||||
EXPECT_EQ(histogram, deserialized);
|
||||
|
||||
ResetStatisticsRecorder();
|
||||
|
||||
PickleIterator iter2(pickle);
|
||||
deserialized = DeserializeHistogramInfo(&iter2);
|
||||
EXPECT_TRUE(deserialized);
|
||||
EXPECT_NE(histogram, deserialized);
|
||||
EXPECT_EQ("TestHistogram", deserialized->histogram_name());
|
||||
EXPECT_EQ(0, deserialized->flags());
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
|
@ -24,14 +24,14 @@ class BASE_EXPORT HistogramFlattener {
|
||||
virtual void RecordDelta(const HistogramBase& histogram,
|
||||
const HistogramSamples& snapshot) = 0;
|
||||
|
||||
// Will be called each time a type of Inconsistenies is seen on a histogram,
|
||||
// Will be called each time a type of Inconsistency is seen on a histogram,
|
||||
// during inspections done internally in HistogramSnapshotManager class.
|
||||
virtual void InconsistencyDetected(Histogram::Inconsistencies problem) = 0;
|
||||
virtual void InconsistencyDetected(HistogramBase::Inconsistency problem) = 0;
|
||||
|
||||
// Will be called when a type of Inconsistenies is seen for the first time
|
||||
// on a histogram.
|
||||
// Will be called when a type of Inconsistency is seen for the first time on
|
||||
// a histogram.
|
||||
virtual void UniqueInconsistencyDetected(
|
||||
Histogram::Inconsistencies problem) = 0;
|
||||
HistogramBase::Inconsistency problem) = 0;
|
||||
|
||||
// Will be called when the total logged sample count of a histogram
|
||||
// differs from the sum of logged sample count in all the buckets. The
|
||||
|
@ -25,7 +25,7 @@ HistogramSnapshotManager::~HistogramSnapshotManager() {
|
||||
STLDeleteValues(&logged_samples_);
|
||||
}
|
||||
|
||||
void HistogramSnapshotManager::PrepareDeltas(Histogram::Flags flag_to_set,
|
||||
void HistogramSnapshotManager::PrepareDeltas(HistogramBase::Flags flag_to_set,
|
||||
bool record_only_uma) {
|
||||
StatisticsRecorder::Histograms histograms;
|
||||
StatisticsRecorder::GetHistograms(&histograms);
|
||||
@ -40,7 +40,7 @@ void HistogramSnapshotManager::PrepareDeltas(Histogram::Flags flag_to_set,
|
||||
}
|
||||
}
|
||||
|
||||
void HistogramSnapshotManager::PrepareDelta(const Histogram& histogram) {
|
||||
void HistogramSnapshotManager::PrepareDelta(const HistogramBase& histogram) {
|
||||
DCHECK(histogram_flattener_);
|
||||
|
||||
// Get up-to-date snapshot of sample stats.
|
||||
@ -52,13 +52,13 @@ void HistogramSnapshotManager::PrepareDelta(const Histogram& histogram) {
|
||||
// Crash if we detect that our histograms have been overwritten. This may be
|
||||
// a fair distance from the memory smasher, but we hope to correlate these
|
||||
// crashes with other events, such as plugins, or usage patterns, etc.
|
||||
if (Histogram::BUCKET_ORDER_ERROR & corruption) {
|
||||
if (HistogramBase::BUCKET_ORDER_ERROR & corruption) {
|
||||
// The checksum should have caught this, so crash separately if it didn't.
|
||||
CHECK_NE(0, Histogram::RANGE_CHECKSUM_ERROR & corruption);
|
||||
CHECK_NE(0, HistogramBase::RANGE_CHECKSUM_ERROR & corruption);
|
||||
CHECK(false); // Crash for the bucket order corruption.
|
||||
}
|
||||
// Checksum corruption might not have caused order corruption.
|
||||
CHECK_EQ(0, Histogram::RANGE_CHECKSUM_ERROR & corruption);
|
||||
CHECK_EQ(0, HistogramBase::RANGE_CHECKSUM_ERROR & corruption);
|
||||
|
||||
// Note, at this point corruption can only be COUNT_HIGH_ERROR or
|
||||
// COUNT_LOW_ERROR and they never arise together, so we don't need to extract
|
||||
@ -67,14 +67,14 @@ void HistogramSnapshotManager::PrepareDelta(const Histogram& histogram) {
|
||||
DLOG(ERROR) << "Histogram: " << histogram_name
|
||||
<< " has data corruption: " << corruption;
|
||||
histogram_flattener_->InconsistencyDetected(
|
||||
static_cast<Histogram::Inconsistencies>(corruption));
|
||||
static_cast<HistogramBase::Inconsistency>(corruption));
|
||||
// Don't record corrupt data to metrics services.
|
||||
int old_corruption = inconsistencies_[histogram_name];
|
||||
if (old_corruption == (corruption | old_corruption))
|
||||
return; // We've already seen this corruption for this histogram.
|
||||
inconsistencies_[histogram_name] |= corruption;
|
||||
histogram_flattener_->UniqueInconsistencyDetected(
|
||||
static_cast<Histogram::Inconsistencies>(corruption));
|
||||
static_cast<HistogramBase::Inconsistency>(corruption));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/metrics/histogram.h"
|
||||
#include "base/metrics/histogram_base.h"
|
||||
|
||||
namespace base {
|
||||
|
||||
@ -31,11 +31,11 @@ class BASE_EXPORT HistogramSnapshotManager {
|
||||
// Snapshot all histograms, and ask |histogram_flattener_| to record the
|
||||
// delta. The arguments allow selecting only a subset of histograms for
|
||||
// recording, or to set a flag in each recorded histogram.
|
||||
void PrepareDeltas(Histogram::Flags flags_to_set, bool record_only_uma);
|
||||
void PrepareDeltas(HistogramBase::Flags flags_to_set, bool record_only_uma);
|
||||
|
||||
private:
|
||||
// Snapshot this histogram, and record the delta.
|
||||
void PrepareDelta(const Histogram& histogram);
|
||||
void PrepareDelta(const HistogramBase& histogram);
|
||||
|
||||
// Try to detect and fix count inconsistency of logged samples.
|
||||
void InspectLoggedSamplesInconsistency(
|
||||
|
@ -315,21 +315,21 @@ TEST_F(HistogramTest, CorruptSampleCounts) {
|
||||
histogram->Add(40);
|
||||
|
||||
scoped_ptr<SampleVector> snapshot = histogram->SnapshotSampleVector();
|
||||
EXPECT_EQ(Histogram::NO_INCONSISTENCIES,
|
||||
EXPECT_EQ(HistogramBase::NO_INCONSISTENCIES,
|
||||
histogram->FindCorruption(*snapshot));
|
||||
EXPECT_EQ(2, snapshot->redundant_count());
|
||||
EXPECT_EQ(2, snapshot->TotalCount());
|
||||
|
||||
snapshot->counts_[3] += 100; // Sample count won't match redundant count.
|
||||
EXPECT_EQ(Histogram::COUNT_LOW_ERROR,
|
||||
EXPECT_EQ(HistogramBase::COUNT_LOW_ERROR,
|
||||
histogram->FindCorruption(*snapshot));
|
||||
snapshot->counts_[2] -= 200;
|
||||
EXPECT_EQ(Histogram::COUNT_HIGH_ERROR,
|
||||
EXPECT_EQ(HistogramBase::COUNT_HIGH_ERROR,
|
||||
histogram->FindCorruption(*snapshot));
|
||||
|
||||
// But we can't spot a corruption if it is compensated for.
|
||||
snapshot->counts_[1] += 100;
|
||||
EXPECT_EQ(Histogram::NO_INCONSISTENCIES,
|
||||
EXPECT_EQ(HistogramBase::NO_INCONSISTENCIES,
|
||||
histogram->FindCorruption(*snapshot));
|
||||
}
|
||||
|
||||
@ -338,7 +338,7 @@ TEST_F(HistogramTest, CorruptBucketBounds) {
|
||||
Histogram::FactoryGet("Histogram", 1, 64, 8, HistogramBase::kNoFlags));
|
||||
|
||||
scoped_ptr<SampleVector> snapshot = histogram->SnapshotSampleVector();
|
||||
EXPECT_EQ(Histogram::NO_INCONSISTENCIES,
|
||||
EXPECT_EQ(HistogramBase::NO_INCONSISTENCIES,
|
||||
histogram->FindCorruption(*snapshot));
|
||||
|
||||
BucketRanges* bucket_ranges =
|
||||
@ -346,8 +346,9 @@ TEST_F(HistogramTest, CorruptBucketBounds) {
|
||||
HistogramBase::Sample tmp = bucket_ranges->range(1);
|
||||
bucket_ranges->set_range(1, bucket_ranges->range(2));
|
||||
bucket_ranges->set_range(2, tmp);
|
||||
EXPECT_EQ(Histogram::BUCKET_ORDER_ERROR | Histogram::RANGE_CHECKSUM_ERROR,
|
||||
histogram->FindCorruption(*snapshot));
|
||||
EXPECT_EQ(
|
||||
HistogramBase::BUCKET_ORDER_ERROR | HistogramBase::RANGE_CHECKSUM_ERROR,
|
||||
histogram->FindCorruption(*snapshot));
|
||||
|
||||
bucket_ranges->set_range(2, bucket_ranges->range(1));
|
||||
bucket_ranges->set_range(1, tmp);
|
||||
@ -355,11 +356,11 @@ TEST_F(HistogramTest, CorruptBucketBounds) {
|
||||
|
||||
// Show that two simple changes don't offset each other
|
||||
bucket_ranges->set_range(3, bucket_ranges->range(3) + 1);
|
||||
EXPECT_EQ(Histogram::RANGE_CHECKSUM_ERROR,
|
||||
EXPECT_EQ(HistogramBase::RANGE_CHECKSUM_ERROR,
|
||||
histogram->FindCorruption(*snapshot));
|
||||
|
||||
bucket_ranges->set_range(4, bucket_ranges->range(4) - 1);
|
||||
EXPECT_EQ(Histogram::RANGE_CHECKSUM_ERROR,
|
||||
EXPECT_EQ(HistogramBase::RANGE_CHECKSUM_ERROR,
|
||||
histogram->FindCorruption(*snapshot));
|
||||
|
||||
// Repair histogram so that destructor won't DCHECK().
|
||||
|
@ -19,9 +19,16 @@ typedef HistogramBase::Sample Sample;
|
||||
|
||||
// static
|
||||
HistogramBase* SparseHistogram::FactoryGet(const string& name, int32 flags) {
|
||||
// TODO(kaiwang): Register and get SparseHistogram with StatisticsRecorder.
|
||||
HistogramBase* histogram = new SparseHistogram(name);
|
||||
histogram->SetFlags(flags);
|
||||
HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
|
||||
|
||||
if (!histogram) {
|
||||
// To avoid racy destruction at shutdown, the following will be leaked.
|
||||
HistogramBase* tentative_histogram = new SparseHistogram(name);
|
||||
tentative_histogram->SetFlags(flags);
|
||||
histogram =
|
||||
StatisticsRecorder::RegisterOrDeleteDuplicate(tentative_histogram);
|
||||
}
|
||||
DCHECK_EQ(SPARSE_HISTOGRAM, histogram->GetHistogramType());
|
||||
return histogram;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,8 @@ bool StatisticsRecorder::IsActive() {
|
||||
}
|
||||
|
||||
// static
|
||||
Histogram* StatisticsRecorder::RegisterOrDeleteDuplicate(Histogram* histogram) {
|
||||
HistogramBase* StatisticsRecorder::RegisterOrDeleteDuplicate(
|
||||
HistogramBase* histogram) {
|
||||
// As per crbug.com/79322 the histograms are intentionally leaked, so we need
|
||||
// to annotate them. Because ANNOTATE_LEAKING_OBJECT_PTR may be used only once
|
||||
// for an object, the duplicates should not be annotated.
|
||||
@ -56,8 +57,8 @@ Histogram* StatisticsRecorder::RegisterOrDeleteDuplicate(Histogram* histogram) {
|
||||
return histogram;
|
||||
}
|
||||
|
||||
Histogram* histogram_to_delete = NULL;
|
||||
Histogram* histogram_to_return = NULL;
|
||||
HistogramBase* histogram_to_delete = NULL;
|
||||
HistogramBase* histogram_to_return = NULL;
|
||||
{
|
||||
base::AutoLock auto_lock(*lock_);
|
||||
if (histograms_ == NULL) {
|
||||
@ -254,7 +255,7 @@ void StatisticsRecorder::GetBucketRanges(
|
||||
}
|
||||
|
||||
// static
|
||||
Histogram* StatisticsRecorder::FindHistogram(const std::string& name) {
|
||||
HistogramBase* StatisticsRecorder::FindHistogram(const std::string& name) {
|
||||
if (lock_ == NULL)
|
||||
return NULL;
|
||||
base::AutoLock auto_lock(*lock_);
|
||||
|
@ -23,12 +23,12 @@
|
||||
namespace base {
|
||||
|
||||
class BucketRanges;
|
||||
class Histogram;
|
||||
class HistogramBase;
|
||||
class Lock;
|
||||
|
||||
class BASE_EXPORT StatisticsRecorder {
|
||||
public:
|
||||
typedef std::vector<Histogram*> Histograms;
|
||||
typedef std::vector<HistogramBase*> Histograms;
|
||||
|
||||
// Initializes the StatisticsRecorder system.
|
||||
static void Initialize();
|
||||
@ -40,7 +40,7 @@ class BASE_EXPORT StatisticsRecorder {
|
||||
// identically named histogram is already registered, then the argument
|
||||
// |histogram| will deleted. The returned value is always the registered
|
||||
// histogram (either the argument, or the pre-existing registered histogram).
|
||||
static Histogram* RegisterOrDeleteDuplicate(Histogram* histogram);
|
||||
static HistogramBase* RegisterOrDeleteDuplicate(HistogramBase* histogram);
|
||||
|
||||
// Register, or add a new BucketRanges. If an identically BucketRanges is
|
||||
// already registered, then the argument |ranges| will deleted. The returned
|
||||
@ -68,7 +68,7 @@ class BASE_EXPORT StatisticsRecorder {
|
||||
|
||||
// Find a histogram by name. It matches the exact name. This method is thread
|
||||
// safe. It returns NULL if a matching histogram is not found.
|
||||
static Histogram* FindHistogram(const std::string& name);
|
||||
static HistogramBase* FindHistogram(const std::string& name);
|
||||
|
||||
static bool dump_on_exit() { return dump_on_exit_; }
|
||||
|
||||
@ -82,7 +82,7 @@ class BASE_EXPORT StatisticsRecorder {
|
||||
|
||||
private:
|
||||
// We keep all registered histograms in a map, from name to histogram.
|
||||
typedef std::map<std::string, Histogram*> HistogramMap;
|
||||
typedef std::map<std::string, HistogramBase*> HistogramMap;
|
||||
|
||||
// We keep all |bucket_ranges_| in a map, from checksum to a list of
|
||||
// |bucket_ranges_|. Checksum is calculated from the |ranges_| in
|
||||
|
@ -12,7 +12,7 @@
|
||||
#import "chrome/browser/chrome_browser_application_mac.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
using base::Histogram;
|
||||
using base::HistogramBase;
|
||||
using base::HistogramSamples;
|
||||
using base::StatisticsRecorder;
|
||||
|
||||
@ -76,7 +76,7 @@ TEST(ChromeApplicationMacTest, RecordException) {
|
||||
// We should have exactly the right number of exceptions.
|
||||
StatisticsRecorder::GetSnapshot("OSX.NSException", &histograms);
|
||||
EXPECT_EQ(1U, histograms.size());
|
||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histograms[0]->flags());
|
||||
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histograms[0]->flags());
|
||||
|
||||
scoped_ptr<HistogramSamples> samples(histograms[0]->SnapshotSamples());
|
||||
EXPECT_EQ(4, samples->GetCount(0));
|
||||
@ -85,7 +85,9 @@ TEST(ChromeApplicationMacTest, RecordException) {
|
||||
EXPECT_EQ(2, samples->GetCount(3));
|
||||
|
||||
// The unknown exceptions should end up in the overflow bucket.
|
||||
EXPECT_EQ(kUnknownNSException + 1, histograms[0]->bucket_count());
|
||||
EXPECT_TRUE(histograms[0]->HasConstructionArguments(1,
|
||||
kUnknownNSException,
|
||||
kUnknownNSException + 1));
|
||||
EXPECT_EQ(4, samples->GetCount(kUnknownNSException));
|
||||
}
|
||||
|
||||
|
@ -110,13 +110,12 @@ void ValidateHistograms(const RecordedHistogram* recorded,
|
||||
const RecordedHistogram& r = recorded[i];
|
||||
size_t j = 0;
|
||||
for (j = 0; j < histograms.size(); ++j) {
|
||||
base::Histogram* histogram(histograms[j]);
|
||||
base::HistogramBase* histogram(histograms[j]);
|
||||
|
||||
if (r.name == histogram->histogram_name()) {
|
||||
EXPECT_EQ(r.type, histogram->GetHistogramType());
|
||||
EXPECT_EQ(r.min, histogram->declared_min());
|
||||
EXPECT_EQ(r.max, histogram->declared_max());
|
||||
EXPECT_EQ(r.buckets, histogram->bucket_count());
|
||||
EXPECT_TRUE(
|
||||
histogram->HasConstructionArguments(r.min, r.max, r.buckets));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
using base::Histogram;
|
||||
using base::HistogramBase;
|
||||
using base::HistogramSamples;
|
||||
|
||||
namespace chrome_browser_net {
|
||||
@ -210,8 +210,8 @@ class HttpPipeliningCompatibilityClientTest : public testing::Test {
|
||||
private:
|
||||
scoped_ptr<HistogramSamples> GetHistogram(const char* name) {
|
||||
scoped_ptr<HistogramSamples> samples;
|
||||
Histogram* cached_histogram = NULL;
|
||||
Histogram* current_histogram =
|
||||
HistogramBase* cached_histogram = NULL;
|
||||
HistogramBase* current_histogram =
|
||||
base::StatisticsRecorder::FindHistogram(name);
|
||||
if (ContainsKey(histograms_, name)) {
|
||||
cached_histogram = histograms_[name];
|
||||
@ -238,12 +238,12 @@ class HttpPipeliningCompatibilityClientTest : public testing::Test {
|
||||
return samples.Pass();
|
||||
}
|
||||
|
||||
static std::map<std::string, Histogram*> histograms_;
|
||||
static std::map<std::string, HistogramBase*> histograms_;
|
||||
std::map<std::string, HistogramSamples*> original_samples_;
|
||||
};
|
||||
|
||||
// static
|
||||
std::map<std::string, Histogram*>
|
||||
std::map<std::string, HistogramBase*>
|
||||
HttpPipeliningCompatibilityClientTest::histograms_;
|
||||
|
||||
TEST_F(HttpPipeliningCompatibilityClientTest, Success) {
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
using base::Histogram;
|
||||
using base::HistogramBase;
|
||||
using base::HistogramSamples;
|
||||
using base::StatisticsRecorder;
|
||||
|
||||
@ -37,7 +37,7 @@ class SpellcheckHostMetricsTest : public testing::Test {
|
||||
|
||||
TEST_F(SpellcheckHostMetricsTest, RecordEnabledStats) {
|
||||
scoped_ptr<HistogramSamples> baseline;
|
||||
Histogram* histogram =
|
||||
HistogramBase* histogram =
|
||||
StatisticsRecorder::FindHistogram("SpellCheck.Enabled");
|
||||
if (histogram)
|
||||
baseline = histogram->SnapshotSamples();
|
||||
@ -69,7 +69,7 @@ TEST_F(SpellcheckHostMetricsTest, RecordEnabledStats) {
|
||||
TEST_F(SpellcheckHostMetricsTest, CustomWordStats) {
|
||||
metrics()->RecordCustomWordCountStats(123);
|
||||
|
||||
Histogram* histogram =
|
||||
HistogramBase* histogram =
|
||||
StatisticsRecorder::FindHistogram("SpellCheck.CustomWords");
|
||||
ASSERT_TRUE(histogram != NULL);
|
||||
scoped_ptr<HistogramSamples> baseline = histogram->SnapshotSamples();
|
||||
@ -102,7 +102,7 @@ TEST_F(SpellcheckHostMetricsTest, RecordWordCountsDiscardsDuplicates) {
|
||||
// Get baselines for all affected histograms.
|
||||
scoped_ptr<HistogramSamples> baselines[arraysize(histogramName)];
|
||||
for (size_t i = 0; i < arraysize(histogramName); ++i) {
|
||||
Histogram* histogram =
|
||||
HistogramBase* histogram =
|
||||
StatisticsRecorder::FindHistogram(histogramName[i]);
|
||||
if (histogram)
|
||||
baselines[i] = histogram->SnapshotSamples();
|
||||
@ -114,7 +114,7 @@ TEST_F(SpellcheckHostMetricsTest, RecordWordCountsDiscardsDuplicates) {
|
||||
// Get samples for all affected histograms.
|
||||
scoped_ptr<HistogramSamples> samples[arraysize(histogramName)];
|
||||
for (size_t i = 0; i < arraysize(histogramName); ++i) {
|
||||
Histogram* histogram =
|
||||
HistogramBase* histogram =
|
||||
StatisticsRecorder::FindHistogram(histogramName[i]);
|
||||
ASSERT_TRUE(histogram != NULL);
|
||||
samples[i] = histogram->SnapshotSamples();
|
||||
@ -128,8 +128,7 @@ TEST_F(SpellcheckHostMetricsTest, RecordWordCountsDiscardsDuplicates) {
|
||||
TEST_F(SpellcheckHostMetricsTest, RecordSpellingServiceStats) {
|
||||
const char kMetricName[] = "SpellCheck.SpellingService.Enabled";
|
||||
scoped_ptr<HistogramSamples> baseline;
|
||||
Histogram* histogram =
|
||||
StatisticsRecorder::FindHistogram(kMetricName);
|
||||
HistogramBase* histogram = StatisticsRecorder::FindHistogram(kMetricName);
|
||||
if (histogram)
|
||||
baseline = histogram->SnapshotSamples();
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "content/public/common/password_form.h"
|
||||
#include "testing/gtest_mac.h"
|
||||
|
||||
using base::Histogram;
|
||||
using base::HistogramBase;
|
||||
using base::HistogramSamples;
|
||||
using base::StatisticsRecorder;
|
||||
|
||||
@ -34,7 +34,8 @@ class PasswordGenerationBubbleControllerTest : public CocoaProfileTest {
|
||||
|
||||
generator_.reset(new autofill::PasswordGenerator(20));
|
||||
|
||||
Histogram* histogram = StatisticsRecorder::FindHistogram(kHistogramName);
|
||||
HistogramBase* histogram =
|
||||
StatisticsRecorder::FindHistogram(kHistogramName);
|
||||
if (histogram)
|
||||
original_ = histogram->SnapshotSamples();
|
||||
|
||||
@ -65,7 +66,7 @@ class PasswordGenerationBubbleControllerTest : public CocoaProfileTest {
|
||||
}
|
||||
|
||||
HistogramSamples* GetHistogramSamples() {
|
||||
Histogram* histogram =
|
||||
HistogramBase* histogram =
|
||||
StatisticsRecorder::FindHistogram(kHistogramName);
|
||||
if (histogram) {
|
||||
current_ = histogram->SnapshotSamples();
|
||||
|
@ -43,15 +43,15 @@ void MetricsServiceBase::RecordDelta(
|
||||
}
|
||||
|
||||
void MetricsServiceBase::InconsistencyDetected(
|
||||
Histogram::Inconsistencies problem) {
|
||||
base::HistogramBase::Inconsistency problem) {
|
||||
UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowser",
|
||||
problem, Histogram::NEVER_EXCEEDED_VALUE);
|
||||
problem, base::HistogramBase::NEVER_EXCEEDED_VALUE);
|
||||
}
|
||||
|
||||
void MetricsServiceBase::UniqueInconsistencyDetected(
|
||||
Histogram::Inconsistencies problem) {
|
||||
base::HistogramBase::Inconsistency problem) {
|
||||
UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesBrowserUnique",
|
||||
problem, Histogram::NEVER_EXCEEDED_VALUE);
|
||||
problem, base::HistogramBase::NEVER_EXCEEDED_VALUE);
|
||||
}
|
||||
|
||||
void MetricsServiceBase::InconsistencyDetectedInLoggedCount(int amount) {
|
||||
|
@ -24,9 +24,9 @@ class MetricsServiceBase : public base::HistogramFlattener {
|
||||
virtual void RecordDelta(const base::HistogramBase& histogram,
|
||||
const base::HistogramSamples& snapshot) OVERRIDE;
|
||||
virtual void InconsistencyDetected(
|
||||
base::Histogram::Inconsistencies problem) OVERRIDE;
|
||||
base::HistogramBase::Inconsistency problem) OVERRIDE;
|
||||
virtual void UniqueInconsistencyDetected(
|
||||
base::Histogram::Inconsistencies problem) OVERRIDE;
|
||||
base::HistogramBase::Inconsistency problem) OVERRIDE;
|
||||
virtual void InconsistencyDetectedInLoggedCount(int amount) OVERRIDE;
|
||||
|
||||
protected:
|
||||
|
@ -113,7 +113,7 @@ void OnInitialPageLoadComplete() {
|
||||
|
||||
// Set UMA flag for histograms outside chrome/ that can't use the
|
||||
// ScopedSlowStartupUMA class.
|
||||
base::Histogram* histogram =
|
||||
base::HistogramBase* histogram =
|
||||
base::StatisticsRecorder::FindHistogram("Startup.SlowStartupNSSInit");
|
||||
if (histogram)
|
||||
histogram->SetFlags(base::HistogramBase::kUmaTargetedHistogramFlag);
|
||||
|
@ -32,8 +32,9 @@ void UMAHistogramHelper::ExpectUniqueSample(
|
||||
const std::string& name,
|
||||
base::HistogramBase::Sample sample,
|
||||
base::HistogramBase::Count expected_count) {
|
||||
base::Histogram* histogram = base::StatisticsRecorder::FindHistogram(name);
|
||||
EXPECT_NE(static_cast<base::Histogram*>(NULL), histogram)
|
||||
base::HistogramBase* histogram =
|
||||
base::StatisticsRecorder::FindHistogram(name);
|
||||
EXPECT_NE(static_cast<base::HistogramBase*>(NULL), histogram)
|
||||
<< "Histogram \"" << name << "\" does not exist.";
|
||||
|
||||
if (histogram) {
|
||||
@ -46,8 +47,9 @@ void UMAHistogramHelper::ExpectUniqueSample(
|
||||
void UMAHistogramHelper::ExpectTotalCount(
|
||||
const std::string& name,
|
||||
base::HistogramBase::Count count) {
|
||||
base::Histogram* histogram = base::StatisticsRecorder::FindHistogram(name);
|
||||
EXPECT_NE(static_cast<base::Histogram*>(NULL), histogram)
|
||||
base::HistogramBase* histogram =
|
||||
base::StatisticsRecorder::FindHistogram(name);
|
||||
EXPECT_NE(static_cast<base::HistogramBase*>(NULL), histogram)
|
||||
<< "Histogram \"" << name << "\" does not exist.";
|
||||
|
||||
if (histogram) {
|
||||
|
@ -63,7 +63,8 @@ void HistogramMessageFilter::OnGetBrowserHistogram(
|
||||
<< " switches.";
|
||||
return;
|
||||
}
|
||||
base::Histogram* histogram = base::StatisticsRecorder::FindHistogram(name);
|
||||
base::HistogramBase* histogram =
|
||||
base::StatisticsRecorder::FindHistogram(name);
|
||||
if (!histogram) {
|
||||
*histogram_json = "{}";
|
||||
} else {
|
||||
|
@ -87,15 +87,15 @@ void ChildHistogramMessageFilter::RecordDelta(
|
||||
}
|
||||
|
||||
void ChildHistogramMessageFilter::InconsistencyDetected(
|
||||
base::Histogram::Inconsistencies problem) {
|
||||
base::HistogramBase::Inconsistency problem) {
|
||||
UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesChildProcess",
|
||||
problem, base::Histogram::NEVER_EXCEEDED_VALUE);
|
||||
problem, base::HistogramBase::NEVER_EXCEEDED_VALUE);
|
||||
}
|
||||
|
||||
void ChildHistogramMessageFilter::UniqueInconsistencyDetected(
|
||||
base::Histogram::Inconsistencies problem) {
|
||||
base::HistogramBase::Inconsistency problem) {
|
||||
UMA_HISTOGRAM_ENUMERATION("Histogram.InconsistenciesChildProcessUnique",
|
||||
problem, base::Histogram::NEVER_EXCEEDED_VALUE);
|
||||
problem, base::HistogramBase::NEVER_EXCEEDED_VALUE);
|
||||
}
|
||||
|
||||
void ChildHistogramMessageFilter::InconsistencyDetectedInLoggedCount(
|
||||
|
@ -38,9 +38,9 @@ class ChildHistogramMessageFilter : public base::HistogramFlattener,
|
||||
virtual void RecordDelta(const base::HistogramBase& histogram,
|
||||
const base::HistogramSamples& snapshot) OVERRIDE;
|
||||
virtual void InconsistencyDetected(
|
||||
base::Histogram::Inconsistencies problem) OVERRIDE;
|
||||
base::HistogramBase::Inconsistency problem) OVERRIDE;
|
||||
virtual void UniqueInconsistencyDetected(
|
||||
base::Histogram::Inconsistencies problem) OVERRIDE;
|
||||
base::HistogramBase::Inconsistency problem) OVERRIDE;
|
||||
virtual void InconsistencyDetectedInLoggedCount(int amount) OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -183,7 +183,7 @@ void DomAutomationController::GetHistogram(const CppArgumentList& args,
|
||||
result->SetNull();
|
||||
return;
|
||||
}
|
||||
base::Histogram* histogram =
|
||||
base::HistogramBase* histogram =
|
||||
base::StatisticsRecorder::FindHistogram(args[0].ToString());
|
||||
std::string output;
|
||||
if (!histogram) {
|
||||
|
@ -182,7 +182,7 @@ TEST_F(SignalSenderVerificationTest, TestSignalAccepted) {
|
||||
TEST_F(SignalSenderVerificationTest, TestSignalRejected) {
|
||||
// To make sure the histogram instance is created.
|
||||
UMA_HISTOGRAM_COUNTS("DBus.RejectedSignalCount", 0);
|
||||
base::Histogram* reject_signal_histogram =
|
||||
base::HistogramBase* reject_signal_histogram =
|
||||
base::StatisticsRecorder::FindHistogram("DBus.RejectedSignalCount");
|
||||
scoped_ptr<base::HistogramSamples> samples1(
|
||||
reject_signal_histogram->SnapshotSamples());
|
||||
|
@ -45,7 +45,7 @@ StatsHistogram* StatsHistogram::FactoryGet(const std::string& name,
|
||||
Sample minimum = 1;
|
||||
Sample maximum = disk_cache::Stats::kDataSizesLength - 1;
|
||||
size_t bucket_count = disk_cache::Stats::kDataSizesLength;
|
||||
Histogram* histogram = StatisticsRecorder::FindHistogram(name);
|
||||
HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
|
||||
if (!histogram) {
|
||||
DCHECK(stats);
|
||||
|
||||
@ -83,9 +83,9 @@ scoped_ptr<HistogramSamples> StatsHistogram::SnapshotSamples() const {
|
||||
return samples.PassAs<HistogramSamples>();
|
||||
}
|
||||
|
||||
Histogram::Inconsistencies StatsHistogram::FindCorruption(
|
||||
const HistogramSamples& samples) const {
|
||||
return NO_INCONSISTENCIES; // This class won't monitor inconsistencies.
|
||||
int StatsHistogram::FindCorruption(const HistogramSamples& samples) const {
|
||||
// This class won't monitor inconsistencies.
|
||||
return HistogramBase::NO_INCONSISTENCIES;
|
||||
}
|
||||
|
||||
} // namespace disk_cache
|
||||
|
@ -43,7 +43,7 @@ class StatsHistogram : public base::Histogram {
|
||||
const Stats* stats);
|
||||
|
||||
virtual scoped_ptr<base::HistogramSamples> SnapshotSamples() const OVERRIDE;
|
||||
virtual Inconsistencies FindCorruption(
|
||||
virtual int FindCorruption(
|
||||
const base::HistogramSamples& samples) const OVERRIDE;
|
||||
|
||||
private:
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "testing/platform_test.h"
|
||||
|
||||
using base::Histogram;
|
||||
using base::HistogramBase;
|
||||
using base::HistogramSamples;
|
||||
using base::StatisticsRecorder;
|
||||
|
||||
@ -24,7 +25,7 @@ TEST(SocketStreamMetricsTest, ProtocolType) {
|
||||
// as histograms can get affected by other tests. In particular,
|
||||
// SocketStreamTest and WebSocketTest can affect the histograms.
|
||||
scoped_ptr<HistogramSamples> original;
|
||||
Histogram* histogram =
|
||||
HistogramBase* histogram =
|
||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ProtocolType");
|
||||
if (histogram) {
|
||||
original = histogram->SnapshotSamples();
|
||||
@ -40,7 +41,7 @@ TEST(SocketStreamMetricsTest, ProtocolType) {
|
||||
histogram =
|
||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ProtocolType");
|
||||
ASSERT_TRUE(histogram != NULL);
|
||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
|
||||
scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples());
|
||||
if (original.get()) {
|
||||
@ -55,7 +56,7 @@ TEST(SocketStreamMetricsTest, ProtocolType) {
|
||||
TEST(SocketStreamMetricsTest, ConnectionType) {
|
||||
// First we'll preserve the original values.
|
||||
scoped_ptr<HistogramSamples> original;
|
||||
Histogram* histogram =
|
||||
HistogramBase* histogram =
|
||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ConnectionType");
|
||||
if (histogram) {
|
||||
original = histogram->SnapshotSamples();
|
||||
@ -75,7 +76,7 @@ TEST(SocketStreamMetricsTest, ConnectionType) {
|
||||
histogram =
|
||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ConnectionType");
|
||||
ASSERT_TRUE(histogram != NULL);
|
||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
|
||||
scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples());
|
||||
if (original.get()) {
|
||||
@ -90,7 +91,7 @@ TEST(SocketStreamMetricsTest, ConnectionType) {
|
||||
TEST(SocketStreamMetricsTest, WireProtocolType) {
|
||||
// First we'll preserve the original values.
|
||||
scoped_ptr<HistogramSamples> original;
|
||||
Histogram* histogram =
|
||||
HistogramBase* histogram =
|
||||
StatisticsRecorder::FindHistogram("Net.SocketStream.WireProtocolType");
|
||||
if (histogram) {
|
||||
original = histogram->SnapshotSamples();
|
||||
@ -106,7 +107,7 @@ TEST(SocketStreamMetricsTest, WireProtocolType) {
|
||||
histogram =
|
||||
StatisticsRecorder::FindHistogram("Net.SocketStream.WireProtocolType");
|
||||
ASSERT_TRUE(histogram != NULL);
|
||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
|
||||
scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples());
|
||||
if (original.get()) {
|
||||
@ -125,7 +126,7 @@ TEST(SocketStreamMetricsTest, OtherNumbers) {
|
||||
|
||||
scoped_ptr<HistogramSamples> original;
|
||||
|
||||
Histogram* histogram =
|
||||
HistogramBase* histogram =
|
||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ReceivedBytes");
|
||||
if (histogram) {
|
||||
original = histogram->SnapshotSamples();
|
||||
@ -167,28 +168,28 @@ TEST(SocketStreamMetricsTest, OtherNumbers) {
|
||||
histogram =
|
||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ConnectionLatency");
|
||||
ASSERT_TRUE(histogram != NULL);
|
||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
// We don't check the contents of the histogram as it's time sensitive.
|
||||
|
||||
// ConnectionEstablish.
|
||||
histogram =
|
||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ConnectionEstablish");
|
||||
ASSERT_TRUE(histogram != NULL);
|
||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
// We don't check the contents of the histogram as it's time sensitive.
|
||||
|
||||
// Duration.
|
||||
histogram =
|
||||
StatisticsRecorder::FindHistogram("Net.SocketStream.Duration");
|
||||
ASSERT_TRUE(histogram != NULL);
|
||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
// We don't check the contents of the histogram as it's time sensitive.
|
||||
|
||||
// ReceivedBytes.
|
||||
histogram =
|
||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ReceivedBytes");
|
||||
ASSERT_TRUE(histogram != NULL);
|
||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
samples = histogram->SnapshotSamples();
|
||||
EXPECT_EQ(11, samples->sum() - original_received_bytes); // 11 bytes read.
|
||||
|
||||
@ -196,7 +197,7 @@ TEST(SocketStreamMetricsTest, OtherNumbers) {
|
||||
histogram =
|
||||
StatisticsRecorder::FindHistogram("Net.SocketStream.ReceivedCounts");
|
||||
ASSERT_TRUE(histogram != NULL);
|
||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
samples = histogram->SnapshotSamples();
|
||||
EXPECT_EQ(2, samples->sum() - original_received_counts); // 2 read requests.
|
||||
|
||||
@ -204,7 +205,7 @@ TEST(SocketStreamMetricsTest, OtherNumbers) {
|
||||
histogram =
|
||||
StatisticsRecorder::FindHistogram("Net.SocketStream.SentBytes");
|
||||
ASSERT_TRUE(histogram != NULL);
|
||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
samples = histogram->SnapshotSamples();
|
||||
EXPECT_EQ(222, samples->sum() - original_sent_bytes); // 222 bytes sent.
|
||||
|
||||
@ -212,7 +213,7 @@ TEST(SocketStreamMetricsTest, OtherNumbers) {
|
||||
histogram =
|
||||
StatisticsRecorder::FindHistogram("Net.SocketStream.SentCounts");
|
||||
ASSERT_TRUE(histogram != NULL);
|
||||
EXPECT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
samples = histogram->SnapshotSamples();
|
||||
EXPECT_EQ(3, samples->sum() - original_sent_counts); // 3 write requests.
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ namespace net {
|
||||
namespace {
|
||||
|
||||
using base::Histogram;
|
||||
using base::HistogramBase;
|
||||
using base::HistogramSamples;
|
||||
using base::StatisticsRecorder;
|
||||
|
||||
@ -211,7 +212,7 @@ void URLRequestThrottlerEntryTest::SetUp() {
|
||||
// Must retrieve original samples for each histogram for comparison
|
||||
// as other tests may affect them.
|
||||
const char* name = kHistogramNames[i];
|
||||
Histogram* histogram = StatisticsRecorder::FindHistogram(name);
|
||||
HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
|
||||
if (histogram) {
|
||||
original_samples_[name] = histogram->SnapshotSamples().release();
|
||||
} else {
|
||||
@ -230,9 +231,9 @@ void URLRequestThrottlerEntryTest::CalculateHistogramDeltas() {
|
||||
const char* name = kHistogramNames[i];
|
||||
HistogramSamples* original = original_samples_[name];
|
||||
|
||||
Histogram* histogram = StatisticsRecorder::FindHistogram(name);
|
||||
HistogramBase* histogram = StatisticsRecorder::FindHistogram(name);
|
||||
if (histogram) {
|
||||
ASSERT_EQ(Histogram::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
ASSERT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
|
||||
|
||||
scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples());
|
||||
if (original)
|
||||
|
Reference in New Issue
Block a user