Commit 59e331da authored by Jun Kokatsu's avatar Jun Kokatsu Committed by Commit Bot

Prevent dummy histograms from appearing in chrome://histograms

This change removes dummy histograms in chrome://histograms

Bug: 1085912
Change-Id: I4fda6a684a20ce2effd601e78a7d601cdd29f4ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2214041Reviewed-by: default avatardpapad <dpapad@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Commit-Queue: Jun Kokatsu <Jun.Kokatsu@microsoft.com>
Auto-Submit: Jun Kokatsu <Jun.Kokatsu@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#773983}
parent 40342cdf
......@@ -101,10 +101,7 @@ std::unique_ptr<HistogramSamples> DummyHistogram::SnapshotFinalDelta() const {
}
base::DictionaryValue DummyHistogram::ToGraphDict() const {
base::DictionaryValue dict;
dict.SetString("header", "dummy");
dict.SetString("body", "dummy");
return dict;
return base::DictionaryValue();
}
} // namespace base
......@@ -236,7 +236,8 @@ class BASE_EXPORT HistogramBase {
// The following method provides graphical histogram displays.
virtual void WriteAscii(std::string* output) const = 0;
// Returns histogram data as a Dict with the following format:
// Returns histograms data as a Dict (or an empty dict if not available),
// with the following format:
// {"header": "Name of the histogram with samples, mean, and/or flags",
// "body": "ASCII histogram representation"}
virtual base::DictionaryValue ToGraphDict() const = 0;
......
......@@ -33,7 +33,7 @@ HistogramsInternalsUIBrowserTest.prototype = {
TEST_F('HistogramsInternalsUIBrowserTest', 'RefreshHistograms', function() {
test('check refresh button replaces existing histograms', function() {
cr.sendWithPromise('requestHistograms', '')
return cr.sendWithPromise('requestHistograms', '')
.then(addHistograms)
.finally(() => {
const histogramHeader = 'Histogram: HTMLOut recorded 5 samples';
......@@ -44,5 +44,19 @@ TEST_F('HistogramsInternalsUIBrowserTest', 'RefreshHistograms', function() {
});
});
mocha.run();
});
TEST_F('HistogramsInternalsUIBrowserTest', 'NoDummyHistograms', function() {
test('check no dummy histogram is present', function() {
return cr.sendWithPromise('requestHistograms', '')
.then(addHistograms)
.finally(() => {
document.querySelectorAll('h4').forEach(header => {
assertNotEquals(header.textContent, '');
});
});
});
mocha.run();
});
\ No newline at end of file
......@@ -76,7 +76,8 @@ void HistogramsMessageHandler::HandleRequestHistograms(
base::StatisticsRecorder::Sort(base::StatisticsRecorder::WithName(
base::StatisticsRecorder::GetHistograms(), query))) {
base::DictionaryValue histogram_dict = histogram->ToGraphDict();
histograms_list.Append(std::move(histogram_dict));
if (!histogram_dict.empty())
histograms_list.Append(std::move(histogram_dict));
}
ResolveJavascriptCallback(base::Value(callback_id),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment