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

Side by Side Diff: sky/engine/core/frame/UseCounter.h

Issue 867903002: Remove UseCounter (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « sky/engine/core/frame/PRESUBMIT.py ('k') | sky/engine/core/frame/UseCounter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2012 Google, Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #ifndef SKY_ENGINE_CORE_FRAME_USECOUNTER_H_
27 #define SKY_ENGINE_CORE_FRAME_USECOUNTER_H_
28
29 #include "gen/sky/core/CSSPropertyNames.h"
30 #include "sky/engine/wtf/BitVector.h"
31 #include "sky/engine/wtf/Noncopyable.h"
32 #include "sky/engine/wtf/OwnPtr.h"
33 #include "sky/engine/wtf/PassOwnPtr.h"
34 #include "sky/engine/wtf/text/WTFString.h"
35
36 namespace blink {
37
38 class CSSStyleSheet;
39 class LocalDOMWindow;
40 class Document;
41 class ExecutionContext;
42 class StyleSheetContents;
43
44 // UseCounter is used for counting the number of times features of
45 // Blink are used on real web pages and help us know commonly
46 // features are used and thus when it's safe to remove or change them.
47 //
48 // The Chromium Content layer controls what is done with this data.
49 // For instance, in Google Chrome, these counts are submitted
50 // anonymously through the Histogram recording system in Chrome
51 // for users who opt-in to "Usage Statistics" submission
52 // during their install of Google Chrome:
53 // http://www.google.com/chrome/intl/en/privacy.html
54
55 class UseCounter {
56 WTF_MAKE_NONCOPYABLE(UseCounter);
57 public:
58 UseCounter();
59 ~UseCounter();
60
61 enum Feature {
62 // Do not change assigned numbers of existing items: add new features
63 // to the end of the list.
64 PageDestruction = 0,
65 PrefixedIndexedDB = 3,
66 WorkerStart = 4,
67 SharedWorkerStart = 5,
68 UnprefixedIndexedDB = 9,
69 UnprefixedRequestAnimationFrame = 13,
70 PrefixedRequestAnimationFrame = 14,
71
72 DataListElement = 23,
73 FormAttribute = 24,
74 IncrementalAttribute = 25,
75 InputTypeColor = 26,
76 InputTypeDate = 27,
77 InputTypeDateTimeFallback = 29,
78 InputTypeDateTimeLocal = 30,
79 InputTypeEmail = 31,
80 InputTypeMonth = 32,
81 InputTypeNumber = 33,
82 InputTypeRange = 34,
83 InputTypeSearch = 35,
84 InputTypeTel = 36,
85 InputTypeTime = 37,
86 InputTypeURL = 38,
87 InputTypeWeek = 39,
88 InputTypeWeekFallback = 40,
89 ListAttribute = 41,
90 MaxAttribute = 42,
91 MinAttribute = 43,
92 PatternAttribute = 44,
93 PlaceholderAttribute = 45,
94 PrefixedDirectoryAttribute = 47,
95 RequiredAttribute = 49,
96 ResultsAttribute = 50,
97 StepAttribute = 51,
98 PageVisits = 52,
99 PrefixedStorageInfo = 57,
100 XFrameOptions = 58,
101 XFrameOptionsSameOrigin = 59,
102 XFrameOptionsSameOriginWithBadAncestorChain = 60,
103 DeprecatedFlexboxWebContent = 61,
104 DeprecatedFlexboxChrome = 62,
105 DeprecatedFlexboxChromeExtension = 63,
106 UnprefixedPerformanceTimeline = 65,
107 UnprefixedUserTiming = 67,
108 WindowEvent = 69,
109 PrefixedMediaAddKey = 71,
110 PrefixedMediaGenerateKeyRequest = 72,
111 SVGFontElement = 76,
112 XMLDocument = 77,
113 SVGSwitchElement = 80,
114 DocumentAll = 83,
115 FormElement = 84,
116 DemotedFormElement = 85,
117 SVGAnimationElement = 90,
118 KeyboardEventKeyLocation = 91,
119 TextReplaceWholeText = 100,
120 ConsoleMarkTimeline = 102,
121 CSSPseudoElementUserAgentCustomPseudo = 103,
122 ElementGetAttributeNode = 107, // Removed from DOM4.
123 ElementSetAttributeNode = 108, // Removed from DOM4.
124 ElementRemoveAttributeNode = 109, // Removed from DOM4.
125 DocumentCreateAttribute = 111, // Removed from DOM4.
126 DocumentCreateAttributeNS = 112, // Removed from DOM4.
127 DocumentInputEncoding = 114, // Removed from DOM4.
128 DocumentXMLEncoding = 115, // Removed from DOM4.
129 DocumentXMLStandalone = 116, // Removed from DOM4.
130 NodeNamespaceURI = 120, // Removed from DOM4.
131 NodeLocalName = 122, // Removed from DOM4.
132 NavigatorProductSub = 123,
133 NavigatorVendor = 124,
134 NavigatorVendorSub = 125,
135 FileError = 126,
136 DocumentCharset = 127, // Documented as IE extensions = 0, from KHTML da ys.
137 EventReturnValue = 137, // Legacy IE extension.
138 HasAttributes = 142, // Removed from DOM4.
139 DOMSubtreeModifiedEvent = 143,
140 DOMNodeInsertedEvent = 144,
141 DOMNodeRemovedEvent = 145,
142 DOMNodeRemovedFromDocumentEvent = 146,
143 DOMNodeInsertedIntoDocumentEvent = 147,
144 DOMCharacterDataModifiedEvent = 148,
145 DocumentAllLegacyCall = 150,
146 SVGFontInCSS = 156,
147 AttributeOwnerElement = 160, // Removed in DOM4.
148 AttributeSpecified = 162, // Removed in DOM4.
149 PrefixedAudioDecodedByteCount = 164,
150 PrefixedElementRequestFullscreen = 176,
151 PrefixedElementRequestFullScreen = 177,
152 InputTypeEmailMultiple = 184,
153 InputTypeEmailMaxLength = 185,
154 InputTypeEmailMultipleMaxLength = 186,
155 InputTypeText = 190,
156 InputTypeTextMaxLength = 191,
157 InputTypePassword = 192,
158 InputTypePasswordMaxLength = 193,
159 PrefixedPageVisibility = 196,
160 CSSStyleSheetInsertRuleOptionalArg = 198, // Inconsistent with the speci fication and other browsers.
161 DocumentUnloadRegistered = 202,
162 DocumentUnloadFired = 203,
163 SVGLocatableNearestViewportElement = 204,
164 SVGLocatableFarthestViewportElement = 205,
165 HTMLHeadElementProfile = 207,
166 SVGPointMatrixTransform = 209,
167 DOMFocusInOutEvent = 211,
168 FileGetLastModifiedDate = 212,
169 ElementPrefixedMatchesSelector = 217,
170 CSSStyleSheetRules = 219,
171 CSSStyleSheetAddRule = 220,
172 CSSStyleSheetRemoveRule = 221,
173 // The above items are available in M33 branch.
174
175 InitMessageEvent = 222,
176 ElementSetPrefix = 224, // Element.prefix is readonly in DOM4.
177 CSSStyleDeclarationGetPropertyCSSValue = 225,
178 PrefixedMediaCancelKeyRequest = 229,
179 CanPlayTypeKeySystem = 232,
180 PrefixedDevicePixelRatioMediaFeature = 233,
181 PrefixedMaxDevicePixelRatioMediaFeature = 234,
182 PrefixedMinDevicePixelRatioMediaFeature = 235,
183 PrefixedTransform3dMediaFeature = 237,
184 PrefixedStorageQuota = 240,
185 ResetReferrerPolicy = 243,
186 CaseInsensitiveAttrSelectorMatch = 244, // Case-insensitivity dropped fr om specification.
187 FormNameAccessForImageElement = 246,
188 FormNameAccessForPastNamesMap = 247,
189 FormAssociationByParser = 248,
190 WebSocketURL = 255,
191 WorkerAllowedByChildBlockedByScript = 258,
192 DeprecatedWebKitGradient = 260,
193 DeprecatedWebKitLinearGradient = 261,
194 DeprecatedWebKitRepeatingLinearGradient = 262,
195 DeprecatedWebKitRadialGradient = 263,
196 DeprecatedWebKitRepeatingRadialGradient = 264,
197 PrefixedImageSmoothingEnabled = 267,
198 UnprefixedImageSmoothingEnabled = 268,
199 // The above items are available in M34 branch.
200
201 TextAutosizing = 274,
202 HTMLAnchorElementPingAttribute = 276,
203 SVGClassName = 279,
204 PrefixedWindowURL = 283,
205 PrefixedWorkerURL = 284, // This didn't work because of crbug.com/376039 . Available since M37.
206 WindowOrientation = 285,
207
208 DocumentCaptureEvents = 287,
209 DocumentReleaseEvents = 288,
210 WindowCaptureEvents = 289,
211 WindowReleaseEvents = 290,
212 PrefixedGamepad = 291,
213 ElementAnimateKeyframeListEffectObjectTiming = 292,
214 ElementAnimateKeyframeListEffectDoubleTiming = 293,
215 ElementAnimateKeyframeListEffectNoTiming = 294,
216 AttrGetValue = 298,
217 AttrSetValue = 299,
218 AnimationConstructorKeyframeListEffectObjectTiming = 300,
219 AnimationConstructorKeyframeListEffectDoubleTiming = 301,
220 AnimationConstructorKeyframeListEffectNoTiming = 302,
221 AttrSetValueWithElement = 303,
222 PrefixedCancelAnimationFrame = 304,
223 PrefixedCancelRequestAnimationFrame = 305,
224
225 XHRProgressEventPosition = 316,
226 XHRProgressEventTotalSize = 317,
227 PrefixedDocumentIsFullscreen = 318,
228 PrefixedDocumentFullScreenKeyboardInputAllowed = 319,
229 PrefixedDocumentCurrentFullScreenElement = 320,
230 PrefixedDocumentCancelFullScreen = 321,
231 PrefixedDocumentFullscreenEnabled = 322,
232 PrefixedDocumentFullscreenElement = 323,
233 PrefixedDocumentExitFullscreen = 324,
234 // The above items are available in M35 branch.
235
236 SVGForeignObjectElement = 325,
237 SelectionSetPosition = 327,
238 AnimationPlayerFinishEvent = 328,
239 // TODO(sky): 329, 330 Unused
240 CanvasRenderingContext2DSetCompositeOperation = 331,
241 CanvasRenderingContext2DSetLineWidth = 332,
242 CanvasRenderingContext2DSetLineCap = 333,
243 CanvasRenderingContext2DSetLineJoin = 334,
244 CanvasRenderingContext2DSetMiterLimit = 335,
245 CanvasRenderingContext2DClearShadow = 336,
246 CanvasRenderingContext2DSetStrokeColor = 337,
247 CanvasRenderingContext2DSetFillColor = 338,
248 CanvasRenderingContext2DDrawImageFromRect = 339,
249 CanvasRenderingContext2DSetShadow = 340,
250 PrefixedPerformanceClearResourceTimings = 341,
251 PrefixedPerformanceSetResourceTimingBufferSize = 342,
252 EventSrcElement = 343,
253 EventCancelBubble = 344,
254 EventPath = 345,
255 EventClipboardData = 346,
256 AttrTextContent = 349,
257 EventGetReturnValueTrue = 350,
258 EventGetReturnValueFalse = 351,
259 EventSetReturnValueTrue = 352,
260 EventSetReturnValueFalse = 353,
261 WindowOffscreenBuffering = 356,
262 WindowDefaultStatus = 357,
263 WindowDefaultstatus = 358,
264 PrefixedTransitionEventConstructor = 361,
265 PrefixedMutationObserverConstructor = 362,
266 PrefixedIDBCursorConstructor = 363,
267 PrefixedIDBDatabaseConstructor = 364,
268 PrefixedIDBFactoryConstructor = 365,
269 PrefixedIDBIndexConstructor = 366,
270 PrefixedIDBKeyRangeConstructor = 367,
271 PrefixedIDBObjectStoreConstructor = 368,
272 PrefixedIDBRequestConstructor = 369,
273 PrefixedIDBTransactionConstructor = 370,
274 NotificationPermission = 371,
275 RangeDetach = 372,
276 PrefixedTouchRadiusX = 378,
277 PrefixedTouchRadiusY = 379,
278 PrefixedTouchRotationAngle = 380,
279 PrefixedTouchForce = 381,
280 PrefixedMouseEventMovementX = 382,
281 PrefixedMouseEventMovementY = 383,
282 PrefixedFileRelativePath = 386,
283 DocumentCaretRangeFromPoint = 387,
284 DocumentGetCSSCanvasContext = 388,
285 ElementScrollIntoViewIfNeeded = 389,
286 RangeCompareNode = 392,
287 RangeExpand = 393,
288 HTMLImageElementX = 396,
289 HTMLImageElementY = 397,
290 SelectionBaseNode = 400,
291 SelectionBaseOffset = 401,
292 SelectionExtentNode = 402,
293 SelectionExtentOffset = 403,
294 SelectionType = 404,
295 SelectionModify = 405,
296 SelectionSetBaseAndExtent = 406,
297 SelectionEmpty = 407,
298 // The above items are available in M36 branch.
299
300 PostMessageFromSecureToInsecure = 419,
301 PostMessageFromInsecureToSecure = 420,
302 PrefixedCursorZoomIn = 424,
303 PrefixedCursorZoomOut = 425,
304 CSSCharsetRuleEncoding = 426,
305 DocumentSetCharset = 427,
306 DocumentDefaultCharset = 428,
307 TextEncoderConstructor = 429,
308 TextEncoderEncode = 430,
309 TextDecoderConstructor = 431,
310 TextDecoderDecode = 432,
311 FocusInOutEvent = 433,
312 MouseEventMovementX = 434,
313 MouseEventMovementY = 435,
314 MixedContentRaw = 437,
315 MixedContentImage = 438,
316 MixedContentMedia = 439,
317 DocumentFonts = 440,
318 MixedContentFormsSubmitted = 441,
319 FormsSubmitted = 442,
320 TextInputEventOnInput = 443,
321 TextInputEventOnTextArea = 444,
322 TextInputEventOnContentEditable = 445,
323 TextInputEventOnNotNode = 446,
324 WebkitBeforeTextInsertedOnInput = 447,
325 WebkitBeforeTextInsertedOnTextArea = 448,
326 WebkitBeforeTextInsertedOnContentEditable = 449,
327 WebkitBeforeTextInsertedOnNotNode = 450,
328 WebkitEditableContentChangedOnInput = 451,
329 WebkitEditableContentChangedOnTextArea = 452,
330 WebkitEditableContentChangedOnContentEditable = 453,
331 WebkitEditableContentChangedOnNotNode = 454,
332 HTMLImports = 455,
333 ElementCreateShadowRoot = 456,
334 DocumentRegisterElement = 457,
335 EditingAppleInterchangeNewline = 458,
336 EditingAppleConvertedSpace = 459,
337 EditingApplePasteAsQuotation = 460,
338 EditingAppleStyleSpanClass = 461,
339 EditingAppleTabSpanClass = 462,
340 HTMLImportsAsyncAttribute = 463,
341 FontFaceSetReady = 464,
342
343 CSSSelectorPseudoHost = 469,
344
345 CSSDeepCombinator = 471,
346 SyncXHRWithCredentials = 472,
347 // The above items are available in M37 branch.
348
349 UseAsm = 473,
350 KeyEventNotAllowedInFullScreen = 474,
351 DOMWindowOpen = 475,
352 DOMWindowOpenFeatures = 476,
353 AspectRatioFlexItem = 479,
354 DetailsElement = 480,
355 DialogElement = 481,
356 MapElement = 482,
357 MeterElement = 483,
358 ProgressElement = 484,
359 PrefixedHTMLElementDropzone = 490,
360 WheelEventWheelDeltaX = 491,
361 WheelEventWheelDeltaY = 492,
362 WheelEventWheelDelta = 493,
363 SendBeacon = 494,
364 SendBeaconQuotaExceeded = 495,
365 SVGSMILElementInDocument = 501,
366 MouseEventOffsetX = 502,
367 MouseEventOffsetY = 503,
368 MouseEventX = 504,
369 MouseEventY = 505,
370 MouseEventFromElement = 506,
371 MouseEventToElement = 507,
372 RequestFileSystem = 508,
373 RequestFileSystemWorker = 509,
374 RequestFileSystemSyncWorker = 510,
375 UIEventLayerX = 511,
376 UIEventLayerY = 512,
377 UIEventPageX = 513,
378 UIEventPageY = 514,
379 BgPropertiesFixed = 515,
380 HTMLImageElementComposite = 516,
381 DevToolsConsoleTimeline = 517,
382 DevToolsConsoleProfile = 518,
383 PictureSourceSrc = 520,
384 // The above items are available in M38 branch.
385
386 Picture = 521,
387 Sizes = 522,
388 SrcsetXDescriptor = 523,
389 SrcsetWDescriptor = 524,
390 SelectionContainsNode = 525,
391 // Add new features immediately above this line. Don't change assigned
392 // numbers of any item, and don't reuse removed slots.
393 // Also, run update_use_counter_feature_enum.py in chromium/src/tools/me trics/histograms/
394 // to update the UMA mapping.
395 NumberOfFeatures, // This enum value must be last.
396 };
397
398 // "count" sets the bit for this feature to 1. Repeated calls are ignored.
399 static void count(const Document&, Feature);
400 // This doesn't count for ExecutionContexts for shared workers and service
401 // workers.
402 static void count(const ExecutionContext*, Feature);
403 void count(CSSParserContext, CSSPropertyID);
404 void count(Feature);
405
406 // "countDeprecation" sets the bit for this feature to 1, and sends a deprec ation
407 // warning to the console. Repeated calls are ignored.
408 //
409 // Be considerate to developers' consoles: features should only send
410 // deprecation warnings when we're actively interested in removing them from
411 // the platform.
412 //
413 // The ExecutionContext* overload doesn't work for shared workers and
414 // service workers.
415 static void countDeprecation(const LocalDOMWindow*, Feature);
416 static void countDeprecation(ExecutionContext*, Feature);
417 static void countDeprecation(const Document&, Feature);
418 String deprecationMessage(Feature);
419
420 void didCommitLoad();
421
422 static UseCounter* getFrom(const Document*);
423 static UseCounter* getFrom(const CSSStyleSheet*);
424 static UseCounter* getFrom(const StyleSheetContents*);
425
426 static void muteForInspector();
427 static void unmuteForInspector();
428
429 private:
430 static int m_muteCount;
431
432 bool recordMeasurement(Feature feature)
433 {
434 if (UseCounter::m_muteCount)
435 return false;
436 ASSERT(feature != PageDestruction); // PageDestruction is reserved as a scaling factor.
437 ASSERT(feature < NumberOfFeatures);
438 if (!m_countBits) {
439 m_countBits = adoptPtr(new BitVector(NumberOfFeatures));
440 m_countBits->clearAll();
441 }
442
443 if (m_countBits->quickGet(feature))
444 return false;
445
446 m_countBits->quickSet(feature);
447 return true;
448 }
449
450 void updateMeasurements();
451
452 OwnPtr<BitVector> m_countBits;
453 BitVector m_CSSFeatureBits;
454 };
455
456 } // namespace blink
457
458 #endif // SKY_ENGINE_CORE_FRAME_USECOUNTER_H_
OLDNEW
« no previous file with comments | « sky/engine/core/frame/PRESUBMIT.py ('k') | sky/engine/core/frame/UseCounter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698