Chromium Code Reviews| Index: third_party/WebKit/Source/core/frame/UseCounter.h |
| diff --git a/third_party/WebKit/Source/core/frame/UseCounter.h b/third_party/WebKit/Source/core/frame/UseCounter.h |
| index a05f092d92800c6e30de69e1c9708dbe680a1fab..95b754dfff1d9e131dd8fa8e4f73481b33f8136b 100644 |
| --- a/third_party/WebKit/Source/core/frame/UseCounter.h |
| +++ b/third_party/WebKit/Source/core/frame/UseCounter.h |
| @@ -60,8 +60,10 @@ class CORE_EXPORT UseCounter { |
| DISALLOW_NEW(); |
| WTF_MAKE_NONCOPYABLE(UseCounter); |
| public: |
| - UseCounter(); |
| - ~UseCounter(); |
| + UseCounter() |
| + : m_featuresReported(NumberOfFeatures) |
| + , m_CSSFeaturesReported(lastUnresolvedCSSProperty + 1) |
| + {} |
| enum Feature { |
| // Do not change assigned numbers of existing items: add new features |
| @@ -1237,58 +1239,44 @@ public: |
| bool isCounted(CSSPropertyID unresolvedProperty); |
| void didCommitLoad(); |
| + void deprecatedDidCommitFrameLoad() { m_legacyCounter.updateMeasurements(); } |
| + |
| + void recordMeasurement(Feature); |
| + bool hasRecordedMeasurement(Feature feature) const { return m_featuresReported.quickGet(feature); } |
|
dtapuska
2016/05/31 01:10:51
The semantics of this are changing wrt muted count
|
| static UseCounter* getFrom(const Document*); |
| static UseCounter* getFrom(const CSSStyleSheet*); |
| static UseCounter* getFrom(const StyleSheetContents*); |
| - static int mapCSSPropertyIdToCSSSampleIdForHistogram(int id); |
| + static int mapCSSPropertyIdToCSSSampleIdForHistogram(CSSPropertyID); |
| static void muteForInspector(); |
| static void unmuteForInspector(); |
| + static bool isMuted() { return m_muteCount; } |
| - void recordMeasurement(Feature feature) { m_countBits.recordMeasurement(feature); } |
| - void updateMeasurements(); |
| +protected: |
| + BitVector m_featuresReported; |
| + BitVector m_CSSFeaturesReported; |
| - bool hasRecordedMeasurement(Feature feature) const { return m_countBits.hasRecordedMeasurement(feature); } |
| + friend class UseCounterTest; |
| + static int m_muteCount; |
| - class CountBits { |
| - DISALLOW_NEW(); |
| +private: |
| + // Encapsulates the work to preserve the old "FeatureObserver" histogram with original (buggy) |
| + // semantics. Will be removed eventually. http://crbug.com/597963 |
| + class LegacyCounter { |
| public: |
| - CountBits() : m_bits(NumberOfFeatures) { } |
| - |
| - bool hasRecordedMeasurement(Feature feature) const |
| - { |
| - if (UseCounter::m_muteCount) |
| - return false; |
| - ASSERT(feature != PageDestruction); // PageDestruction is reserved as a scaling factor. |
| - ASSERT(feature < NumberOfFeatures); |
| - |
| - return m_bits.quickGet(feature); |
| - } |
| - |
| - void recordMeasurement(Feature feature) |
| - { |
| - if (UseCounter::m_muteCount) |
| - return; |
| - ASSERT(feature != PageDestruction); // PageDestruction is reserved as a scaling factor. |
| - ASSERT(feature < NumberOfFeatures); |
| - |
| - m_bits.quickSet(feature); |
| - } |
| - |
| + LegacyCounter(); |
| + ~LegacyCounter(); |
| + void recordMeasurement(Feature); |
| void updateMeasurements(); |
| + bool hasRecordedMeasurement(Feature) const; |
|
dtapuska
2016/05/31 01:10:51
Is this method called anywhere?
|
| + void countCSS(CSSPropertyID feature); |
|
dtapuska
2016/05/31 01:10:51
Likely using a consistent verbage here is good. Co
|
| private: |
| - BitVector m_bits; |
| - }; |
| - |
| -protected: |
| - friend class UseCounterTest; |
| - static int m_muteCount; |
| - |
| - CountBits m_countBits; |
| - BitVector m_CSSFeatureBits; |
| + BitVector m_countBits; |
| + BitVector m_CSSFeatureBits; |
| + } m_legacyCounter; |
| }; |
| } // namespace blink |