OLD | NEW |
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 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 } | 1158 } |
1159 | 1159 |
1160 m_featuresRecorded.clearAll(); | 1160 m_featuresRecorded.clearAll(); |
1161 m_CSSRecorded.clearAll(); | 1161 m_CSSRecorded.clearAll(); |
1162 if (!m_disableReporting && !m_muteCount) { | 1162 if (!m_disableReporting && !m_muteCount) { |
1163 featuresHistogram().count(PageVisits); | 1163 featuresHistogram().count(PageVisits); |
1164 cssHistogram().count(totalPagesMeasuredCSSSampleId()); | 1164 cssHistogram().count(totalPagesMeasuredCSSSampleId()); |
1165 } | 1165 } |
1166 } | 1166 } |
1167 | 1167 |
| 1168 // static |
| 1169 const Document* UseCounter::singleOwnerDocument( |
| 1170 const StyleSheetContents* styleSheetContents) { |
| 1171 // FIXME: We may want to handle stylesheets that have multiple owners |
| 1172 // https://crbug.com/242125 |
| 1173 if (styleSheetContents && styleSheetContents->hasSingleOwnerNode()) |
| 1174 return styleSheetContents->singleOwnerDocument(); |
| 1175 return nullptr; |
| 1176 } |
| 1177 |
| 1178 // static |
| 1179 const Document* UseCounter::singleOwnerDocument( |
| 1180 const CSSStyleSheet* styleSheet) { |
| 1181 if (styleSheet) |
| 1182 return UseCounter::singleOwnerDocument(styleSheet->contents()); |
| 1183 return nullptr; |
| 1184 } |
| 1185 |
1168 void UseCounter::count(const Frame* frame, Feature feature) { | 1186 void UseCounter::count(const Frame* frame, Feature feature) { |
1169 if (!frame) | 1187 if (!frame) |
1170 return; | 1188 return; |
1171 FrameHost* host = frame->host(); | 1189 FrameHost* host = frame->host(); |
1172 if (!host) | 1190 if (!host) |
1173 return; | 1191 return; |
1174 | 1192 |
1175 host->useCounter().count(feature); | 1193 host->useCounter().count(feature); |
1176 } | 1194 } |
1177 | 1195 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 m_CSSRecorded.quickSet(property); | 1261 m_CSSRecorded.quickSet(property); |
1244 } | 1262 } |
1245 m_legacyCounter.countCSS(property); | 1263 m_legacyCounter.countCSS(property); |
1246 } | 1264 } |
1247 | 1265 |
1248 void UseCounter::count(Feature feature) { | 1266 void UseCounter::count(Feature feature) { |
1249 DCHECK(Deprecation::deprecationMessage(feature).isEmpty()); | 1267 DCHECK(Deprecation::deprecationMessage(feature).isEmpty()); |
1250 recordMeasurement(feature); | 1268 recordMeasurement(feature); |
1251 } | 1269 } |
1252 | 1270 |
1253 UseCounter* UseCounter::getFrom(const Document* document) { | |
1254 if (document && document->frameHost()) | |
1255 return &document->frameHost()->useCounter(); | |
1256 return 0; | |
1257 } | |
1258 | |
1259 UseCounter* UseCounter::getFrom(const CSSStyleSheet* sheet) { | |
1260 if (sheet) | |
1261 return getFrom(sheet->contents()); | |
1262 return 0; | |
1263 } | |
1264 | |
1265 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) { | |
1266 // FIXME: We may want to handle stylesheets that have multiple owners | |
1267 // https://crbug.com/242125 | |
1268 if (sheetContents && sheetContents->hasSingleOwnerNode()) | |
1269 return getFrom(sheetContents->singleOwnerDocument()); | |
1270 return 0; | |
1271 } | |
1272 | |
1273 EnumerationHistogram& UseCounter::featuresHistogram() const { | 1271 EnumerationHistogram& UseCounter::featuresHistogram() const { |
1274 // Every SVGImage has it's own Page instance, and multiple web pages can | 1272 // Every SVGImage has it's own Page instance, and multiple web pages can |
1275 // share the usage of a single SVGImage. Ideally perhaps we'd delegate | 1273 // share the usage of a single SVGImage. Ideally perhaps we'd delegate |
1276 // metrics from an SVGImage to one of the Page's it's displayed in, but | 1274 // metrics from an SVGImage to one of the Page's it's displayed in, but |
1277 // that's tricky (SVGImage is intentionally isolated, and the Page that | 1275 // that's tricky (SVGImage is intentionally isolated, and the Page that |
1278 // created it may not even exist anymore). | 1276 // created it may not even exist anymore). |
1279 // So instead we just use a dedicated histogram for the SVG case. | 1277 // So instead we just use a dedicated histogram for the SVG case. |
1280 DEFINE_STATIC_LOCAL( | 1278 DEFINE_STATIC_LOCAL( |
1281 blink::EnumerationHistogram, histogram, | 1279 blink::EnumerationHistogram, histogram, |
1282 ("Blink.UseCounter.Features", blink::UseCounter::NumberOfFeatures)); | 1280 ("Blink.UseCounter.Features", blink::UseCounter::NumberOfFeatures)); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 } | 1354 } |
1357 } | 1355 } |
1358 | 1356 |
1359 if (needsPagesMeasuredUpdate) | 1357 if (needsPagesMeasuredUpdate) |
1360 cssPropertiesHistogram.count(totalPagesMeasuredCSSSampleId()); | 1358 cssPropertiesHistogram.count(totalPagesMeasuredCSSSampleId()); |
1361 | 1359 |
1362 m_CSSBits.clearAll(); | 1360 m_CSSBits.clearAll(); |
1363 } | 1361 } |
1364 | 1362 |
1365 } // namespace blink | 1363 } // namespace blink |
OLD | NEW |