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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // | 60 // |
61 // Changes on UseCounter are observable by UseCounter::Observer. | 61 // Changes on UseCounter are observable by UseCounter::Observer. |
62 class CORE_EXPORT UseCounter { | 62 class CORE_EXPORT UseCounter { |
63 DISALLOW_NEW(); | 63 DISALLOW_NEW(); |
64 WTF_MAKE_NONCOPYABLE(UseCounter); | 64 WTF_MAKE_NONCOPYABLE(UseCounter); |
65 | 65 |
66 public: | 66 public: |
67 enum Context { | 67 enum Context { |
68 kDefaultContext, | 68 kDefaultContext, |
69 // Counters for SVGImages (lifetime independent from other pages). | 69 // Counters for SVGImages (lifetime independent from other pages). |
70 kSVGImageContext | 70 kSVGImageContext, |
| 71 // Counters for extensions. |
| 72 kExtensionContext, |
| 73 // Context when counters should be disabled (eg, internal pages such as |
| 74 // about, chrome-devtools, etc). |
| 75 kDisabledContext |
71 }; | 76 }; |
72 | 77 |
73 UseCounter(Context = kDefaultContext); | 78 UseCounter(Context = kDefaultContext); |
74 | 79 |
75 enum Feature : uint32_t { | 80 enum Feature : uint32_t { |
76 // Do not change assigned numbers of existing items: add new features | 81 // Do not change assigned numbers of existing items: add new features |
77 // to the end of the list. | 82 // to the end of the list. |
78 kOBSOLETE_PageDestruction = 0, | 83 kOBSOLETE_PageDestruction = 0, |
79 kWorkerStart = 4, | 84 kWorkerStart = 4, |
80 kSharedWorkerStart = 5, | 85 kSharedWorkerStart = 5, |
(...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 kFontShapingNotDefGlyphObserved = 1973, | 1587 kFontShapingNotDefGlyphObserved = 1973, |
1583 | 1588 |
1584 // Add new features immediately above this line. Don't change assigned | 1589 // Add new features immediately above this line. Don't change assigned |
1585 // numbers of any item, and don't reuse removed slots. | 1590 // numbers of any item, and don't reuse removed slots. |
1586 // Also, run update_use_counter_feature_enum.py in | 1591 // Also, run update_use_counter_feature_enum.py in |
1587 // chromium/src/tools/metrics/histograms/ to update the UMA mapping. | 1592 // chromium/src/tools/metrics/histograms/ to update the UMA mapping. |
1588 kNumberOfFeatures, // This enum value must be last. | 1593 kNumberOfFeatures, // This enum value must be last. |
1589 }; | 1594 }; |
1590 | 1595 |
1591 // An interface to observe UseCounter changes. Note that this is never | 1596 // An interface to observe UseCounter changes. Note that this is never |
1592 // notified when the counter is disabled by |m_muteCount| or | 1597 // notified when the counter is disabled by |m_muteCount| or when |m_context| |
1593 // |m_disableReporting|. | 1598 // is DisabledContext. |
1594 class Observer : public GarbageCollected<Observer> { | 1599 class Observer : public GarbageCollected<Observer> { |
1595 public: | 1600 public: |
1596 // Notified when a feature is counted for the first time. This should return | 1601 // Notified when a feature is counted for the first time. This should return |
1597 // true if it no longer needs to observe changes so that the counter can | 1602 // true if it no longer needs to observe changes so that the counter can |
1598 // remove a reference to the observer and stop notifications. | 1603 // remove a reference to the observer and stop notifications. |
1599 virtual bool OnCountFeature(Feature) = 0; | 1604 virtual bool OnCountFeature(Feature) = 0; |
1600 | 1605 |
1601 DEFINE_INLINE_VIRTUAL_TRACE() {} | 1606 DEFINE_INLINE_VIRTUAL_TRACE() {} |
1602 }; | 1607 }; |
1603 | 1608 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 | 1650 |
1646 // Return whether the feature has been seen since the last page load | 1651 // Return whether the feature has been seen since the last page load |
1647 // (except when muted). Does include features seen in documents which have | 1652 // (except when muted). Does include features seen in documents which have |
1648 // reporting disabled. | 1653 // reporting disabled. |
1649 bool HasRecordedMeasurement(Feature) const; | 1654 bool HasRecordedMeasurement(Feature) const; |
1650 | 1655 |
1651 DECLARE_TRACE(); | 1656 DECLARE_TRACE(); |
1652 | 1657 |
1653 private: | 1658 private: |
1654 // Notifies that a feature is newly counted to |m_observers|. This shouldn't | 1659 // Notifies that a feature is newly counted to |m_observers|. This shouldn't |
1655 // be called when the counter is disabled by |m_muteCount| or | 1660 // be called when the counter is disabled by |m_muteCount| or when |m_context| |
1656 // |m_disableReporting|. | 1661 // if DisabledContext. |
1657 void NotifyFeatureCounted(Feature); | 1662 void NotifyFeatureCounted(Feature); |
1658 | 1663 |
1659 EnumerationHistogram& FeaturesHistogram() const; | 1664 EnumerationHistogram& FeaturesHistogram() const; |
1660 EnumerationHistogram& CssHistogram() const; | 1665 EnumerationHistogram& CssHistogram() const; |
1661 EnumerationHistogram& AnimatedCSSHistogram() const; | 1666 EnumerationHistogram& AnimatedCSSHistogram() const; |
1662 | 1667 |
1663 // If non-zero, ignore all 'count' calls completely. | 1668 // If non-zero, ignore all 'count' calls completely. |
1664 unsigned mute_count_; | 1669 unsigned mute_count_; |
1665 | 1670 |
1666 // If true, disable reporting all histogram entries. | 1671 // The scope represented by this UseCounter instance, which must be fixed for |
1667 bool disable_reporting_; | 1672 // the duration of a page but can change when a new page is loaded. |
1668 | |
1669 // The scope represented by this UseCounter instance. | |
1670 Context context_; | 1673 Context context_; |
1671 | 1674 |
1672 // Track what features/properties have been reported to the (non-legacy) | 1675 // Track what features/properties have been reported to the (non-legacy) |
1673 // histograms. | 1676 // histograms. |
1674 BitVector features_recorded_; | 1677 BitVector features_recorded_; |
1675 BitVector css_recorded_; | 1678 BitVector css_recorded_; |
1676 BitVector animated_css_recorded_; | 1679 BitVector animated_css_recorded_; |
1677 | 1680 |
1678 HeapHashSet<Member<Observer>> observers_; | 1681 HeapHashSet<Member<Observer>> observers_; |
1679 | 1682 |
(...skipping 12 matching lines...) Expand all Loading... |
1692 // Tracks what features/properties need to be reported to the legacy | 1695 // Tracks what features/properties need to be reported to the legacy |
1693 // histograms. | 1696 // histograms. |
1694 BitVector feature_bits_; | 1697 BitVector feature_bits_; |
1695 BitVector css_bits_; | 1698 BitVector css_bits_; |
1696 } legacy_counter_; | 1699 } legacy_counter_; |
1697 }; | 1700 }; |
1698 | 1701 |
1699 } // namespace blink | 1702 } // namespace blink |
1700 | 1703 |
1701 #endif // UseCounter_h | 1704 #endif // UseCounter_h |
OLD | NEW |