diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-05-09 14:22:11 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-05-09 15:11:45 +0000 |
commit | 2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c (patch) | |
tree | e75f511546c5fd1a173e87c1f9fb11d7ac8d1af3 /chromium/base/metrics/histogram_base.cc | |
parent | a4f3d46271c57e8155ba912df46a05559d14726e (diff) | |
download | qtwebengine-chromium-2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c.tar.gz |
BASELINE: Update Chromium to 51.0.2704.41
Also adds in all smaller components by reversing logic for exclusion.
Change-Id: Ibf90b506e7da088ea2f65dcf23f2b0992c504422
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'chromium/base/metrics/histogram_base.cc')
-rw-r--r-- | chromium/base/metrics/histogram_base.cc | 79 |
1 files changed, 73 insertions, 6 deletions
diff --git a/chromium/base/metrics/histogram_base.cc b/chromium/base/metrics/histogram_base.cc index 412f1438d2f..6a79ae25d1c 100644 --- a/chromium/base/metrics/histogram_base.cc +++ b/chromium/base/metrics/histogram_base.cc @@ -6,11 +6,11 @@ #include <limits.h> +#include <memory> #include <utility> #include "base/json/json_string_value_serializer.h" #include "base/logging.h" -#include "base/memory/scoped_ptr.h" #include "base/metrics/histogram.h" #include "base/metrics/histogram_samples.h" #include "base/metrics/sparse_histogram.h" @@ -34,9 +34,8 @@ std::string HistogramTypeToString(HistogramType type) { return "CUSTOM_HISTOGRAM"; case SPARSE_HISTOGRAM: return "SPARSE_HISTOGRAM"; - default: - NOTREACHED(); } + NOTREACHED(); return "UNKNOWN"; } @@ -62,6 +61,7 @@ HistogramBase* DeserializeHistogramInfo(PickleIterator* iter) { } const HistogramBase::Sample HistogramBase::kSampleType_MAX = INT_MAX; +HistogramBase* HistogramBase::report_histogram_ = nullptr; HistogramBase::HistogramBase(const std::string& name) : histogram_name_(name), @@ -97,7 +97,7 @@ bool HistogramBase::SerializeInfo(Pickle* pickle) const { return SerializeInfoImpl(pickle); } -int HistogramBase::FindCorruption(const HistogramSamples& samples) const { +uint32_t HistogramBase::FindCorruption(const HistogramSamples& samples) const { // Not supported by default. return NO_INCONSISTENCIES; } @@ -105,9 +105,9 @@ int HistogramBase::FindCorruption(const HistogramSamples& samples) const { void HistogramBase::WriteJSON(std::string* output) const { Count count; int64_t sum; - scoped_ptr<ListValue> buckets(new ListValue()); + std::unique_ptr<ListValue> buckets(new ListValue()); GetCountAndBucketData(&count, &sum, buckets.get()); - scoped_ptr<DictionaryValue> parameters(new DictionaryValue()); + std::unique_ptr<DictionaryValue> parameters(new DictionaryValue()); GetParameters(parameters.get()); JSONStringValueSerializer serializer(output); @@ -122,6 +122,30 @@ void HistogramBase::WriteJSON(std::string* output) const { serializer.Serialize(root); } +// static +void HistogramBase::EnableActivityReportHistogram( + const std::string& process_type) { + DCHECK(!report_histogram_); + size_t existing = StatisticsRecorder::GetHistogramCount(); + if (existing != 0) { + DLOG(WARNING) << existing + << " histograms were created before reporting was enabled."; + } + + std::string name = + "UMA.Histograms.Activity" + + (process_type.empty() ? process_type : "." + process_type); + + // Calling FactoryGet() here rather than using a histogram-macro works + // around some problems with tests that could end up seeing the results + // histogram when not expected due to a bad interaction between + // HistogramTester and StatisticsRecorder. + report_histogram_ = LinearHistogram::FactoryGet( + name, 1, HISTOGRAM_REPORT_MAX, HISTOGRAM_REPORT_MAX + 1, + kUmaTargetedHistogramFlag); + report_histogram_->Add(HISTOGRAM_REPORT_CREATED); +} + void HistogramBase::FindAndRunCallback(HistogramBase::Sample sample) const { if ((flags() & kCallbackExists) == 0) return; @@ -163,4 +187,47 @@ void HistogramBase::WriteAsciiBucketValue(Count current, StringAppendF(output, " (%d = %3.1f%%)", current, current/scaled_sum); } +// static +void HistogramBase::ReportHistogramActivity(const HistogramBase& histogram, + ReportActivity activity) { + if (!report_histogram_) + return; + + const int32_t flags = histogram.flags_; + HistogramReport report_type = HISTOGRAM_REPORT_MAX; + switch (activity) { + case HISTOGRAM_CREATED: + report_histogram_->Add(HISTOGRAM_REPORT_HISTOGRAM_CREATED); + switch (histogram.GetHistogramType()) { + case HISTOGRAM: + report_type = HISTOGRAM_REPORT_TYPE_LOGARITHMIC; + break; + case LINEAR_HISTOGRAM: + report_type = HISTOGRAM_REPORT_TYPE_LINEAR; + break; + case BOOLEAN_HISTOGRAM: + report_type = HISTOGRAM_REPORT_TYPE_BOOLEAN; + break; + case CUSTOM_HISTOGRAM: + report_type = HISTOGRAM_REPORT_TYPE_CUSTOM; + break; + case SPARSE_HISTOGRAM: + report_type = HISTOGRAM_REPORT_TYPE_SPARSE; + break; + } + report_histogram_->Add(report_type); + if (flags & kIsPersistent) + report_histogram_->Add(HISTOGRAM_REPORT_FLAG_PERSISTENT); + if ((flags & kUmaStabilityHistogramFlag) == kUmaStabilityHistogramFlag) + report_histogram_->Add(HISTOGRAM_REPORT_FLAG_UMA_STABILITY); + else if (flags & kUmaTargetedHistogramFlag) + report_histogram_->Add(HISTOGRAM_REPORT_FLAG_UMA_TARGETED); + break; + + case HISTOGRAM_LOOKUP: + report_histogram_->Add(HISTOGRAM_REPORT_HISTOGRAM_LOOKUP); + break; + } +} + } // namespace base |