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

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

Issue 2680423006: UseCounter: Introduce UseCounter::Observer for layout tests (Closed)
Patch Set: instance method 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..79272a3075bb1af7a4b11567b0cf8e1fbf853488 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,11 @@ bool UseCounter::isCounted(CSSPropertyID unresolvedProperty) {
return m_CSSRecorded.quickGet(unresolvedProperty);
}
+void UseCounter::addObserver(Observer* observer) {
+ DCHECK(!m_observers.contains(observer));
+ m_observers.insert(observer);
+}
+
bool UseCounter::isCounted(Document& document, const String& string) {
Frame* frame = document.frame();
if (!frame)
@@ -1249,6 +1259,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