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

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

Issue 2393313002: reflow comments in core/frame (Closed)
Patch Set: tweak Created 4 years, 2 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 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 case CSSPropertyOffsetPath: 1051 case CSSPropertyOffsetPath:
1052 return 541; 1052 return 541;
1053 case CSSPropertyOffsetRotation: 1053 case CSSPropertyOffsetRotation:
1054 return 542; 1054 return 542;
1055 case CSSPropertyOffset: 1055 case CSSPropertyOffset:
1056 return 543; 1056 return 543;
1057 case CSSPropertyOffsetAnchor: 1057 case CSSPropertyOffsetAnchor:
1058 return 544; 1058 return 544;
1059 case CSSPropertyOffsetPosition: 1059 case CSSPropertyOffsetPosition:
1060 return 545; 1060 return 545;
1061 // 1. Add new features above this line (don't change the assigned numbers of the existing 1061 // 1. Add new features above this line (don't change the assigned numbers of
1062 // items). 1062 // the existing items).
1063 // 2. Update kMaximumCSSSampleId with the new maximum value. 1063 // 2. Update kMaximumCSSSampleId with the new maximum value.
1064 // 3. Run the update_use_counter_css.py script in 1064 // 3. Run the update_use_counter_css.py script in
1065 // chromium/src/tools/metrics/histograms to update the UMA histogram names. 1065 // chromium/src/tools/metrics/histograms to update the UMA histogram names.
1066 1066
1067 case CSSPropertyInvalid: 1067 case CSSPropertyInvalid:
1068 ASSERT_NOT_REACHED(); 1068 ASSERT_NOT_REACHED();
1069 return 0; 1069 return 0;
1070 } 1070 }
1071 1071
1072 ASSERT_NOT_REACHED(); 1072 ASSERT_NOT_REACHED();
(...skipping 17 matching lines...) Expand all
1090 void UseCounter::recordMeasurement(Feature feature) { 1090 void UseCounter::recordMeasurement(Feature feature) {
1091 if (m_muteCount) 1091 if (m_muteCount)
1092 return; 1092 return;
1093 1093
1094 DCHECK(feature != OBSOLETE_PageDestruction && 1094 DCHECK(feature != OBSOLETE_PageDestruction &&
1095 feature != 1095 feature !=
1096 PageVisits); // PageDestruction is reserved as a scaling factor. 1096 PageVisits); // PageDestruction is reserved as a scaling factor.
1097 DCHECK(feature < NumberOfFeatures); 1097 DCHECK(feature < NumberOfFeatures);
1098 1098
1099 if (!m_featuresRecorded.quickGet(feature)) { 1099 if (!m_featuresRecorded.quickGet(feature)) {
1100 // Note that HTTPArchive tooling looks specifically for this event - see htt ps://github.com/HTTPArchive/httparchive/issues/59 1100 // Note that HTTPArchive tooling looks specifically for this event - see
1101 // https://github.com/HTTPArchive/httparchive/issues/59
1101 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"), 1102 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"),
1102 "FeatureFirstUsed", "feature", feature); 1103 "FeatureFirstUsed", "feature", feature);
1103 featuresHistogram().count(feature); 1104 featuresHistogram().count(feature);
1104 m_featuresRecorded.quickSet(feature); 1105 m_featuresRecorded.quickSet(feature);
1105 } 1106 }
1106 m_legacyCounter.countFeature(feature); 1107 m_legacyCounter.countFeature(feature);
1107 } 1108 }
1108 1109
1109 bool UseCounter::hasRecordedMeasurement(Feature feature) const { 1110 bool UseCounter::hasRecordedMeasurement(Feature feature) const {
1110 if (m_muteCount) 1111 if (m_muteCount)
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 } 1214 }
1214 1215
1215 void UseCounter::count(CSSParserMode cssParserMode, CSSPropertyID property) { 1216 void UseCounter::count(CSSParserMode cssParserMode, CSSPropertyID property) {
1216 DCHECK(property >= firstCSSProperty); 1217 DCHECK(property >= firstCSSProperty);
1217 DCHECK(property <= lastUnresolvedCSSProperty); 1218 DCHECK(property <= lastUnresolvedCSSProperty);
1218 1219
1219 if (!isUseCounterEnabledForMode(cssParserMode) || m_muteCount) 1220 if (!isUseCounterEnabledForMode(cssParserMode) || m_muteCount)
1220 return; 1221 return;
1221 1222
1222 if (!m_CSSRecorded.quickGet(property)) { 1223 if (!m_CSSRecorded.quickGet(property)) {
1223 // Note that HTTPArchive tooling looks specifically for this event - see htt ps://github.com/HTTPArchive/httparchive/issues/59 1224 // Note that HTTPArchive tooling looks specifically for this event - see
1225 // https://github.com/HTTPArchive/httparchive/issues/59
1224 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"), 1226 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"),
1225 "CSSFeatureFirstUsed", "feature", property); 1227 "CSSFeatureFirstUsed", "feature", property);
1226 cssHistogram().count(mapCSSPropertyIdToCSSSampleIdForHistogram(property)); 1228 cssHistogram().count(mapCSSPropertyIdToCSSSampleIdForHistogram(property));
1227 m_CSSRecorded.quickSet(property); 1229 m_CSSRecorded.quickSet(property);
1228 } 1230 }
1229 m_legacyCounter.countCSS(property); 1231 m_legacyCounter.countCSS(property);
1230 } 1232 }
1231 1233
1232 void UseCounter::count(Feature feature) { 1234 void UseCounter::count(Feature feature) {
1233 DCHECK(Deprecation::deprecationMessage(feature).isEmpty()); 1235 DCHECK(Deprecation::deprecationMessage(feature).isEmpty());
(...skipping 15 matching lines...) Expand all
1249 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) { 1251 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) {
1250 // FIXME: We may want to handle stylesheets that have multiple owners 1252 // FIXME: We may want to handle stylesheets that have multiple owners
1251 // https://crbug.com/242125 1253 // https://crbug.com/242125
1252 if (sheetContents && sheetContents->hasSingleOwnerNode()) 1254 if (sheetContents && sheetContents->hasSingleOwnerNode())
1253 return getFrom(sheetContents->singleOwnerDocument()); 1255 return getFrom(sheetContents->singleOwnerDocument());
1254 return 0; 1256 return 0;
1255 } 1257 }
1256 1258
1257 EnumerationHistogram& UseCounter::featuresHistogram() const { 1259 EnumerationHistogram& UseCounter::featuresHistogram() const {
1258 // TODO(rbyers): Fix the SVG case. crbug.com/236262 1260 // TODO(rbyers): Fix the SVG case. crbug.com/236262
1259 // Eg. every SVGImage has it's own Page instance, they should probably all be delegating 1261 // Eg. every SVGImage has it's own Page instance, they should probably all be
1260 // their UseCounter to the containing Page. For now just use a separate histo gram. 1262 // delegating their UseCounter to the containing Page. For now just use a
1263 // separate histogram.
1261 DEFINE_STATIC_LOCAL(blink::EnumerationHistogram, histogram, 1264 DEFINE_STATIC_LOCAL(blink::EnumerationHistogram, histogram,
1262 ("WebCore.UseCounter_TEST.Features", 1265 ("WebCore.UseCounter_TEST.Features",
1263 blink::UseCounter::NumberOfFeatures)); 1266 blink::UseCounter::NumberOfFeatures));
1264 DEFINE_STATIC_LOCAL(blink::EnumerationHistogram, svgHistogram, 1267 DEFINE_STATIC_LOCAL(blink::EnumerationHistogram, svgHistogram,
1265 ("WebCore.UseCounter_TEST.SVGImage.Features", 1268 ("WebCore.UseCounter_TEST.SVGImage.Features",
1266 blink::UseCounter::NumberOfFeatures)); 1269 blink::UseCounter::NumberOfFeatures));
1267 1270
1268 return m_context == SVGImageContext ? svgHistogram : histogram; 1271 return m_context == SVGImageContext ? svgHistogram : histogram;
1269 } 1272 }
1270 1273
1271 EnumerationHistogram& UseCounter::cssHistogram() const { 1274 EnumerationHistogram& UseCounter::cssHistogram() const {
1272 DEFINE_STATIC_LOCAL( 1275 DEFINE_STATIC_LOCAL(
1273 blink::EnumerationHistogram, histogram, 1276 blink::EnumerationHistogram, histogram,
1274 ("WebCore.UseCounter_TEST.CSSProperties", kMaximumCSSSampleId)); 1277 ("WebCore.UseCounter_TEST.CSSProperties", kMaximumCSSSampleId));
1275 DEFINE_STATIC_LOCAL( 1278 DEFINE_STATIC_LOCAL(
1276 blink::EnumerationHistogram, svgHistogram, 1279 blink::EnumerationHistogram, svgHistogram,
1277 ("WebCore.UseCounter_TEST.SVGImage.CSSProperties", kMaximumCSSSampleId)); 1280 ("WebCore.UseCounter_TEST.SVGImage.CSSProperties", kMaximumCSSSampleId));
1278 1281
1279 return m_context == SVGImageContext ? svgHistogram : histogram; 1282 return m_context == SVGImageContext ? svgHistogram : histogram;
1280 } 1283 }
1281 1284
1282 /* 1285 /*
1283 * 1286 *
1284 * LEGACY metrics support - WebCore.FeatureObserver is to be superceded by WebCo re.UseCounter 1287 * LEGACY metrics support - WebCore.FeatureObserver is to be superceded by
1288 * WebCore.UseCounter
1285 * 1289 *
1286 */ 1290 */
1287 1291
1288 static EnumerationHistogram& featureObserverHistogram() { 1292 static EnumerationHistogram& featureObserverHistogram() {
1289 DEFINE_STATIC_LOCAL( 1293 DEFINE_STATIC_LOCAL(
1290 EnumerationHistogram, histogram, 1294 EnumerationHistogram, histogram,
1291 ("WebCore.FeatureObserver", UseCounter::NumberOfFeatures)); 1295 ("WebCore.FeatureObserver", UseCounter::NumberOfFeatures));
1292 return histogram; 1296 return histogram;
1293 } 1297 }
1294 1298
1295 UseCounter::LegacyCounter::LegacyCounter() 1299 UseCounter::LegacyCounter::LegacyCounter()
1296 : m_featureBits(NumberOfFeatures), 1300 : m_featureBits(NumberOfFeatures),
1297 m_CSSBits(lastUnresolvedCSSProperty + 1) {} 1301 m_CSSBits(lastUnresolvedCSSProperty + 1) {}
1298 1302
1299 UseCounter::LegacyCounter::~LegacyCounter() { 1303 UseCounter::LegacyCounter::~LegacyCounter() {
1300 // PageDestruction was intended to be used as a scale, but it's broken (due to fast shutdown). 1304 // PageDestruction was intended to be used as a scale, but it's broken (due to
1301 // See https://crbug.com/597963. 1305 // fast shutdown). See https://crbug.com/597963.
1302 featureObserverHistogram().count(OBSOLETE_PageDestruction); 1306 featureObserverHistogram().count(OBSOLETE_PageDestruction);
1303 updateMeasurements(); 1307 updateMeasurements();
1304 } 1308 }
1305 1309
1306 void UseCounter::LegacyCounter::countFeature(Feature feature) { 1310 void UseCounter::LegacyCounter::countFeature(Feature feature) {
1307 m_featureBits.quickSet(feature); 1311 m_featureBits.quickSet(feature);
1308 } 1312 }
1309 1313
1310 void UseCounter::LegacyCounter::countCSS(CSSPropertyID property) { 1314 void UseCounter::LegacyCounter::countCSS(CSSPropertyID property) {
1311 m_CSSBits.quickSet(property); 1315 m_CSSBits.quickSet(property);
1312 } 1316 }
1313 1317
1314 void UseCounter::LegacyCounter::updateMeasurements() { 1318 void UseCounter::LegacyCounter::updateMeasurements() {
1315 EnumerationHistogram& featureHistogram = featureObserverHistogram(); 1319 EnumerationHistogram& featureHistogram = featureObserverHistogram();
1316 featureHistogram.count(PageVisits); 1320 featureHistogram.count(PageVisits);
1317 for (size_t i = 0; i < NumberOfFeatures; ++i) { 1321 for (size_t i = 0; i < NumberOfFeatures; ++i) {
1318 if (m_featureBits.quickGet(i)) 1322 if (m_featureBits.quickGet(i))
1319 featureHistogram.count(i); 1323 featureHistogram.count(i);
1320 } 1324 }
1321 // Clearing count bits is timing sensitive. 1325 // Clearing count bits is timing sensitive.
1322 m_featureBits.clearAll(); 1326 m_featureBits.clearAll();
1323 1327
1324 // FIXME: Sometimes this function is called more than once per page. The follo wing 1328 // FIXME: Sometimes this function is called more than once per page. The
1325 // bool guards against incrementing the page count when there are no CS S 1329 // following bool guards against incrementing the page count when there are no
1326 // bits set. https://crbug.com/236262. 1330 // CSS bits set. https://crbug.com/236262.
1327 DEFINE_STATIC_LOCAL( 1331 DEFINE_STATIC_LOCAL(
1328 EnumerationHistogram, cssPropertiesHistogram, 1332 EnumerationHistogram, cssPropertiesHistogram,
1329 ("WebCore.FeatureObserver.CSSProperties", kMaximumCSSSampleId)); 1333 ("WebCore.FeatureObserver.CSSProperties", kMaximumCSSSampleId));
1330 bool needsPagesMeasuredUpdate = false; 1334 bool needsPagesMeasuredUpdate = false;
1331 for (size_t i = firstCSSProperty; i <= lastUnresolvedCSSProperty; ++i) { 1335 for (size_t i = firstCSSProperty; i <= lastUnresolvedCSSProperty; ++i) {
1332 if (m_CSSBits.quickGet(i)) { 1336 if (m_CSSBits.quickGet(i)) {
1333 int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram( 1337 int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(
1334 static_cast<CSSPropertyID>(i)); 1338 static_cast<CSSPropertyID>(i));
1335 cssPropertiesHistogram.count(cssSampleId); 1339 cssPropertiesHistogram.count(cssSampleId);
1336 needsPagesMeasuredUpdate = true; 1340 needsPagesMeasuredUpdate = true;
1337 } 1341 }
1338 } 1342 }
1339 1343
1340 if (needsPagesMeasuredUpdate) 1344 if (needsPagesMeasuredUpdate)
1341 cssPropertiesHistogram.count(totalPagesMeasuredCSSSampleId()); 1345 cssPropertiesHistogram.count(totalPagesMeasuredCSSSampleId());
1342 1346
1343 m_CSSBits.clearAll(); 1347 m_CSSBits.clearAll();
1344 } 1348 }
1345 1349
1346 } // namespace blink 1350 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.h ('k') | third_party/WebKit/Source/core/frame/UseCounterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698