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

Side by Side Diff: third_party/WebKit/Source/core/frame/UseCounter.cpp

Issue 2678143003: Move CSS animations use counters to UseCounter (Closed)
Patch Set: Replace FIXME with test expectation file 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google, Inc. All rights reserved. 2 * Copyright (C) 2012 Google, Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 1092
1093 ASSERT_NOT_REACHED(); 1093 ASSERT_NOT_REACHED();
1094 return 0; 1094 return 0;
1095 } 1095 }
1096 1096
1097 UseCounter::UseCounter(Context context) 1097 UseCounter::UseCounter(Context context)
1098 : m_muteCount(0), 1098 : m_muteCount(0),
1099 m_disableReporting(false), 1099 m_disableReporting(false),
1100 m_context(context), 1100 m_context(context),
1101 m_featuresRecorded(NumberOfFeatures), 1101 m_featuresRecorded(NumberOfFeatures),
1102 m_CSSRecorded(numCSSPropertyIDs) {} 1102 m_CSSRecorded(numCSSPropertyIDs),
1103 m_animatedCSSRecorded(numCSSPropertyIDs) {}
1103 1104
1104 void UseCounter::muteForInspector() { 1105 void UseCounter::muteForInspector() {
1105 m_muteCount++; 1106 m_muteCount++;
1106 } 1107 }
1107 1108
1108 void UseCounter::unmuteForInspector() { 1109 void UseCounter::unmuteForInspector() {
1109 m_muteCount--; 1110 m_muteCount--;
1110 } 1111 }
1111 1112
1112 void UseCounter::recordMeasurement(Feature feature) { 1113 void UseCounter::recordMeasurement(Feature feature) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 // Use the protocol of the document being loaded into the main frame to 1158 // Use the protocol of the document being loaded into the main frame to
1158 // decide whether this page is interesting from a metrics perspective. 1159 // decide whether this page is interesting from a metrics perspective.
1159 // Note that SVGImage cases always have an about:blank URL 1160 // Note that SVGImage cases always have an about:blank URL
1160 if (m_context == DefaultContext && 1161 if (m_context == DefaultContext &&
1161 !SchemeRegistry::shouldTrackUsageMetricsForScheme(url.protocol())) { 1162 !SchemeRegistry::shouldTrackUsageMetricsForScheme(url.protocol())) {
1162 m_disableReporting = true; 1163 m_disableReporting = true;
1163 } 1164 }
1164 1165
1165 m_featuresRecorded.clearAll(); 1166 m_featuresRecorded.clearAll();
1166 m_CSSRecorded.clearAll(); 1167 m_CSSRecorded.clearAll();
1168 m_animatedCSSRecorded.clearAll();
1167 if (!m_disableReporting && !m_muteCount) { 1169 if (!m_disableReporting && !m_muteCount) {
1168 featuresHistogram().count(PageVisits); 1170 featuresHistogram().count(PageVisits);
1169 cssHistogram().count(totalPagesMeasuredCSSSampleId()); 1171 cssHistogram().count(totalPagesMeasuredCSSSampleId());
1172 animatedCSSHistogram().count(totalPagesMeasuredCSSSampleId());
1170 } 1173 }
1171 } 1174 }
1172 1175
1173 void UseCounter::count(const Frame* frame, Feature feature) { 1176 void UseCounter::count(const Frame* frame, Feature feature) {
1174 if (!frame) 1177 if (!frame)
1175 return; 1178 return;
1176 FrameHost* host = frame->host(); 1179 FrameHost* host = frame->host();
1177 if (!host) 1180 if (!host)
1178 return; 1181 return;
1179 1182
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 } 1232 }
1230 1233
1231 void UseCounter::countCrossOriginIframe(const Document& document, 1234 void UseCounter::countCrossOriginIframe(const Document& document,
1232 Feature feature) { 1235 Feature feature) {
1233 LocalFrame* frame = document.frame(); 1236 LocalFrame* frame = document.frame();
1234 if (frame && frame->isCrossOriginSubframe()) 1237 if (frame && frame->isCrossOriginSubframe())
1235 count(frame, feature); 1238 count(frame, feature);
1236 } 1239 }
1237 1240
1238 void UseCounter::count(CSSParserMode cssParserMode, CSSPropertyID property) { 1241 void UseCounter::count(CSSParserMode cssParserMode, CSSPropertyID property) {
1242 // FIXME(suzyh): Count custom properties as well as named properties
1239 DCHECK(isCSSPropertyIDWithName(property)); 1243 DCHECK(isCSSPropertyIDWithName(property));
1240 1244
1241 if (!isUseCounterEnabledForMode(cssParserMode) || m_muteCount) 1245 if (!isUseCounterEnabledForMode(cssParserMode) || m_muteCount)
1242 return; 1246 return;
1243 1247
1244 if (!m_CSSRecorded.quickGet(property)) { 1248 if (!m_CSSRecorded.quickGet(property)) {
1245 // Note that HTTPArchive tooling looks specifically for this event - see 1249 // Note that HTTPArchive tooling looks specifically for this event - see
1246 // https://github.com/HTTPArchive/httparchive/issues/59 1250 // https://github.com/HTTPArchive/httparchive/issues/59
1247 int sampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(property); 1251 int sampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(property);
1248 if (!m_disableReporting) { 1252 if (!m_disableReporting) {
1249 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"), 1253 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"),
1250 "CSSFirstUsed", "feature", sampleId); 1254 "CSSFirstUsed", "feature", sampleId);
1251 cssHistogram().count(sampleId); 1255 cssHistogram().count(sampleId);
1252 } 1256 }
1253 m_CSSRecorded.quickSet(property); 1257 m_CSSRecorded.quickSet(property);
1254 } 1258 }
1255 m_legacyCounter.countCSS(property); 1259 m_legacyCounter.countCSS(property);
1256 } 1260 }
1257 1261
1258 void UseCounter::count(Feature feature) { 1262 void UseCounter::count(Feature feature) {
1259 recordMeasurement(feature); 1263 recordMeasurement(feature);
1260 } 1264 }
1261 1265
1266 bool UseCounter::isCountedAnimatedCSS(CSSPropertyID unresolvedProperty) {
1267 return m_animatedCSSRecorded.quickGet(unresolvedProperty);
1268 }
1269
1270 bool UseCounter::isCountedAnimatedCSS(Document& document,
1271 const String& string) {
1272 Frame* frame = document.frame();
1273 if (!frame)
1274 return false;
1275 FrameHost* host = frame->host();
1276 if (!host)
1277 return false;
1278
1279 CSSPropertyID unresolvedProperty = unresolvedCSSPropertyID(string);
1280 if (unresolvedProperty == CSSPropertyInvalid)
1281 return false;
1282 return host->useCounter().isCountedAnimatedCSS(unresolvedProperty);
1283 }
1284
1285 void UseCounter::countAnimatedCSS(const Document& document,
1286 CSSPropertyID property) {
1287 const Frame* frame = document.frame();
1288 if (!frame)
1289 return;
1290 FrameHost* host = frame->host();
1291 if (!host)
1292 return;
1293
1294 host->useCounter().countAnimatedCSS(property);
1295 }
1296
1297 void UseCounter::countAnimatedCSS(CSSPropertyID property) {
1298 DCHECK(isCSSPropertyIDWithName(property) || property == CSSPropertyVariable);
1299
1300 if (m_muteCount)
1301 return;
1302
1303 if (!m_animatedCSSRecorded.quickGet(property)) {
1304 int sampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(property);
1305 if (!m_disableReporting) {
1306 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"),
1307 "AnimatedCSSFirstUsed", "feature", sampleId);
Rick Byers 2017/02/25 15:10:57 Note if you'd like to get this data into HTTP Arch
1308 animatedCSSHistogram().count(sampleId);
1309 }
1310 m_animatedCSSRecorded.quickSet(property);
1311 }
1312 }
1313
1262 void UseCounter::notifyFeatureCounted(Feature feature) { 1314 void UseCounter::notifyFeatureCounted(Feature feature) {
1263 DCHECK(!m_muteCount); 1315 DCHECK(!m_muteCount);
1264 DCHECK(!m_disableReporting); 1316 DCHECK(!m_disableReporting);
1265 HeapHashSet<Member<Observer>> toBeRemoved; 1317 HeapHashSet<Member<Observer>> toBeRemoved;
1266 for (auto observer : m_observers) { 1318 for (auto observer : m_observers) {
1267 if (observer->onCountFeature(feature)) 1319 if (observer->onCountFeature(feature))
1268 toBeRemoved.insert(observer); 1320 toBeRemoved.insert(observer);
1269 } 1321 }
1270 m_observers.removeAll(toBeRemoved); 1322 m_observers.removeAll(toBeRemoved);
1271 } 1323 }
(...skipping 18 matching lines...) Expand all
1290 EnumerationHistogram& UseCounter::cssHistogram() const { 1342 EnumerationHistogram& UseCounter::cssHistogram() const {
1291 DEFINE_STATIC_LOCAL(blink::EnumerationHistogram, histogram, 1343 DEFINE_STATIC_LOCAL(blink::EnumerationHistogram, histogram,
1292 ("Blink.UseCounter.CSSProperties", kMaximumCSSSampleId)); 1344 ("Blink.UseCounter.CSSProperties", kMaximumCSSSampleId));
1293 DEFINE_STATIC_LOCAL( 1345 DEFINE_STATIC_LOCAL(
1294 blink::EnumerationHistogram, svgHistogram, 1346 blink::EnumerationHistogram, svgHistogram,
1295 ("Blink.UseCounter.SVGImage.CSSProperties", kMaximumCSSSampleId)); 1347 ("Blink.UseCounter.SVGImage.CSSProperties", kMaximumCSSSampleId));
1296 1348
1297 return m_context == SVGImageContext ? svgHistogram : histogram; 1349 return m_context == SVGImageContext ? svgHistogram : histogram;
1298 } 1350 }
1299 1351
1352 EnumerationHistogram& UseCounter::animatedCSSHistogram() const {
1353 DEFINE_STATIC_LOCAL(
1354 blink::EnumerationHistogram, histogram,
1355 ("Blink.UseCounter.AnimatedCSSProperties", kMaximumCSSSampleId));
1356 DEFINE_STATIC_LOCAL(
1357 blink::EnumerationHistogram, svgHistogram,
1358 ("Blink.UseCounter.SVGImage.AnimatedCSSProperties", kMaximumCSSSampleId));
1359
1360 return m_context == SVGImageContext ? svgHistogram : histogram;
1361 }
1362
1300 /* 1363 /*
1301 * 1364 *
1302 * LEGACY metrics support - WebCore.FeatureObserver is to be superceded by 1365 * LEGACY metrics support - WebCore.FeatureObserver is to be superceded by
1303 * WebCore.UseCounter 1366 * WebCore.UseCounter
1304 * 1367 *
1305 */ 1368 */
1306 1369
1307 static EnumerationHistogram& featureObserverHistogram() { 1370 static EnumerationHistogram& featureObserverHistogram() {
1308 DEFINE_STATIC_LOCAL( 1371 DEFINE_STATIC_LOCAL(
1309 EnumerationHistogram, histogram, 1372 EnumerationHistogram, histogram,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 } 1418 }
1356 } 1419 }
1357 1420
1358 if (needsPagesMeasuredUpdate) 1421 if (needsPagesMeasuredUpdate)
1359 cssPropertiesHistogram.count(totalPagesMeasuredCSSSampleId()); 1422 cssPropertiesHistogram.count(totalPagesMeasuredCSSSampleId());
1360 1423
1361 m_CSSBits.clearAll(); 1424 m_CSSBits.clearAll();
1362 } 1425 }
1363 1426
1364 } // namespace blink 1427 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698