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

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

Issue 2604633002: Mute use counters for internal pages (Closed)
Patch Set: Created 3 years, 12 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 19 matching lines...) Expand all
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" 34 #include "core/frame/FrameHost.h"
35 #include "core/frame/LocalFrame.h" 35 #include "core/frame/LocalFrame.h"
36 #include "core/inspector/ConsoleMessage.h" 36 #include "core/inspector/ConsoleMessage.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 41
41 namespace { 42 namespace {
42 43
43 int totalPagesMeasuredCSSSampleId() { 44 int totalPagesMeasuredCSSSampleId() {
44 return 1; 45 return 1;
45 } 46 }
46 47
47 // Make sure update_use_counter_css.py was run which updates histograms.xml. 48 // Make sure update_use_counter_css.py was run which updates histograms.xml.
48 constexpr int kMaximumCSSSampleId = 549; 49 constexpr int kMaximumCSSSampleId = 549;
49 50
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 ASSERT_NOT_REACHED(); 1077 ASSERT_NOT_REACHED();
1077 return 0; 1078 return 0;
1078 } 1079 }
1079 1080
1080 ASSERT_NOT_REACHED(); 1081 ASSERT_NOT_REACHED();
1081 return 0; 1082 return 0;
1082 } 1083 }
1083 1084
1084 UseCounter::UseCounter(Context context) 1085 UseCounter::UseCounter(Context context)
1085 : m_muteCount(0), 1086 : m_muteCount(0),
1087 m_mutedByLoad(false),
1086 m_context(context), 1088 m_context(context),
1087 m_featuresRecorded(NumberOfFeatures), 1089 m_featuresRecorded(NumberOfFeatures),
1088 m_CSSRecorded(lastUnresolvedCSSProperty + 1) {} 1090 m_CSSRecorded(lastUnresolvedCSSProperty + 1) {}
1089 1091
1090 void UseCounter::muteForInspector() { 1092 void UseCounter::muteForInspector() {
1091 m_muteCount++; 1093 m_muteCount++;
1092 } 1094 }
1093 1095
1094 void UseCounter::unmuteForInspector() { 1096 void UseCounter::unmuteForInspector() {
1095 m_muteCount--; 1097 m_muteCount--;
(...skipping 24 matching lines...) Expand all
1120 return false; 1122 return false;
1121 1123
1122 DCHECK(feature != OBSOLETE_PageDestruction && 1124 DCHECK(feature != OBSOLETE_PageDestruction &&
1123 feature != 1125 feature !=
1124 PageVisits); // PageDestruction is reserved as a scaling factor. 1126 PageVisits); // PageDestruction is reserved as a scaling factor.
1125 DCHECK(feature < NumberOfFeatures); 1127 DCHECK(feature < NumberOfFeatures);
1126 1128
1127 return m_featuresRecorded.quickGet(feature); 1129 return m_featuresRecorded.quickGet(feature);
1128 } 1130 }
1129 1131
1130 void UseCounter::didCommitLoad() { 1132 void UseCounter::didCommitLoad(KURL url) {
1131 m_legacyCounter.updateMeasurements(); 1133 m_legacyCounter.updateMeasurements();
1132 1134
1133 // TODO: Is didCommitLoad really the right time to do this? crbug.com/608040 1135 if (m_mutedByLoad) {
1136 m_muteCount--;
1137 m_mutedByLoad = false;
1138 }
1139
1140 // Use the protocol of the document being loaded into the main frame to
1141 // decide whether this page is interesting from a metrics perspective.
1142 // Note that SVGImage cases always have an about:blank URL
1143 if (m_context == DefaultContext &&
1144 !SchemeRegistry::shouldTrackUsageMetricsForScheme(url.protocol())) {
1145 m_muteCount++;
1146 m_mutedByLoad = true;
1147 }
1148
1134 m_featuresRecorded.clearAll(); 1149 m_featuresRecorded.clearAll();
1135 featuresHistogram().count(PageVisits);
1136 m_CSSRecorded.clearAll(); 1150 m_CSSRecorded.clearAll();
1137 cssHistogram().count(totalPagesMeasuredCSSSampleId()); 1151 if (!m_muteCount) {
1152 featuresHistogram().count(PageVisits);
1153 cssHistogram().count(totalPagesMeasuredCSSSampleId());
1154 }
1138 } 1155 }
1139 1156
1140 void UseCounter::count(const Frame* frame, Feature feature) { 1157 void UseCounter::count(const Frame* frame, Feature feature) {
1141 if (!frame) 1158 if (!frame)
1142 return; 1159 return;
1143 FrameHost* host = frame->host(); 1160 FrameHost* host = frame->host();
1144 if (!host) 1161 if (!host)
1145 return; 1162 return;
1146 1163
1147 host->useCounter().count(feature); 1164 host->useCounter().count(feature);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 } 1342 }
1326 } 1343 }
1327 1344
1328 if (needsPagesMeasuredUpdate) 1345 if (needsPagesMeasuredUpdate)
1329 cssPropertiesHistogram.count(totalPagesMeasuredCSSSampleId()); 1346 cssPropertiesHistogram.count(totalPagesMeasuredCSSSampleId());
1330 1347
1331 m_CSSBits.clearAll(); 1348 m_CSSBits.clearAll();
1332 } 1349 }
1333 1350
1334 } // namespace blink 1351 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698