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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 655 } | 656 } |
| 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 host->useCounter().count(feature); |
|
foolip
2016/08/08 19:59:11
This ASSERT should still hold, right, or why was i
Pat Meenan
2016/08/09 19:06:32
UseCounter::count() is exactly this assert + the r
foolip
2016/08/11 08:03:44
Acknowledged.
| |
| 666 host->useCounter().recordMeasurement(feature); | |
| 667 } | 667 } |
| 668 | 668 |
| 669 void UseCounter::count(const Document& document, Feature feature) | 669 void UseCounter::count(const Document& document, Feature feature) |
| 670 { | 670 { |
| 671 count(document.frame(), feature); | 671 count(document.frame(), feature); |
| 672 } | 672 } |
| 673 | 673 |
| 674 bool UseCounter::isCounted(Document& document, Feature feature) | 674 bool UseCounter::isCounted(Document& document, Feature feature) |
| 675 { | 675 { |
| 676 Frame* frame = document.frame(); | 676 Frame* frame = document.frame(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 744 } | 744 } |
| 745 | 745 |
| 746 void UseCounter::count(CSSParserMode cssParserMode, CSSPropertyID feature) | 746 void UseCounter::count(CSSParserMode cssParserMode, CSSPropertyID feature) |
| 747 { | 747 { |
| 748 ASSERT(feature >= firstCSSProperty); | 748 ASSERT(feature >= firstCSSProperty); |
| 749 ASSERT(feature <= lastUnresolvedCSSProperty); | 749 ASSERT(feature <= lastUnresolvedCSSProperty); |
| 750 | 750 |
| 751 if (!isUseCounterEnabledForMode(cssParserMode) || m_muteCount) | 751 if (!isUseCounterEnabledForMode(cssParserMode) || m_muteCount) |
| 752 return; | 752 return; |
| 753 | 753 |
| 754 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"), "CSSFeatureUs ed", "feature", feature); | |
| 754 m_CSSFeatureBits.quickSet(feature); | 755 m_CSSFeatureBits.quickSet(feature); |
| 755 } | 756 } |
| 756 | 757 |
| 757 void UseCounter::count(Feature feature) | 758 void UseCounter::count(Feature feature) |
| 758 { | 759 { |
| 759 ASSERT(Deprecation::deprecationMessage(feature).isEmpty()); | 760 ASSERT(Deprecation::deprecationMessage(feature).isEmpty()); |
| 760 recordMeasurement(feature); | 761 recordMeasurement(feature); |
| 761 } | 762 } |
| 762 | 763 |
| 763 UseCounter* UseCounter::getFrom(const Document* document) | 764 UseCounter* UseCounter::getFrom(const Document* document) |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 776 | 777 |
| 777 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) | 778 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) |
| 778 { | 779 { |
| 779 // FIXME: We may want to handle stylesheets that have multiple owners | 780 // FIXME: We may want to handle stylesheets that have multiple owners |
| 780 // https://crbug.com/242125 | 781 // https://crbug.com/242125 |
| 781 if (sheetContents && sheetContents->hasSingleOwnerNode()) | 782 if (sheetContents && sheetContents->hasSingleOwnerNode()) |
| 782 return getFrom(sheetContents->singleOwnerDocument()); | 783 return getFrom(sheetContents->singleOwnerDocument()); |
| 783 return 0; | 784 return 0; |
| 784 } | 785 } |
| 785 | 786 |
| 787 void UseCounter::recordMeasurement(Feature feature) | |
| 788 { | |
| 789 if (!m_muteCount) { | |
|
foolip
2016/08/08 19:59:11
Can you do an early return instead, and put this s
Pat Meenan
2016/08/09 19:06:32
Done.
| |
| 790 m_countBits.recordMeasurement(feature); | |
| 791 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"), "FeatureU sed", "feature", feature); | |
| 792 } | |
| 793 } | |
| 794 | |
| 786 } // namespace blink | 795 } // namespace blink |
| OLD | NEW |