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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 void count(CSSParserContext, CSSPropertyID); | 647 void count(CSSParserContext, CSSPropertyID); |
648 void count(Feature); | 648 void count(Feature); |
649 | 649 |
650 // "countDeprecation" sets the bit for this feature to 1, and sends a deprec
ation | 650 // "countDeprecation" sets the bit for this feature to 1, and sends a deprec
ation |
651 // warning to the console. Repeated calls are ignored. | 651 // warning to the console. Repeated calls are ignored. |
652 // | 652 // |
653 // Be considerate to developers' consoles: features should only send | 653 // Be considerate to developers' consoles: features should only send |
654 // deprecation warnings when we're actively interested in removing them from | 654 // deprecation warnings when we're actively interested in removing them from |
655 // the platform. | 655 // the platform. |
656 // | 656 // |
657 // The ExecutionContext* overload doesn't work for shared workers and | 657 // For shared workers and service workers, the ExecutionContext* overload |
658 // service workers. | 658 // doesn't count the usage but only sends a console warning. |
659 static void countDeprecation(const LocalFrame*, Feature); | 659 static void countDeprecation(const LocalFrame*, Feature); |
660 static void countDeprecation(ExecutionContext*, Feature); | 660 static void countDeprecation(ExecutionContext*, Feature); |
661 static void countDeprecation(const Document&, Feature); | 661 static void countDeprecation(const Document&, Feature); |
662 // Use countDeprecationIfNotPrivateScript() instead of countDeprecation() | 662 // Use countDeprecationIfNotPrivateScript() instead of countDeprecation() |
663 // if you don't want to count metrics in private scripts. You should use | 663 // if you don't want to count metrics in private scripts. You should use |
664 // countDeprecationIfNotPrivateScript() in a binding layer. | 664 // countDeprecationIfNotPrivateScript() in a binding layer. |
665 static void countDeprecationIfNotPrivateScript(v8::Isolate*, ExecutionContex
t*, Feature); | 665 static void countDeprecationIfNotPrivateScript(v8::Isolate*, ExecutionContex
t*, Feature); |
666 String deprecationMessage(Feature); | 666 static String deprecationMessage(Feature); |
667 | 667 |
668 void didCommitLoad(); | 668 void didCommitLoad(); |
669 | 669 |
670 static UseCounter* getFrom(const Document*); | 670 static UseCounter* getFrom(const Document*); |
671 static UseCounter* getFrom(const CSSStyleSheet*); | 671 static UseCounter* getFrom(const CSSStyleSheet*); |
672 static UseCounter* getFrom(const StyleSheetContents*); | 672 static UseCounter* getFrom(const StyleSheetContents*); |
673 | 673 |
674 static int mapCSSPropertyIdToCSSSampleIdForHistogram(int id); | 674 static int mapCSSPropertyIdToCSSSampleIdForHistogram(int id); |
675 | 675 |
676 static void muteForInspector(); | 676 static void muteForInspector(); |
677 static void unmuteForInspector(); | 677 static void unmuteForInspector(); |
678 | 678 |
| 679 class CountBits { |
| 680 public: |
| 681 bool recordMeasurement(Feature feature) |
| 682 { |
| 683 if (UseCounter::m_muteCount) |
| 684 return false; |
| 685 ASSERT(feature != PageDestruction); // PageDestruction is reserved a
s a scaling factor. |
| 686 ASSERT(feature < NumberOfFeatures); |
| 687 if (!m_bits) { |
| 688 m_bits = adoptPtr(new BitVector(NumberOfFeatures)); |
| 689 m_bits->clearAll(); |
| 690 } |
| 691 |
| 692 if (m_bits->quickGet(feature)) |
| 693 return false; |
| 694 |
| 695 m_bits->quickSet(feature); |
| 696 return true; |
| 697 } |
| 698 void updateMeasurements(); |
| 699 |
| 700 private: |
| 701 OwnPtr<BitVector> m_bits; |
| 702 }; |
| 703 |
679 private: | 704 private: |
680 static int m_muteCount; | 705 static int m_muteCount; |
681 | 706 |
682 bool recordMeasurement(Feature feature) | 707 bool recordMeasurement(Feature feature) { return m_countBits.recordMeasureme
nt(feature); } |
683 { | |
684 if (UseCounter::m_muteCount) | |
685 return false; | |
686 ASSERT(feature != PageDestruction); // PageDestruction is reserved as a
scaling factor. | |
687 ASSERT(feature < NumberOfFeatures); | |
688 if (!m_countBits) { | |
689 m_countBits = adoptPtr(new BitVector(NumberOfFeatures)); | |
690 m_countBits->clearAll(); | |
691 } | |
692 | |
693 if (m_countBits->quickGet(feature)) | |
694 return false; | |
695 | |
696 m_countBits->quickSet(feature); | |
697 return true; | |
698 } | |
699 | |
700 void updateMeasurements(); | 708 void updateMeasurements(); |
701 | 709 |
702 OwnPtr<BitVector> m_countBits; | 710 CountBits m_countBits; |
703 BitVector m_CSSFeatureBits; | 711 BitVector m_CSSFeatureBits; |
704 }; | 712 }; |
705 | 713 |
706 } // namespace blink | 714 } // namespace blink |
707 | 715 |
708 #endif // UseCounter_h | 716 #endif // UseCounter_h |
OLD | NEW |