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