Chromium Code Reviews| 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 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1136 return false; | 1136 return false; |
| 1137 | 1137 |
| 1138 DCHECK(feature != OBSOLETE_PageDestruction && | 1138 DCHECK(feature != OBSOLETE_PageDestruction && |
| 1139 feature != | 1139 feature != |
| 1140 PageVisits); // PageDestruction is reserved as a scaling factor. | 1140 PageVisits); // PageDestruction is reserved as a scaling factor. |
| 1141 DCHECK(feature < NumberOfFeatures); | 1141 DCHECK(feature < NumberOfFeatures); |
| 1142 | 1142 |
| 1143 return m_featuresRecorded.quickGet(feature); | 1143 return m_featuresRecorded.quickGet(feature); |
| 1144 } | 1144 } |
| 1145 | 1145 |
| 1146 DEFINE_TRACE(UseCounter) { | |
| 1147 visitor->trace(m_observers); | |
| 1148 } | |
| 1149 | |
| 1146 void UseCounter::didCommitLoad(KURL url) { | 1150 void UseCounter::didCommitLoad(KURL url) { |
| 1147 m_legacyCounter.updateMeasurements(); | 1151 m_legacyCounter.updateMeasurements(); |
| 1148 | 1152 |
| 1149 // Reset state from previous load. | 1153 // Reset state from previous load. |
| 1150 m_disableReporting = false; | 1154 m_disableReporting = false; |
| 1151 | 1155 |
| 1152 // Use the protocol of the document being loaded into the main frame to | 1156 // Use the protocol of the document being loaded into the main frame to |
| 1153 // decide whether this page is interesting from a metrics perspective. | 1157 // decide whether this page is interesting from a metrics perspective. |
| 1154 // Note that SVGImage cases always have an about:blank URL | 1158 // Note that SVGImage cases always have an about:blank URL |
| 1155 if (m_context == DefaultContext && | 1159 if (m_context == DefaultContext && |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1166 } | 1170 } |
| 1167 | 1171 |
| 1168 void UseCounter::count(const Frame* frame, Feature feature) { | 1172 void UseCounter::count(const Frame* frame, Feature feature) { |
| 1169 if (!frame) | 1173 if (!frame) |
| 1170 return; | 1174 return; |
| 1171 FrameHost* host = frame->host(); | 1175 FrameHost* host = frame->host(); |
| 1172 if (!host) | 1176 if (!host) |
| 1173 return; | 1177 return; |
| 1174 | 1178 |
| 1175 host->useCounter().count(feature); | 1179 host->useCounter().count(feature); |
| 1180 HeapHashSet<Member<Observer>> toBeRemoved; | |
|
Rick Byers
2017/02/11 15:01:51
IIRC, this code path isn't triggered on the deprec
nhiroki
2017/02/13 04:35:07
Good point. This is because both countFeature() an
| |
| 1181 for (auto observer : host->useCounter().m_observers) { | |
| 1182 if (observer->onCountFeature(feature)) | |
| 1183 toBeRemoved.insert(observer); | |
| 1184 } | |
| 1185 host->useCounter().m_observers.removeAll(toBeRemoved); | |
| 1176 } | 1186 } |
| 1177 | 1187 |
| 1178 void UseCounter::count(const Document& document, Feature feature) { | 1188 void UseCounter::count(const Document& document, Feature feature) { |
| 1179 count(document.frame(), feature); | 1189 count(document.frame(), feature); |
| 1180 } | 1190 } |
| 1181 | 1191 |
| 1182 bool UseCounter::isCounted(Document& document, Feature feature) { | 1192 bool UseCounter::isCounted(Document& document, Feature feature) { |
| 1183 Frame* frame = document.frame(); | 1193 Frame* frame = document.frame(); |
| 1184 if (!frame) | 1194 if (!frame) |
| 1185 return false; | 1195 return false; |
| 1186 FrameHost* host = frame->host(); | 1196 FrameHost* host = frame->host(); |
| 1187 if (!host) | 1197 if (!host) |
| 1188 return false; | 1198 return false; |
| 1189 return host->useCounter().hasRecordedMeasurement(feature); | 1199 return host->useCounter().hasRecordedMeasurement(feature); |
| 1190 } | 1200 } |
| 1191 | 1201 |
| 1192 bool UseCounter::isCounted(CSSPropertyID unresolvedProperty) { | 1202 bool UseCounter::isCounted(CSSPropertyID unresolvedProperty) { |
| 1193 return m_CSSRecorded.quickGet(unresolvedProperty); | 1203 return m_CSSRecorded.quickGet(unresolvedProperty); |
| 1194 } | 1204 } |
| 1195 | 1205 |
| 1206 void UseCounter::addObserver(Document& document, Observer* observer) { | |
| 1207 Frame* frame = document.frame(); | |
| 1208 if (!frame) | |
| 1209 return; | |
| 1210 FrameHost* host = frame->host(); | |
| 1211 if (!host) | |
| 1212 return; | |
| 1213 host->useCounter().m_observers.insert(observer); | |
| 1214 } | |
| 1215 | |
| 1196 bool UseCounter::isCounted(Document& document, const String& string) { | 1216 bool UseCounter::isCounted(Document& document, const String& string) { |
| 1197 Frame* frame = document.frame(); | 1217 Frame* frame = document.frame(); |
| 1198 if (!frame) | 1218 if (!frame) |
| 1199 return false; | 1219 return false; |
| 1200 FrameHost* host = frame->host(); | 1220 FrameHost* host = frame->host(); |
| 1201 if (!host) | 1221 if (!host) |
| 1202 return false; | 1222 return false; |
| 1203 | 1223 |
| 1204 CSSPropertyID unresolvedProperty = unresolvedCSSPropertyID(string); | 1224 CSSPropertyID unresolvedProperty = unresolvedCSSPropertyID(string); |
| 1205 if (unresolvedProperty == CSSPropertyInvalid) | 1225 if (unresolvedProperty == CSSPropertyInvalid) |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1335 } | 1355 } |
| 1336 } | 1356 } |
| 1337 | 1357 |
| 1338 if (needsPagesMeasuredUpdate) | 1358 if (needsPagesMeasuredUpdate) |
| 1339 cssPropertiesHistogram.count(totalPagesMeasuredCSSSampleId()); | 1359 cssPropertiesHistogram.count(totalPagesMeasuredCSSSampleId()); |
| 1340 | 1360 |
| 1341 m_CSSBits.clearAll(); | 1361 m_CSSBits.clearAll(); |
| 1342 } | 1362 } |
| 1343 | 1363 |
| 1344 } // namespace blink | 1364 } // namespace blink |
| OLD | NEW |