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 18 matching lines...) Expand all Loading... | |
| 29 #include "core/css/StyleSheetContents.h" | 29 #include "core/css/StyleSheetContents.h" |
| 30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 31 #include "core/dom/ExecutionContext.h" | 31 #include "core/dom/ExecutionContext.h" |
| 32 #include "core/frame/Deprecation.h" | 32 #include "core/frame/Deprecation.h" |
| 33 #include "core/frame/FrameConsole.h" | 33 #include "core/frame/FrameConsole.h" |
| 34 #include "core/frame/FrameHost.h" | 34 #include "core/frame/FrameHost.h" |
| 35 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
| 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 | 40 |
| 40 namespace blink { | 41 namespace blink { |
| 41 | 42 |
| 42 static int totalPagesMeasuredCSSSampleId() { return 1; } | 43 static int totalPagesMeasuredCSSSampleId() { return 1; } |
| 43 | 44 |
| 44 int UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(int id) | 45 int UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(int id) |
| 45 { | 46 { |
| 46 CSSPropertyID cssPropertyID = static_cast<CSSPropertyID>(id); | 47 CSSPropertyID cssPropertyID = static_cast<CSSPropertyID>(id); |
| 47 | 48 |
| 48 switch (cssPropertyID) { | 49 switch (cssPropertyID) { |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 656 | 657 |
| 657 void UseCounter::count(const Frame* frame, Feature feature) | 658 void UseCounter::count(const Frame* frame, Feature feature) |
| 658 { | 659 { |
| 659 if (!frame) | 660 if (!frame) |
| 660 return; | 661 return; |
| 661 FrameHost* host = frame->host(); | 662 FrameHost* host = frame->host(); |
| 662 if (!host) | 663 if (!host) |
| 663 return; | 664 return; |
| 664 | 665 |
| 665 ASSERT(Deprecation::deprecationMessage(feature).isEmpty()); | 666 ASSERT(Deprecation::deprecationMessage(feature).isEmpty()); |
| 667 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"), "FeatureUsed" , "feature", feature); | |
|
Rick Byers
2016/08/03 01:08:32
I believe this will double count (Calls into the o
Pat Meenan
2016/08/03 13:20:27
It doesn't because it is calling directly into rec
| |
| 666 host->useCounter().recordMeasurement(feature); | 668 host->useCounter().recordMeasurement(feature); |
| 667 } | 669 } |
| 668 | 670 |
| 669 void UseCounter::count(const Document& document, Feature feature) | 671 void UseCounter::count(const Document& document, Feature feature) |
| 670 { | 672 { |
| 671 count(document.frame(), feature); | 673 count(document.frame(), feature); |
| 672 } | 674 } |
| 673 | 675 |
| 674 bool UseCounter::isCounted(Document& document, Feature feature) | 676 bool UseCounter::isCounted(Document& document, Feature feature) |
| 675 { | 677 { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 744 } | 746 } |
| 745 | 747 |
| 746 void UseCounter::count(CSSParserMode cssParserMode, CSSPropertyID feature) | 748 void UseCounter::count(CSSParserMode cssParserMode, CSSPropertyID feature) |
| 747 { | 749 { |
| 748 ASSERT(feature >= firstCSSProperty); | 750 ASSERT(feature >= firstCSSProperty); |
| 749 ASSERT(feature <= lastUnresolvedCSSProperty); | 751 ASSERT(feature <= lastUnresolvedCSSProperty); |
| 750 | 752 |
| 751 if (!isUseCounterEnabledForMode(cssParserMode) || m_muteCount) | 753 if (!isUseCounterEnabledForMode(cssParserMode) || m_muteCount) |
| 752 return; | 754 return; |
| 753 | 755 |
| 756 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"), "FeatureUsed" , "feature", feature); | |
|
Rick Byers
2016/08/03 01:08:32
This 'feature' has a different range/semantics tha
Pat Meenan
2016/08/03 13:20:27
Doh. Good catch, thanks. Done.
| |
| 754 m_CSSFeatureBits.quickSet(feature); | 757 m_CSSFeatureBits.quickSet(feature); |
| 755 } | 758 } |
| 756 | 759 |
| 757 void UseCounter::count(Feature feature) | 760 void UseCounter::count(Feature feature) |
| 758 { | 761 { |
| 759 ASSERT(Deprecation::deprecationMessage(feature).isEmpty()); | 762 ASSERT(Deprecation::deprecationMessage(feature).isEmpty()); |
| 763 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"), "FeatureUsed" , "feature", feature); | |
|
Rick Byers
2016/08/03 01:08:32
There are a few features which are used a LOT, do
Pat Meenan
2016/08/03 13:20:27
Is there value in knowing how often features were
| |
| 760 recordMeasurement(feature); | 764 recordMeasurement(feature); |
| 761 } | 765 } |
| 762 | 766 |
| 763 UseCounter* UseCounter::getFrom(const Document* document) | 767 UseCounter* UseCounter::getFrom(const Document* document) |
| 764 { | 768 { |
| 765 if (document && document->frameHost()) | 769 if (document && document->frameHost()) |
| 766 return &document->frameHost()->useCounter(); | 770 return &document->frameHost()->useCounter(); |
| 767 return 0; | 771 return 0; |
| 768 } | 772 } |
| 769 | 773 |
| 770 UseCounter* UseCounter::getFrom(const CSSStyleSheet* sheet) | 774 UseCounter* UseCounter::getFrom(const CSSStyleSheet* sheet) |
| 771 { | 775 { |
| 772 if (sheet) | 776 if (sheet) |
| 773 return getFrom(sheet->contents()); | 777 return getFrom(sheet->contents()); |
| 774 return 0; | 778 return 0; |
| 775 } | 779 } |
| 776 | 780 |
| 777 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) | 781 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) |
| 778 { | 782 { |
| 779 // FIXME: We may want to handle stylesheets that have multiple owners | 783 // FIXME: We may want to handle stylesheets that have multiple owners |
| 780 // https://crbug.com/242125 | 784 // https://crbug.com/242125 |
| 781 if (sheetContents && sheetContents->hasSingleOwnerNode()) | 785 if (sheetContents && sheetContents->hasSingleOwnerNode()) |
| 782 return getFrom(sheetContents->singleOwnerDocument()); | 786 return getFrom(sheetContents->singleOwnerDocument()); |
| 783 return 0; | 787 return 0; |
| 784 } | 788 } |
| 785 | 789 |
| 786 } // namespace blink | 790 } // namespace blink |
| OLD | NEW |