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