Commit 1fd80b7d authored by Luna Lu's avatar Luna Lu Committed by Commit Bot

Remove unused Chrome histograms Blink.UseCounter.SVGImage.*CSS*

Bug: 804645
Change-Id: I19e29e9d201eea3d6bd9e8a42f6e0621672ae2aa
Reviewed-on: https://chromium-review.googlesource.com/1100972Reviewed-by: default avatarRick Byers <rbyers@chromium.org>
Commit-Queue: Luna Lu <loonybear@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567642}
parent 99e5894e
......@@ -1298,17 +1298,11 @@ void UseCounter::DidCommitLoad(const LocalFrame* frame) {
css_recorded_.ClearAll();
animated_css_recorded_.ClearAll();
if (context_ != kDisabledContext && !mute_count_) {
// Only needs to count page visits on SVG histogram and extension histogram
// since the features histogram is being recorded on the browser side.
if (context_ != kDefaultContext)
// TODO(loonybear): Remove or move SVG features histogram and extension
// features histogram to the browser side.
if (!mute_count_ &&
(context_ == kSVGImageContext || context_ == kExtensionContext))
FeaturesHistogram().Count(static_cast<int>(WebFeature::kPageVisits));
if (context_ == kSVGImageContext) {
CssHistogram().Count(mojom::blink::kTotalPagesMeasuredCSSSampleId);
AnimatedCSSHistogram().Count(
mojom::blink::kTotalPagesMeasuredCSSSampleId);
}
}
}
void UseCounter::Count(const LocalFrame* frame, WebFeature feature) {
......@@ -1379,13 +1373,6 @@ void UseCounter::Count(CSSParserMode css_parser_mode,
if (!IsUseCounterEnabledForMode(css_parser_mode) || mute_count_)
return;
// TODO(loonybear): Remove this check once UseCounter is moved from Page to
// DocumentLoader. No features would be counted before
// UseCounter::DidCommitLoad (crbug.com/828416).
if (context_ == kDefaultContext &&
!Page::OrdinaryPages().Contains(source_frame->GetPage()))
return;
if (!css_recorded_.QuickGet(property)) {
// Note that HTTPArchive tooling looks specifically for this event - see
// https://github.com/HTTPArchive/httparchive/issues/59
......@@ -1393,11 +1380,6 @@ void UseCounter::Count(CSSParserMode css_parser_mode,
if (context_ != kDisabledContext && context_ != kExtensionContext) {
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"),
"CSSFirstUsed", "feature", sample_id);
// The CSS properties are being recorded on the browser side.
// TODO(loonybear): Record CSS properties for SVG documents on the browser
// side.
if (context_ == kSVGImageContext)
CssHistogram().Count(sample_id);
if (source_frame && source_frame->Client())
source_frame->Client()->DidObserveNewCssPropertyUsage(sample_id, false);
}
......@@ -1441,23 +1423,11 @@ void UseCounter::CountAnimatedCSS(CSSPropertyID property,
if (mute_count_)
return;
// TODO(loonybear): Remove this check once UseCounter is moved from Page to
// DocumentLoader. No features would be counted before
// UseCounter::DidCommitLoad (crbug.com/828416).
if (context_ == kDefaultContext &&
!Page::OrdinaryPages().Contains(source_frame->GetPage()))
return;
if (!animated_css_recorded_.QuickGet(property)) {
int sample_id = MapCSSPropertyIdToCSSSampleIdForHistogram(property);
if (context_ != kDisabledContext && context_ != kExtensionContext) {
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"),
"AnimatedCSSFirstUsed", "feature", sample_id);
// The CSS properties are being recorded on the browser side.
// TODO(loonybear): Record CSS properties for SVG documents on the browser
// side.
if (context_ == kSVGImageContext)
AnimatedCSSHistogram().Count(sample_id);
if (source_frame && source_frame->Client())
source_frame->Client()->DidObserveNewCssPropertyUsage(sample_id, true);
}
......
......@@ -20,13 +20,6 @@ const char kExtensionFeaturesHistogramName[] =
"Blink.UseCounter.Extensions.Features";
const char kSVGFeaturesHistogramName[] = "Blink.UseCounter.SVGImage.Features";
const char kSVGCSSHistogramName[] = "Blink.UseCounter.SVGImage.CSSProperties";
const char kSVGAnimatedCSSHistogramName[] =
"Blink.UseCounter.SVGImage.AnimatedCSSProperties";
const char* kHistogramList[] = {kExtensionFeaturesHistogramName,
kSVGCSSHistogramName,
kSVGAnimatedCSSHistogramName};
// In practice, SVGs always appear to be loaded with an about:blank URL
const char kSvgUrl[] = "about:blank";
......@@ -114,31 +107,6 @@ void UseCounterTest::HistogramBasicTest(
EXPECT_TRUE(counted(item));
histogram_tester_.ExpectBucketCount(histogram, histogram_map(item), 2);
histogram_tester_.ExpectTotalCount(histogram, 4);
// For all histograms, no other histograms besides |histogram| should
// be affected.
for (const std::string& unaffected_histogram : kHistogramList) {
if (unaffected_histogram == histogram)
continue;
// CSS histograms are never created in didCommitLoad when the context is
// extension.
if (histogram == kExtensionFeaturesHistogramName &&
unaffected_histogram.find("CSS") != std::string::npos)
continue;
// The expected total count for "Features" of unaffected histograms should
// be either:
// a. pageVisits, for "CSSProperties"; or
// b. 0 (pageVisits is 0), for others, including "SVGImage.CSSProperties"
// since no SVG images are loaded at all.
histogram_tester_.ExpectTotalCount(
unaffected_histogram,
unaffected_histogram.find("CSS") != std::string::npos
? histogram_tester_.GetBucketCount(
unaffected_histogram,
GetPageVisitsBucketforHistogram(unaffected_histogram))
: 0);
}
}
TEST_F(UseCounterTest, RecordingExtensions) {
......@@ -172,38 +140,6 @@ TEST_F(UseCounterTest, SVGImageContextFeatures) {
[&](LocalFrame* frame) { use_counter.DidCommitLoad(frame); }, kSvgUrl);
}
TEST_F(UseCounterTest, SVGImageContextCSSProperties) {
UseCounter use_counter(UseCounter::kSVGImageContext);
HistogramBasicTest<CSSPropertyID>(
kSVGCSSHistogramName, CSSPropertyFont, CSSPropertyZoom,
[&](CSSPropertyID property) -> bool {
return use_counter.IsCounted(property);
},
[&](CSSPropertyID property) {
use_counter.Count(kHTMLStandardMode, property, GetFrame());
},
[](CSSPropertyID property) -> int {
return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property);
},
[&](LocalFrame* frame) { use_counter.DidCommitLoad(frame); }, kSvgUrl);
}
TEST_F(UseCounterTest, SVGImageContextAnimatedCSSProperties) {
UseCounter use_counter(UseCounter::kSVGImageContext);
HistogramBasicTest<CSSPropertyID>(
kSVGAnimatedCSSHistogramName, CSSPropertyOpacity, CSSPropertyVariable,
[&](CSSPropertyID property) -> bool {
return use_counter.IsCountedAnimatedCSS(property);
},
[&](CSSPropertyID property) {
use_counter.CountAnimatedCSS(property, GetFrame());
},
[](CSSPropertyID property) -> int {
return UseCounter::MapCSSPropertyIdToCSSSampleIdForHistogram(property);
},
[&](LocalFrame* frame) { use_counter.DidCommitLoad(frame); }, kSvgUrl);
}
TEST_F(UseCounterTest, CSSSelectorPseudoIS) {
std::unique_ptr<DummyPageHolder> dummy_page_holder =
DummyPageHolder::Create(IntSize(800, 600));
......
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