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

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

Issue 2720933003: Removed FrameHost::useCounter() (Closed)
Patch Set: Created 3 years, 9 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 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #include "core/frame/UseCounter.h" 26 #include "core/frame/UseCounter.h"
27 27
28 #include "core/css/CSSStyleSheet.h" 28 #include "core/css/CSSStyleSheet.h"
29 #include "core/css/StyleSheetContents.h" 29 #include "core/css/StyleSheetContents.h"
30 #include "core/dom/Document.h" 30 #include "core/dom/Document.h"
31 #include "core/dom/ExecutionContext.h" 31 #include "core/dom/ExecutionContext.h"
32 #include "core/frame/Deprecation.h" 32 #include "core/frame/Deprecation.h"
33 #include "core/frame/FrameConsole.h" 33 #include "core/frame/FrameConsole.h"
34 #include "core/frame/FrameHost.h"
35 #include "core/frame/LocalFrame.h" 34 #include "core/frame/LocalFrame.h"
36 #include "core/inspector/ConsoleMessage.h" 35 #include "core/inspector/ConsoleMessage.h"
36 #include "core/page/Page.h"
37 #include "core/workers/WorkerOrWorkletGlobalScope.h" 37 #include "core/workers/WorkerOrWorkletGlobalScope.h"
38 #include "platform/Histogram.h" 38 #include "platform/Histogram.h"
39 #include "platform/instrumentation/tracing/TraceEvent.h" 39 #include "platform/instrumentation/tracing/TraceEvent.h"
40 #include "platform/weborigin/SchemeRegistry.h" 40 #include "platform/weborigin/SchemeRegistry.h"
41 41
42 namespace { 42 namespace {
43 43
44 int totalPagesMeasuredCSSSampleId() { 44 int totalPagesMeasuredCSSSampleId() {
45 return 1; 45 return 1;
46 } 46 }
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 m_CSSRecorded.clearAll(); 1166 m_CSSRecorded.clearAll();
1167 if (!m_disableReporting && !m_muteCount) { 1167 if (!m_disableReporting && !m_muteCount) {
1168 featuresHistogram().count(PageVisits); 1168 featuresHistogram().count(PageVisits);
1169 cssHistogram().count(totalPagesMeasuredCSSSampleId()); 1169 cssHistogram().count(totalPagesMeasuredCSSSampleId());
1170 } 1170 }
1171 } 1171 }
1172 1172
1173 void UseCounter::count(const Frame* frame, Feature feature) { 1173 void UseCounter::count(const Frame* frame, Feature feature) {
1174 if (!frame) 1174 if (!frame)
1175 return; 1175 return;
1176 FrameHost* host = frame->host(); 1176 Page* page = frame->page();
1177 if (!host) 1177 if (!page)
1178 return; 1178 return;
1179 1179
1180 host->useCounter().count(feature); 1180 page->useCounter().count(feature);
1181 } 1181 }
1182 1182
1183 void UseCounter::count(const Document& document, Feature feature) { 1183 void UseCounter::count(const Document& document, Feature feature) {
1184 count(document.frame(), feature); 1184 count(document.frame(), feature);
1185 } 1185 }
1186 1186
1187 bool UseCounter::isCounted(Document& document, Feature feature) { 1187 bool UseCounter::isCounted(Document& document, Feature feature) {
1188 Frame* frame = document.frame(); 1188 Page* page = document.page();
1189 if (!frame) 1189 if (!page)
1190 return false; 1190 return false;
1191 FrameHost* host = frame->host(); 1191 return page->useCounter().hasRecordedMeasurement(feature);
1192 if (!host)
1193 return false;
1194 return host->useCounter().hasRecordedMeasurement(feature);
1195 } 1192 }
1196 1193
1197 bool UseCounter::isCounted(CSSPropertyID unresolvedProperty) { 1194 bool UseCounter::isCounted(CSSPropertyID unresolvedProperty) {
1198 return m_CSSRecorded.quickGet(unresolvedProperty); 1195 return m_CSSRecorded.quickGet(unresolvedProperty);
1199 } 1196 }
1200 1197
1201 void UseCounter::addObserver(Observer* observer) { 1198 void UseCounter::addObserver(Observer* observer) {
1202 DCHECK(!m_observers.contains(observer)); 1199 DCHECK(!m_observers.contains(observer));
1203 m_observers.insert(observer); 1200 m_observers.insert(observer);
1204 } 1201 }
1205 1202
1206 bool UseCounter::isCounted(Document& document, const String& string) { 1203 bool UseCounter::isCounted(Document& document, const String& string) {
1207 Frame* frame = document.frame(); 1204 Page* page = document.page();
1208 if (!frame) 1205 if (!page)
1209 return false;
1210 FrameHost* host = frame->host();
1211 if (!host)
1212 return false; 1206 return false;
1213 1207
1214 CSSPropertyID unresolvedProperty = unresolvedCSSPropertyID(string); 1208 CSSPropertyID unresolvedProperty = unresolvedCSSPropertyID(string);
1215 if (unresolvedProperty == CSSPropertyInvalid) 1209 if (unresolvedProperty == CSSPropertyInvalid)
1216 return false; 1210 return false;
1217 return host->useCounter().isCounted(unresolvedProperty); 1211 return page->useCounter().isCounted(unresolvedProperty);
1218 } 1212 }
1219 1213
1220 void UseCounter::count(ExecutionContext* context, Feature feature) { 1214 void UseCounter::count(ExecutionContext* context, Feature feature) {
1221 if (!context) 1215 if (!context)
1222 return; 1216 return;
1223 if (context->isDocument()) { 1217 if (context->isDocument()) {
1224 count(*toDocument(context), feature); 1218 count(*toDocument(context), feature);
1225 return; 1219 return;
1226 } 1220 }
1227 if (context->isWorkerOrWorkletGlobalScope()) 1221 if (context->isWorkerOrWorkletGlobalScope())
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 } 1350 }
1357 } 1351 }
1358 1352
1359 if (needsPagesMeasuredUpdate) 1353 if (needsPagesMeasuredUpdate)
1360 cssPropertiesHistogram.count(totalPagesMeasuredCSSSampleId()); 1354 cssPropertiesHistogram.count(totalPagesMeasuredCSSSampleId());
1361 1355
1362 m_CSSBits.clearAll(); 1356 m_CSSBits.clearAll();
1363 } 1357 }
1364 1358
1365 } // namespace blink 1359 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameHost.cpp ('k') | third_party/WebKit/Source/core/testing/Internals.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698