Upstream version 10.38.208.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / frame / UseCounter.h
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 UseCounter_h
27 #define UseCounter_h
28
29 #include "core/CSSPropertyNames.h"
30 #include "wtf/BitVector.h"
31 #include "wtf/Noncopyable.h"
32 #include "wtf/OwnPtr.h"
33 #include "wtf/PassOwnPtr.h"
34 #include "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         OpenWebDatabase = 10,
70         UnprefixedRequestAnimationFrame = 13,
71         PrefixedRequestAnimationFrame = 14,
72         ContentSecurityPolicy = 15,
73         ContentSecurityPolicyReportOnly = 16,
74         PrefixedTransitionEndEvent = 18,
75         UnprefixedTransitionEndEvent = 19,
76         PrefixedAndUnprefixedTransitionEndEvent = 20,
77         AutoFocusAttribute = 21,
78         DataListElement = 23,
79         FormAttribute = 24,
80         IncrementalAttribute = 25,
81         InputTypeColor = 26,
82         InputTypeDate = 27,
83         InputTypeDateTimeFallback = 29,
84         InputTypeDateTimeLocal = 30,
85         InputTypeEmail = 31,
86         InputTypeMonth = 32,
87         InputTypeNumber = 33,
88         InputTypeRange = 34,
89         InputTypeSearch = 35,
90         InputTypeTel = 36,
91         InputTypeTime = 37,
92         InputTypeURL = 38,
93         InputTypeWeek = 39,
94         InputTypeWeekFallback = 40,
95         ListAttribute = 41,
96         MaxAttribute = 42,
97         MinAttribute = 43,
98         PatternAttribute = 44,
99         PlaceholderAttribute = 45,
100         PrefixedDirectoryAttribute = 47,
101         RequiredAttribute = 49,
102         ResultsAttribute = 50,
103         StepAttribute = 51,
104         PageVisits = 52,
105         HTMLMarqueeElement = 53,
106         Reflection = 55,
107         PrefixedStorageInfo = 57,
108         XFrameOptions = 58,
109         XFrameOptionsSameOrigin = 59,
110         XFrameOptionsSameOriginWithBadAncestorChain = 60,
111         DeprecatedFlexboxWebContent = 61,
112         DeprecatedFlexboxChrome = 62,
113         DeprecatedFlexboxChromeExtension = 63,
114         UnprefixedPerformanceTimeline = 65,
115         UnprefixedUserTiming = 67,
116         WindowEvent = 69,
117         ContentSecurityPolicyWithBaseElement = 70,
118         PrefixedMediaAddKey = 71,
119         PrefixedMediaGenerateKeyRequest = 72,
120         DocumentClear = 74,
121         SVGFontElement = 76,
122         XMLDocument = 77,
123         XSLProcessingInstruction = 78,
124         XSLTProcessor = 79,
125         SVGSwitchElement = 80,
126         DocumentAll = 83,
127         FormElement = 84,
128         DemotedFormElement = 85,
129         SVGAnimationElement = 90,
130         KeyboardEventKeyLocation = 91,
131         LineClamp = 96,
132         SubFrameBeforeUnloadRegistered = 97,
133         SubFrameBeforeUnloadFired = 98,
134         TextReplaceWholeText = 100,
135         ConsoleMarkTimeline = 102,
136         CSSPseudoElementUserAgentCustomPseudo = 103,
137         ElementGetAttributeNode = 107, // Removed from DOM4.
138         ElementSetAttributeNode = 108, // Removed from DOM4.
139         ElementRemoveAttributeNode = 109, // Removed from DOM4.
140         ElementGetAttributeNodeNS = 110, // Removed from DOM4.
141         DocumentCreateAttribute = 111, // Removed from DOM4.
142         DocumentCreateAttributeNS = 112, // Removed from DOM4.
143         DocumentCreateCDATASection = 113, // Removed from DOM4.
144         DocumentInputEncoding = 114, // Removed from DOM4.
145         DocumentXMLEncoding = 115, // Removed from DOM4.
146         DocumentXMLStandalone = 116, // Removed from DOM4.
147         DocumentXMLVersion = 117, // Removed from DOM4.
148         NodeIsSameNode = 118, // Removed from DOM4.
149         NodeNamespaceURI = 120, // Removed from DOM4.
150         NodeLocalName = 122, // Removed from DOM4.
151         NavigatorProductSub = 123,
152         NavigatorVendor = 124,
153         NavigatorVendorSub = 125,
154         FileError = 126,
155         DocumentCharset = 127, // Documented as IE extensions = 0, from KHTML days.
156         PrefixedAnimationEndEvent = 128,
157         UnprefixedAnimationEndEvent = 129,
158         PrefixedAndUnprefixedAnimationEndEvent = 130,
159         PrefixedAnimationStartEvent = 131,
160         UnprefixedAnimationStartEvent = 132,
161         PrefixedAndUnprefixedAnimationStartEvent = 133,
162         PrefixedAnimationIterationEvent = 134,
163         UnprefixedAnimationIterationEvent = 135,
164         PrefixedAndUnprefixedAnimationIterationEvent = 136,
165         EventReturnValue = 137, // Legacy IE extension.
166         SVGSVGElement = 138,
167         InsertAdjacentText = 140,
168         InsertAdjacentElement = 141,
169         HasAttributes = 142, // Removed from DOM4.
170         DOMSubtreeModifiedEvent = 143,
171         DOMNodeInsertedEvent = 144,
172         DOMNodeRemovedEvent = 145,
173         DOMNodeRemovedFromDocumentEvent = 146,
174         DOMNodeInsertedIntoDocumentEvent = 147,
175         DOMCharacterDataModifiedEvent = 148,
176         DocumentAllLegacyCall = 150,
177         HTMLAppletElementLegacyCall = 151,
178         HTMLEmbedElementLegacyCall = 152,
179         HTMLObjectElementLegacyCall = 153,
180         GetMatchedCSSRules = 155,
181         SVGFontInCSS = 156,
182         AttributeOwnerElement = 160, // Removed in DOM4.
183         AttributeSpecified = 162, // Removed in DOM4.
184         PrefixedAudioDecodedByteCount = 164,
185         PrefixedVideoDecodedByteCount = 165,
186         PrefixedVideoSupportsFullscreen = 166,
187         PrefixedVideoDisplayingFullscreen = 167,
188         PrefixedVideoEnterFullscreen = 168,
189         PrefixedVideoExitFullscreen = 169,
190         PrefixedVideoEnterFullScreen = 170,
191         PrefixedVideoExitFullScreen = 171,
192         PrefixedVideoDecodedFrameCount = 172,
193         PrefixedVideoDroppedFrameCount = 173,
194         PrefixedElementRequestFullscreen = 176,
195         PrefixedElementRequestFullScreen = 177,
196         BarPropLocationbar = 178,
197         BarPropMenubar = 179,
198         BarPropPersonalbar = 180,
199         BarPropScrollbars = 181,
200         BarPropStatusbar = 182,
201         BarPropToolbar = 183,
202         InputTypeEmailMultiple = 184,
203         InputTypeEmailMaxLength = 185,
204         InputTypeEmailMultipleMaxLength = 186,
205         InputTypeText = 190,
206         InputTypeTextMaxLength = 191,
207         InputTypePassword = 192,
208         InputTypePasswordMaxLength = 193,
209         SVGInstanceRoot = 194,
210         ShowModalDialog = 195,
211         PrefixedPageVisibility = 196,
212         CSSStyleSheetInsertRuleOptionalArg = 198, // Inconsistent with the specification and other browsers.
213         DocumentBeforeUnloadRegistered = 200,
214         DocumentBeforeUnloadFired = 201,
215         DocumentUnloadRegistered = 202,
216         DocumentUnloadFired = 203,
217         SVGLocatableNearestViewportElement = 204,
218         SVGLocatableFarthestViewportElement = 205,
219         HTMLHeadElementProfile = 207,
220         OverflowChangedEvent = 208,
221         SVGPointMatrixTransform = 209,
222         DOMFocusInOutEvent = 211,
223         FileGetLastModifiedDate = 212,
224         HTMLElementInnerText = 213,
225         HTMLElementOuterText = 214,
226         ReplaceDocumentViaJavaScriptURL = 215,
227         ElementSetAttributeNodeNS = 216, // Removed from DOM4.
228         ElementPrefixedMatchesSelector = 217,
229         CSSStyleSheetRules = 219,
230         CSSStyleSheetAddRule = 220,
231         CSSStyleSheetRemoveRule = 221,
232         // The above items are available in M33 branch.
233
234         InitMessageEvent = 222,
235         ElementSetPrefix = 224, // Element.prefix is readonly in DOM4.
236         CSSStyleDeclarationGetPropertyCSSValue = 225,
237         PrefixedMediaCancelKeyRequest = 229,
238         DOMImplementationHasFeature = 230,
239         DOMImplementationHasFeatureReturnFalse = 231,
240         CanPlayTypeKeySystem = 232,
241         PrefixedDevicePixelRatioMediaFeature = 233,
242         PrefixedMaxDevicePixelRatioMediaFeature = 234,
243         PrefixedMinDevicePixelRatioMediaFeature = 235,
244         PrefixedTransform3dMediaFeature = 237,
245         PrefixedStorageQuota = 240,
246         ContentSecurityPolicyReportOnlyInMeta = 241,
247         ResetReferrerPolicy = 243,
248         CaseInsensitiveAttrSelectorMatch = 244, // Case-insensitivity dropped from specification.
249         FormNameAccessForImageElement = 246,
250         FormNameAccessForPastNamesMap = 247,
251         FormAssociationByParser = 248,
252         SVGSVGElementInDocument = 250,
253         SVGDocumentRootElement = 251,
254         MediaErrorEncrypted = 253,
255         EventSourceURL = 254,
256         WebSocketURL = 255,
257         WorkerSubjectToCSP = 257,
258         WorkerAllowedByChildBlockedByScript = 258,
259         DeprecatedWebKitGradient = 260,
260         DeprecatedWebKitLinearGradient = 261,
261         DeprecatedWebKitRepeatingLinearGradient = 262,
262         DeprecatedWebKitRadialGradient = 263,
263         DeprecatedWebKitRepeatingRadialGradient = 264,
264         PrefixedImageSmoothingEnabled = 267,
265         UnprefixedImageSmoothingEnabled = 268,
266         PromiseConstructor = 270,
267         PromiseCast = 271,
268         PromiseReject = 272,
269         PromiseResolve = 273,
270         // The above items are available in M34 branch.
271
272         TextAutosizing = 274,
273         TextAutosizingLayout = 275,
274         HTMLAnchorElementPingAttribute = 276,
275         InsertAdjacentHTML = 278,
276         SVGClassName = 279,
277         HTMLAppletElement = 280,
278         HTMLMediaElementSeekToFragmentStart = 281,
279         HTMLMediaElementPauseAtFragmentEnd = 282,
280         PrefixedWindowURL = 283,
281         PrefixedWorkerURL = 284, // This didn't work because of crbug.com/376039. Available since M37.
282         WindowOrientation = 285,
283         DOMStringListContains = 286,
284         DocumentCaptureEvents = 287,
285         DocumentReleaseEvents = 288,
286         WindowCaptureEvents = 289,
287         WindowReleaseEvents = 290,
288         PrefixedGamepad = 291,
289         ElementAnimateKeyframeListEffectObjectTiming = 292,
290         ElementAnimateKeyframeListEffectDoubleTiming = 293,
291         ElementAnimateKeyframeListEffectNoTiming = 294,
292         DocumentXPathCreateExpression = 295,
293         DocumentXPathCreateNSResolver = 296,
294         DocumentXPathEvaluate = 297,
295         AttrGetValue = 298,
296         AttrSetValue = 299,
297         AnimationConstructorKeyframeListEffectObjectTiming = 300,
298         AnimationConstructorKeyframeListEffectDoubleTiming = 301,
299         AnimationConstructorKeyframeListEffectNoTiming = 302,
300         AttrSetValueWithElement = 303,
301         PrefixedCancelAnimationFrame = 304,
302         PrefixedCancelRequestAnimationFrame = 305,
303         NamedNodeMapGetNamedItem = 306,
304         NamedNodeMapSetNamedItem = 307,
305         NamedNodeMapRemoveNamedItem = 308,
306         NamedNodeMapItem = 309,
307         NamedNodeMapGetNamedItemNS = 310,
308         NamedNodeMapSetNamedItemNS = 311,
309         NamedNodeMapRemoveNamedItemNS = 312,
310         OpenWebDatabaseInWorker = 313, // This didn't work because of crbug.com/376039. Available since M37.
311         OpenWebDatabaseSyncInWorker = 314, // This didn't work because of crbug.com/376039. Available since M37.
312         XHRProgressEventPosition = 316,
313         XHRProgressEventTotalSize = 317,
314         PrefixedDocumentIsFullscreen = 318,
315         PrefixedDocumentFullScreenKeyboardInputAllowed = 319,
316         PrefixedDocumentCurrentFullScreenElement = 320,
317         PrefixedDocumentCancelFullScreen = 321,
318         PrefixedDocumentFullscreenEnabled = 322,
319         PrefixedDocumentFullscreenElement = 323,
320         PrefixedDocumentExitFullscreen = 324,
321         // The above items are available in M35 branch.
322
323         SVGForeignObjectElement = 325,
324         PrefixedElementRequestPointerLock = 326,
325         SelectionSetPosition = 327,
326         AnimationPlayerFinishEvent = 328,
327         SVGSVGElementInXMLDocument = 329,
328         CanvasRenderingContext2DSetAlpha = 330,
329         CanvasRenderingContext2DSetCompositeOperation = 331,
330         CanvasRenderingContext2DSetLineWidth = 332,
331         CanvasRenderingContext2DSetLineCap = 333,
332         CanvasRenderingContext2DSetLineJoin = 334,
333         CanvasRenderingContext2DSetMiterLimit = 335,
334         CanvasRenderingContext2DClearShadow = 336,
335         CanvasRenderingContext2DSetStrokeColor = 337,
336         CanvasRenderingContext2DSetFillColor = 338,
337         CanvasRenderingContext2DDrawImageFromRect = 339,
338         CanvasRenderingContext2DSetShadow = 340,
339         PrefixedPerformanceClearResourceTimings = 341,
340         PrefixedPerformanceSetResourceTimingBufferSize = 342,
341         EventSrcElement = 343,
342         EventCancelBubble = 344,
343         EventPath = 345,
344         EventClipboardData = 346,
345         NodeIteratorDetach = 347,
346         AttrNodeValue = 348,
347         AttrTextContent = 349,
348         EventGetReturnValueTrue = 350,
349         EventGetReturnValueFalse = 351,
350         EventSetReturnValueTrue = 352,
351         EventSetReturnValueFalse = 353,
352         NodeIteratorExpandEntityReferences = 354,
353         TreeWalkerExpandEntityReferences = 355,
354         WindowOffscreenBuffering = 356,
355         WindowDefaultStatus = 357,
356         WindowDefaultstatus = 358,
357         PrefixedConvertPointFromPageToNode = 359,
358         PrefixedConvertPointFromNodeToPage = 360,
359         PrefixedTransitionEventConstructor = 361,
360         PrefixedMutationObserverConstructor = 362,
361         PrefixedIDBCursorConstructor = 363,
362         PrefixedIDBDatabaseConstructor = 364,
363         PrefixedIDBFactoryConstructor = 365,
364         PrefixedIDBIndexConstructor = 366,
365         PrefixedIDBKeyRangeConstructor = 367,
366         PrefixedIDBObjectStoreConstructor = 368,
367         PrefixedIDBRequestConstructor = 369,
368         PrefixedIDBTransactionConstructor = 370,
369         NotificationPermission = 371,
370         RangeDetach = 372,
371         HTMLTableElementVspace = 374,
372         HTMLTableElementHspace = 375,
373         PrefixedDocumentExitPointerLock = 376,
374         PrefixedDocumentPointerLockElement = 377,
375         PrefixedTouchRadiusX = 378,
376         PrefixedTouchRadiusY = 379,
377         PrefixedTouchRotationAngle = 380,
378         PrefixedTouchForce = 381,
379         PrefixedMouseEventMovementX = 382,
380         PrefixedMouseEventMovementY = 383,
381         PrefixedFileRelativePath = 386,
382         DocumentCaretRangeFromPoint = 387,
383         DocumentGetCSSCanvasContext = 388,
384         ElementScrollIntoViewIfNeeded = 389,
385         RangeCompareNode = 392,
386         RangeExpand = 393,
387         HTMLImageElementX = 396,
388         HTMLImageElementY = 397,
389         SelectionBaseNode = 400,
390         SelectionBaseOffset = 401,
391         SelectionExtentNode = 402,
392         SelectionExtentOffset = 403,
393         SelectionType = 404,
394         SelectionModify = 405,
395         SelectionSetBaseAndExtent = 406,
396         SelectionEmpty = 407,
397         VTTCue = 409,
398         VTTCueRender = 410,
399         VTTCueRenderVertical = 411,
400         VTTCueRenderSnapToLinesFalse = 412,
401         VTTCueRenderLineNotAuto = 413,
402         VTTCueRenderPositionNot50 = 414,
403         VTTCueRenderSizeNot100 = 415,
404         VTTCueRenderAlignNotMiddle = 416,
405         // The above items are available in M36 branch.
406
407         ElementRequestPointerLock = 417,
408         VTTCueRenderRtl = 418,
409         PostMessageFromSecureToInsecure = 419,
410         PostMessageFromInsecureToSecure = 420,
411         DocumentExitPointerLock = 421,
412         DocumentPointerLockElement = 422,
413         PrefixedCursorZoomIn = 424,
414         PrefixedCursorZoomOut = 425,
415         CSSCharsetRuleEncoding = 426,
416         DocumentSetCharset = 427,
417         DocumentDefaultCharset = 428,
418         TextEncoderConstructor = 429,
419         TextEncoderEncode = 430,
420         TextDecoderConstructor = 431,
421         TextDecoderDecode= 432,
422         FocusInOutEvent = 433,
423         MouseEventMovementX = 434,
424         MouseEventMovementY = 435,
425         MixedContentTextTrack = 436,
426         MixedContentRaw = 437,
427         MixedContentImage = 438,
428         MixedContentMedia = 439,
429         DocumentFonts = 440,
430         MixedContentFormsSubmitted = 441,
431         FormsSubmitted = 442,
432         TextInputEventOnInput = 443,
433         TextInputEventOnTextArea = 444,
434         TextInputEventOnContentEditable= 445,
435         TextInputEventOnNotNode = 446,
436         WebkitBeforeTextInsertedOnInput = 447,
437         WebkitBeforeTextInsertedOnTextArea = 448,
438         WebkitBeforeTextInsertedOnContentEditable = 449,
439         WebkitBeforeTextInsertedOnNotNode = 450,
440         WebkitEditableContentChangedOnInput = 451,
441         WebkitEditableContentChangedOnTextArea = 452,
442         WebkitEditableContentChangedOnContentEditable = 453,
443         WebkitEditableContentChangedOnNotNode = 454,
444         HTMLImports = 455,
445         ElementCreateShadowRoot = 456,
446         DocumentRegisterElement = 457,
447         EditingAppleInterchangeNewline = 458,
448         EditingAppleConvertedSpace = 459,
449         EditingApplePasteAsQuotation = 460,
450         EditingAppleStyleSpanClass = 461,
451         EditingAppleTabSpanClass = 462,
452         HTMLImportsAsyncAttribute = 463,
453         FontFaceSetReady = 464,
454         XMLHttpRequestSynchronous = 465,
455         CSSSelectorPseudoUnresolved = 466,
456         CSSSelectorPseudoShadow = 467,
457         CSSSelectorPseudoContent = 468,
458         CSSSelectorPseudoHost = 469,
459         CSSSelectorPseudoHostContext = 470,
460         CSSDeepCombinator = 471,
461         SyncXHRWithCredentials = 472,
462         // The above items are available in M37 branch.
463
464         UseAsm = 473,
465         KeyEventNotAllowedInFullScreen = 474,
466         DOMWindowOpen = 475,
467         DOMWindowOpenFeatures = 476,
468         MediaStreamTrackGetSources = 478,
469         AspectRatioFlexItem = 479,
470         DetailsElement = 480,
471         DialogElement = 481,
472         MapElement = 482,
473         MeterElement = 483,
474         ProgressElement = 484,
475         VideoFullscreenAllowedExemption = 485,
476         WebKitPoint = 488,
477         PrefixedHTMLElementDropzone = 490,
478         WheelEventWheelDeltaX = 491,
479         WheelEventWheelDeltaY = 492,
480         WheelEventWheelDelta = 493,
481         SendBeacon = 494,
482         SendBeaconQuotaExceeded = 495,
483         SVGSMILElementInDocument = 501,
484         MouseEventOffsetX = 502,
485         MouseEventOffsetY = 503,
486         MouseEventX = 504,
487         MouseEventY = 505,
488         MouseEventFromElement = 506,
489         MouseEventToElement = 507,
490         RequestFileSystem = 508,
491         RequestFileSystemWorker = 509,
492         RequestFileSystemSyncWorker = 510,
493         UIEventLayerX = 511,
494         UIEventLayerY = 512,
495         UIEventPageX = 513,
496         UIEventPageY = 514,
497         BgPropertiesFixed = 515,
498         HTMLImageElementComposite = 516,
499         DevToolsConsoleTimeline = 517,
500         DevToolsConsoleProfile = 518,
501         SVGStyleElementTitle = 519,
502         PictureSourceSrc = 520,
503         // Add new features immediately above this line. Don't change assigned
504         // numbers of any item, and don't reuse removed slots.
505         // Also, run update_use_counter_feature_enum.py in chromium/src/tools/metrics/histograms/
506         // to update the UMA mapping.
507         NumberOfFeatures, // This enum value must be last.
508     };
509
510     // "count" sets the bit for this feature to 1. Repeated calls are ignored.
511     static void count(const Document&, Feature);
512     // This doesn't count for ExecutionContexts for shared workers and service
513     // workers.
514     static void count(const ExecutionContext*, Feature);
515     void count(CSSParserContext, CSSPropertyID);
516     void count(Feature);
517
518     // "countDeprecation" sets the bit for this feature to 1, and sends a deprecation
519     // warning to the console. Repeated calls are ignored.
520     //
521     // Be considerate to developers' consoles: features should only send
522     // deprecation warnings when we're actively interested in removing them from
523     // the platform.
524     //
525     // The ExecutionContext* overload doesn't work for shared workers and
526     // service workers.
527     static void countDeprecation(const LocalDOMWindow*, Feature);
528     static void countDeprecation(ExecutionContext*, Feature);
529     static void countDeprecation(const Document&, Feature);
530     String deprecationMessage(Feature);
531
532     void didCommitLoad();
533
534     static UseCounter* getFrom(const Document*);
535     static UseCounter* getFrom(const CSSStyleSheet*);
536     static UseCounter* getFrom(const StyleSheetContents*);
537
538     static int mapCSSPropertyIdToCSSSampleIdForHistogram(int id);
539
540     static void muteForInspector();
541     static void unmuteForInspector();
542
543 private:
544     static int m_muteCount;
545
546     bool recordMeasurement(Feature feature)
547     {
548         if (UseCounter::m_muteCount)
549             return false;
550         ASSERT(feature != PageDestruction); // PageDestruction is reserved as a scaling factor.
551         ASSERT(feature < NumberOfFeatures);
552         if (!m_countBits) {
553             m_countBits = adoptPtr(new BitVector(NumberOfFeatures));
554             m_countBits->clearAll();
555         }
556
557         if (m_countBits->quickGet(feature))
558             return false;
559
560         m_countBits->quickSet(feature);
561         return true;
562     }
563
564     void updateMeasurements();
565
566     OwnPtr<BitVector> m_countBits;
567     BitVector m_CSSFeatureBits;
568 };
569
570 } // namespace blink
571
572 #endif // UseCounter_h