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

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

Issue 2680423006: UseCounter: Introduce UseCounter::Observer for layout tests (Closed)
Patch Set: rebase Created 3 years, 10 months 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
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.h ('k') | third_party/WebKit/Source/core/page/Page.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f424c1430b58935699917abd1a4a054bb88f957c..d020ed4ef09f2fd7668c0ef77ea680aa9500eb66 100644
--- a/third_party/WebKit/Source/core/frame/UseCounter.cpp
+++ b/third_party/WebKit/Source/core/frame/UseCounter.cpp
@@ -1125,6 +1125,7 @@ void UseCounter::recordMeasurement(Feature feature) {
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"),
"FeatureFirstUsed", "feature", feature);
featuresHistogram().count(feature);
+ notifyFeatureCounted(feature);
}
m_featuresRecorded.quickSet(feature);
}
@@ -1143,6 +1144,10 @@ bool UseCounter::hasRecordedMeasurement(Feature feature) const {
return m_featuresRecorded.quickGet(feature);
}
+DEFINE_TRACE(UseCounter) {
+ visitor->trace(m_observers);
+}
+
void UseCounter::didCommitLoad(KURL url) {
m_legacyCounter.updateMeasurements();
@@ -1193,6 +1198,16 @@ bool UseCounter::isCounted(CSSPropertyID unresolvedProperty) {
return m_CSSRecorded.quickGet(unresolvedProperty);
}
+void UseCounter::addObserver(Document& document, Observer* observer) {
Rick Byers 2017/02/13 20:46:31 nit: IMHO this would make more sense as an instanc
nhiroki 2017/02/14 02:03:29 There is no special reason. I just aligned it with
+ Frame* frame = document.frame();
+ if (!frame)
+ return;
+ FrameHost* host = frame->host();
+ if (!host)
+ return;
+ host->useCounter().m_observers.insert(observer);
+}
+
bool UseCounter::isCounted(Document& document, const String& string) {
Frame* frame = document.frame();
if (!frame)
@@ -1249,6 +1264,17 @@ void UseCounter::count(Feature feature) {
recordMeasurement(feature);
}
+void UseCounter::notifyFeatureCounted(Feature feature) {
+ DCHECK(!m_muteCount);
+ DCHECK(!m_disableReporting);
+ HeapHashSet<Member<Observer>> toBeRemoved;
+ for (auto observer : m_observers) {
+ if (observer->onCountFeature(feature))
+ toBeRemoved.insert(observer);
+ }
+ m_observers.removeAll(toBeRemoved);
+}
+
EnumerationHistogram& UseCounter::featuresHistogram() const {
// 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
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.h ('k') | third_party/WebKit/Source/core/page/Page.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698