Chromium Code Reviews| 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 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1580 kGamepadButtons = 1965, | 1585 kGamepadButtons = 1965, |
| 1581 | 1586 |
| 1582 // Add new features immediately above this line. Don't change assigned | 1587 // Add new features immediately above this line. Don't change assigned |
| 1583 // numbers of any item, and don't reuse removed slots. | 1588 // numbers of any item, and don't reuse removed slots. |
| 1584 // Also, run update_use_counter_feature_enum.py in | 1589 // Also, run update_use_counter_feature_enum.py in |
| 1585 // chromium/src/tools/metrics/histograms/ to update the UMA mapping. | 1590 // chromium/src/tools/metrics/histograms/ to update the UMA mapping. |
| 1586 kNumberOfFeatures, // This enum value must be last. | 1591 kNumberOfFeatures, // This enum value must be last. |
| 1587 }; | 1592 }; |
| 1588 | 1593 |
| 1589 // An interface to observe UseCounter changes. Note that this is never | 1594 // An interface to observe UseCounter changes. Note that this is never |
| 1590 // notified when the counter is disabled by |m_muteCount| or | 1595 // notified when the counter is disabled by |m_muteCount| or when |m_context| |
| 1591 // |m_disableReporting|. | 1596 // is DisabledContext. |
| 1592 class Observer : public GarbageCollected<Observer> { | 1597 class Observer : public GarbageCollected<Observer> { |
| 1593 public: | 1598 public: |
| 1594 // Notified when a feature is counted for the first time. This should return | 1599 // Notified when a feature is counted for the first time. This should return |
| 1595 // true if it no longer needs to observe changes so that the counter can | 1600 // true if it no longer needs to observe changes so that the counter can |
| 1596 // remove a reference to the observer and stop notifications. | 1601 // remove a reference to the observer and stop notifications. |
| 1597 virtual bool OnCountFeature(Feature) = 0; | 1602 virtual bool OnCountFeature(Feature) = 0; |
| 1598 | 1603 |
| 1599 DEFINE_INLINE_VIRTUAL_TRACE() {} | 1604 DEFINE_INLINE_VIRTUAL_TRACE() {} |
| 1600 }; | 1605 }; |
| 1601 | 1606 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1643 | 1648 |
| 1644 // Return whether the feature has been seen since the last page load | 1649 // Return whether the feature has been seen since the last page load |
| 1645 // (except when muted). Does include features seen in documents which have | 1650 // (except when muted). Does include features seen in documents which have |
| 1646 // reporting disabled. | 1651 // reporting disabled. |
| 1647 bool HasRecordedMeasurement(Feature) const; | 1652 bool HasRecordedMeasurement(Feature) const; |
| 1648 | 1653 |
| 1649 DECLARE_TRACE(); | 1654 DECLARE_TRACE(); |
| 1650 | 1655 |
| 1651 private: | 1656 private: |
| 1652 // Notifies that a feature is newly counted to |m_observers|. This shouldn't | 1657 // Notifies that a feature is newly counted to |m_observers|. This shouldn't |
| 1653 // be called when the counter is disabled by |m_muteCount| or | 1658 // be called when the counter is disabled by |m_muteCount| or when |m_context| |
| 1654 // |m_disableReporting|. | 1659 // if DisabledContext. |
| 1655 void NotifyFeatureCounted(Feature); | 1660 void NotifyFeatureCounted(Feature); |
| 1656 | 1661 |
| 1657 EnumerationHistogram& FeaturesHistogram() const; | 1662 EnumerationHistogram& FeaturesHistogram() const; |
| 1658 EnumerationHistogram& CssHistogram() const; | 1663 EnumerationHistogram& CssHistogram() const; |
| 1659 EnumerationHistogram& AnimatedCSSHistogram() const; | 1664 EnumerationHistogram& AnimatedCSSHistogram() const; |
| 1660 | 1665 |
| 1661 // If non-zero, ignore all 'count' calls completely. | 1666 // If non-zero, ignore all 'count' calls completely. |
| 1662 unsigned mute_count_; | 1667 unsigned mute_count_; |
| 1663 | 1668 |
| 1664 // If true, disable reporting all histogram entries. | |
| 1665 bool disable_reporting_; | |
| 1666 | |
| 1667 // The scope represented by this UseCounter instance. | 1669 // The scope represented by this UseCounter instance. |
|
Rick Byers
2017/04/28 15:04:40
Nit: can you add a comment saying that this must b
lunalu1
2017/05/01 15:37:52
Done. Thanks
| |
| 1668 Context context_; | 1670 Context context_; |
| 1669 | 1671 |
| 1670 // Track what features/properties have been reported to the (non-legacy) | 1672 // Track what features/properties have been reported to the (non-legacy) |
| 1671 // histograms. | 1673 // histograms. |
| 1672 BitVector features_recorded_; | 1674 BitVector features_recorded_; |
| 1673 BitVector css_recorded_; | 1675 BitVector css_recorded_; |
| 1674 BitVector animated_css_recorded_; | 1676 BitVector animated_css_recorded_; |
| 1675 | 1677 |
| 1676 HeapHashSet<Member<Observer>> observers_; | 1678 HeapHashSet<Member<Observer>> observers_; |
| 1677 | 1679 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1690 // Tracks what features/properties need to be reported to the legacy | 1692 // Tracks what features/properties need to be reported to the legacy |
| 1691 // histograms. | 1693 // histograms. |
| 1692 BitVector feature_bits_; | 1694 BitVector feature_bits_; |
| 1693 BitVector css_bits_; | 1695 BitVector css_bits_; |
| 1694 } legacy_counter_; | 1696 } legacy_counter_; |
| 1695 }; | 1697 }; |
| 1696 | 1698 |
| 1697 } // namespace blink | 1699 } // namespace blink |
| 1698 | 1700 |
| 1699 #endif // UseCounter_h | 1701 #endif // UseCounter_h |
| OLD | NEW |