| 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 25 matching lines...) Expand all Loading... |
| 36 #include "core/inspector/ConsoleMessage.h" | 36 #include "core/inspector/ConsoleMessage.h" |
| 37 #include "core/workers/WorkerGlobalScope.h" | 37 #include "core/workers/WorkerGlobalScope.h" |
| 38 #include "platform/Histogram.h" | 38 #include "platform/Histogram.h" |
| 39 #include "platform/TraceEvent.h" | 39 #include "platform/TraceEvent.h" |
| 40 | 40 |
| 41 namespace { | 41 namespace { |
| 42 | 42 |
| 43 int totalPagesMeasuredCSSSampleId() { return 1; } | 43 int totalPagesMeasuredCSSSampleId() { return 1; } |
| 44 | 44 |
| 45 // Make sure update_use_counter_css.py was run which updates histograms.xml. | 45 // Make sure update_use_counter_css.py was run which updates histograms.xml. |
| 46 int maximumCSSSampleId() { return 545; } | 46 constexpr int kMaximumCSSSampleId = 545; |
| 47 | 47 |
| 48 } // namespace | 48 } // namespace |
| 49 | 49 |
| 50 namespace blink { | 50 namespace blink { |
| 51 | 51 |
| 52 int UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(CSSPropertyID cssPrope
rtyID) | 52 int UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(CSSPropertyID cssPrope
rtyID) |
| 53 { | 53 { |
| 54 switch (cssPropertyID) { | 54 switch (cssPropertyID) { |
| 55 // Begin at 2, because 1 is reserved for totalPagesMeasuredCSSSampleId. | 55 // Begin at 2, because 1 is reserved for totalPagesMeasuredCSSSampleId. |
| 56 case CSSPropertyColor: return 2; | 56 case CSSPropertyColor: return 2; |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 case CSSPropertyOverflowAnchor: return 538; | 572 case CSSPropertyOverflowAnchor: return 538; |
| 573 case CSSPropertyUserSelect: return 539; | 573 case CSSPropertyUserSelect: return 539; |
| 574 case CSSPropertyOffsetDistance: return 540; | 574 case CSSPropertyOffsetDistance: return 540; |
| 575 case CSSPropertyOffsetPath: return 541; | 575 case CSSPropertyOffsetPath: return 541; |
| 576 case CSSPropertyOffsetRotation: return 542; | 576 case CSSPropertyOffsetRotation: return 542; |
| 577 case CSSPropertyOffset: return 543; | 577 case CSSPropertyOffset: return 543; |
| 578 case CSSPropertyOffsetAnchor: return 544; | 578 case CSSPropertyOffsetAnchor: return 544; |
| 579 case CSSPropertyOffsetPosition: return 545; | 579 case CSSPropertyOffsetPosition: return 545; |
| 580 // 1. Add new features above this line (don't change the assigned numbers of
the existing | 580 // 1. Add new features above this line (don't change the assigned numbers of
the existing |
| 581 // items). | 581 // items). |
| 582 // 2. Update maximumCSSSampleId() with the new maximum value. | 582 // 2. Update kMaximumCSSSampleId with the new maximum value. |
| 583 // 3. Run the update_use_counter_css.py script in | 583 // 3. Run the update_use_counter_css.py script in |
| 584 // chromium/src/tools/metrics/histograms to update the UMA histogram names. | 584 // chromium/src/tools/metrics/histograms to update the UMA histogram names. |
| 585 | 585 |
| 586 case CSSPropertyInvalid: | 586 case CSSPropertyInvalid: |
| 587 ASSERT_NOT_REACHED(); | 587 ASSERT_NOT_REACHED(); |
| 588 return 0; | 588 return 0; |
| 589 } | 589 } |
| 590 | 590 |
| 591 ASSERT_NOT_REACHED(); | 591 ASSERT_NOT_REACHED(); |
| 592 return 0; | 592 return 0; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 // Eg. every SVGImage has it's own Page instance, they should probably all b
e delegating | 788 // Eg. every SVGImage has it's own Page instance, they should probably all b
e delegating |
| 789 // their UseCounter to the containing Page. For now just use a separate his
togram. | 789 // their UseCounter to the containing Page. For now just use a separate his
togram. |
| 790 DEFINE_STATIC_LOCAL(blink::EnumerationHistogram, histogram, ("WebCore.UseCou
nter_TEST.Features", blink::UseCounter::NumberOfFeatures)); | 790 DEFINE_STATIC_LOCAL(blink::EnumerationHistogram, histogram, ("WebCore.UseCou
nter_TEST.Features", blink::UseCounter::NumberOfFeatures)); |
| 791 DEFINE_STATIC_LOCAL(blink::EnumerationHistogram, svgHistogram, ("WebCore.Use
Counter_TEST.SVGImage.Features", blink::UseCounter::NumberOfFeatures)); | 791 DEFINE_STATIC_LOCAL(blink::EnumerationHistogram, svgHistogram, ("WebCore.Use
Counter_TEST.SVGImage.Features", blink::UseCounter::NumberOfFeatures)); |
| 792 | 792 |
| 793 return m_context == SVGImageContext ? svgHistogram : histogram; | 793 return m_context == SVGImageContext ? svgHistogram : histogram; |
| 794 } | 794 } |
| 795 | 795 |
| 796 EnumerationHistogram& UseCounter::cssHistogram() const | 796 EnumerationHistogram& UseCounter::cssHistogram() const |
| 797 { | 797 { |
| 798 DEFINE_STATIC_LOCAL(blink::EnumerationHistogram, histogram, ("WebCore.UseCou
nter_TEST.CSSProperties", maximumCSSSampleId())); | 798 DEFINE_STATIC_LOCAL(blink::EnumerationHistogram, histogram, ("WebCore.UseCou
nter_TEST.CSSProperties", kMaximumCSSSampleId)); |
| 799 DEFINE_STATIC_LOCAL(blink::EnumerationHistogram, svgHistogram, ("WebCore.Use
Counter_TEST.SVGImage.CSSProperties", maximumCSSSampleId())); | 799 DEFINE_STATIC_LOCAL(blink::EnumerationHistogram, svgHistogram, ("WebCore.Use
Counter_TEST.SVGImage.CSSProperties", kMaximumCSSSampleId)); |
| 800 | 800 |
| 801 return m_context == SVGImageContext ? svgHistogram : histogram; | 801 return m_context == SVGImageContext ? svgHistogram : histogram; |
| 802 } | 802 } |
| 803 | 803 |
| 804 /* | 804 /* |
| 805 * | 805 * |
| 806 * LEGACY metrics support - WebCore.FeatureObserver is to be superceded by WebCo
re.UseCounter | 806 * LEGACY metrics support - WebCore.FeatureObserver is to be superceded by WebCo
re.UseCounter |
| 807 * | 807 * |
| 808 */ | 808 */ |
| 809 | 809 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 for (size_t i = 0; i < NumberOfFeatures; ++i) { | 844 for (size_t i = 0; i < NumberOfFeatures; ++i) { |
| 845 if (m_featureBits.quickGet(i)) | 845 if (m_featureBits.quickGet(i)) |
| 846 featureHistogram.count(i); | 846 featureHistogram.count(i); |
| 847 } | 847 } |
| 848 // Clearing count bits is timing sensitive. | 848 // Clearing count bits is timing sensitive. |
| 849 m_featureBits.clearAll(); | 849 m_featureBits.clearAll(); |
| 850 | 850 |
| 851 // FIXME: Sometimes this function is called more than once per page. The fol
lowing | 851 // FIXME: Sometimes this function is called more than once per page. The fol
lowing |
| 852 // bool guards against incrementing the page count when there are no
CSS | 852 // bool guards against incrementing the page count when there are no
CSS |
| 853 // bits set. https://crbug.com/236262. | 853 // bits set. https://crbug.com/236262. |
| 854 DEFINE_STATIC_LOCAL(EnumerationHistogram, cssPropertiesHistogram, ("WebCore.
FeatureObserver.CSSProperties", maximumCSSSampleId())); | 854 DEFINE_STATIC_LOCAL(EnumerationHistogram, cssPropertiesHistogram, ("WebCore.
FeatureObserver.CSSProperties", kMaximumCSSSampleId)); |
| 855 bool needsPagesMeasuredUpdate = false; | 855 bool needsPagesMeasuredUpdate = false; |
| 856 for (size_t i = firstCSSProperty; i <= lastUnresolvedCSSProperty; ++i) { | 856 for (size_t i = firstCSSProperty; i <= lastUnresolvedCSSProperty; ++i) { |
| 857 if (m_CSSBits.quickGet(i)) { | 857 if (m_CSSBits.quickGet(i)) { |
| 858 int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(static_c
ast<CSSPropertyID>(i)); | 858 int cssSampleId = mapCSSPropertyIdToCSSSampleIdForHistogram(static_c
ast<CSSPropertyID>(i)); |
| 859 cssPropertiesHistogram.count(cssSampleId); | 859 cssPropertiesHistogram.count(cssSampleId); |
| 860 needsPagesMeasuredUpdate = true; | 860 needsPagesMeasuredUpdate = true; |
| 861 } | 861 } |
| 862 } | 862 } |
| 863 | 863 |
| 864 if (needsPagesMeasuredUpdate) | 864 if (needsPagesMeasuredUpdate) |
| 865 cssPropertiesHistogram.count(totalPagesMeasuredCSSSampleId()); | 865 cssPropertiesHistogram.count(totalPagesMeasuredCSSSampleId()); |
| 866 | 866 |
| 867 m_CSSBits.clearAll(); | 867 m_CSSBits.clearAll(); |
| 868 } | 868 } |
| 869 | 869 |
| 870 } // namespace blink | 870 } // namespace blink |
| OLD | NEW |