Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Unified Diff: third_party/WebKit/Source/core/frame/UseCounter.cpp

Issue 2604633002: Mute use counters for internal pages (Closed)
Patch Set: Update a related comment Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/UseCounter.cpp
diff --git a/third_party/WebKit/Source/core/frame/UseCounter.cpp b/third_party/WebKit/Source/core/frame/UseCounter.cpp
index 383f0723f01a99f0ed9db84c091198423fa87d0e..e8526fef78236ac52f0b6bda569dfcb4aabd7818 100644
--- a/third_party/WebKit/Source/core/frame/UseCounter.cpp
+++ b/third_party/WebKit/Source/core/frame/UseCounter.cpp
@@ -37,6 +37,7 @@
#include "core/workers/WorkerOrWorkletGlobalScope.h"
#include "platform/Histogram.h"
#include "platform/instrumentation/tracing/TraceEvent.h"
+#include "platform/weborigin/SchemeRegistry.h"
namespace {
@@ -1083,6 +1084,7 @@ int UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(
UseCounter::UseCounter(Context context)
: m_muteCount(0),
+ m_disableReporting(false),
m_context(context),
m_featuresRecorded(NumberOfFeatures),
m_CSSRecorded(lastUnresolvedCSSProperty + 1) {}
@@ -1107,9 +1109,11 @@ void UseCounter::recordMeasurement(Feature feature) {
if (!m_featuresRecorded.quickGet(feature)) {
// Note that HTTPArchive tooling looks specifically for this event - see
// https://github.com/HTTPArchive/httparchive/issues/59
- TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"),
- "FeatureFirstUsed", "feature", feature);
- featuresHistogram().count(feature);
+ if (!m_disableReporting) {
+ TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"),
+ "FeatureFirstUsed", "feature", feature);
+ featuresHistogram().count(feature);
+ }
m_featuresRecorded.quickSet(feature);
}
m_legacyCounter.countFeature(feature);
@@ -1127,14 +1131,26 @@ bool UseCounter::hasRecordedMeasurement(Feature feature) const {
return m_featuresRecorded.quickGet(feature);
}
-void UseCounter::didCommitLoad() {
+void UseCounter::didCommitLoad(KURL url) {
m_legacyCounter.updateMeasurements();
- // TODO: Is didCommitLoad really the right time to do this? crbug.com/608040
+ // Reset state from previous load.
+ m_disableReporting = false;
+
+ // Use the protocol of the document being loaded into the main frame to
+ // decide whether this page is interesting from a metrics perspective.
+ // Note that SVGImage cases always have an about:blank URL
+ if (m_context == DefaultContext &&
+ !SchemeRegistry::shouldTrackUsageMetricsForScheme(url.protocol())) {
+ m_disableReporting = true;
+ }
+
m_featuresRecorded.clearAll();
- featuresHistogram().count(PageVisits);
m_CSSRecorded.clearAll();
- cssHistogram().count(totalPagesMeasuredCSSSampleId());
+ if (!m_disableReporting && !m_muteCount) {
+ featuresHistogram().count(PageVisits);
+ cssHistogram().count(totalPagesMeasuredCSSSampleId());
+ }
}
void UseCounter::count(const Frame* frame, Feature feature) {
@@ -1207,9 +1223,11 @@ void UseCounter::count(CSSParserMode cssParserMode, CSSPropertyID property) {
// Note that HTTPArchive tooling looks specifically for this event - see
// https://github.com/HTTPArchive/httparchive/issues/59
int sampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(property);
- TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"),
- "CSSFirstUsed", "feature", sampleId);
- cssHistogram().count(sampleId);
+ if (!m_disableReporting) {
+ TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"),
+ "CSSFirstUsed", "feature", sampleId);
+ cssHistogram().count(sampleId);
+ }
m_CSSRecorded.quickSet(property);
}
m_legacyCounter.countCSS(property);
@@ -1241,10 +1259,12 @@ UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) {
}
EnumerationHistogram& UseCounter::featuresHistogram() const {
- // TODO(rbyers): Fix the SVG case. crbug.com/236262
- // Eg. every SVGImage has it's own Page instance, they should probably all be
- // delegating their UseCounter to the containing Page. For now just use a
- // separate histogram.
+ // Every SVGImage has it's own Page instance, and multiple web pages can
+ // share the usage of a single SVGImage. Ideally perhaps we'd delegate
+ // metrics from an SVGImage to one of the Page's it's displayed in, but
+ // that's tricky (SVGImage is intentionally isolated, and the Page that
+ // created it may not even exist anymore).
+ // So instead we just use a dedicated histogram for the SVG case.
DEFINE_STATIC_LOCAL(blink::EnumerationHistogram, histogram,
("WebCore.UseCounter_TEST.Features",
blink::UseCounter::NumberOfFeatures));

Powered by Google App Engine
This is Rietveld 408576698