Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: third_party/WebKit/Source/core/frame/UseCounter.cpp

Issue 2203913002: Added trace events for blink feature usage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Only trace first use of each feature Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 void UseCounter::muteForInspector() 593 void UseCounter::muteForInspector()
593 { 594 {
594 m_muteCount++; 595 m_muteCount++;
595 } 596 }
596 597
597 void UseCounter::unmuteForInspector() 598 void UseCounter::unmuteForInspector()
598 { 599 {
599 m_muteCount--; 600 m_muteCount--;
600 } 601 }
601 602
603 void UseCounter::recordMeasurement(Feature feature)
604 {
605 if (m_muteCount)
606 return;
607
608 if (!m_countBits.hasRecordedMeasurement(feature)) {
609 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"), "FeatureF irstUsed", "feature", feature);
610 }
611 m_countBits.recordMeasurement(feature);
612 }
613
602 UseCounter::UseCounter() 614 UseCounter::UseCounter()
603 : m_muteCount(0) 615 : m_muteCount(0)
604 { 616 {
605 m_CSSFeatureBits.ensureSize(lastUnresolvedCSSProperty + 1); 617 m_CSSFeatureBits.ensureSize(lastUnresolvedCSSProperty + 1);
606 m_CSSFeatureBits.clearAll(); 618 m_CSSFeatureBits.clearAll();
607 } 619 }
608 620
609 UseCounter::~UseCounter() 621 UseCounter::~UseCounter()
610 { 622 {
611 // We always log PageDestruction so that we have a scale for the rest of the features. 623 // We always log PageDestruction so that we have a scale for the rest of the features.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 } 667 }
656 668
657 void UseCounter::count(const Frame* frame, Feature feature) 669 void UseCounter::count(const Frame* frame, Feature feature)
658 { 670 {
659 if (!frame) 671 if (!frame)
660 return; 672 return;
661 FrameHost* host = frame->host(); 673 FrameHost* host = frame->host();
662 if (!host) 674 if (!host)
663 return; 675 return;
664 676
665 ASSERT(Deprecation::deprecationMessage(feature).isEmpty()); 677 host->useCounter().count(feature);
666 host->useCounter().recordMeasurement(feature);
667 } 678 }
668 679
669 void UseCounter::count(const Document& document, Feature feature) 680 void UseCounter::count(const Document& document, Feature feature)
670 { 681 {
671 count(document.frame(), feature); 682 count(document.frame(), feature);
672 } 683 }
673 684
674 bool UseCounter::isCounted(Document& document, Feature feature) 685 bool UseCounter::isCounted(Document& document, Feature feature)
675 { 686 {
676 Frame* frame = document.frame(); 687 Frame* frame = document.frame();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 } 755 }
745 756
746 void UseCounter::count(CSSParserMode cssParserMode, CSSPropertyID feature) 757 void UseCounter::count(CSSParserMode cssParserMode, CSSPropertyID feature)
747 { 758 {
748 ASSERT(feature >= firstCSSProperty); 759 ASSERT(feature >= firstCSSProperty);
749 ASSERT(feature <= lastUnresolvedCSSProperty); 760 ASSERT(feature <= lastUnresolvedCSSProperty);
750 761
751 if (!isUseCounterEnabledForMode(cssParserMode) || m_muteCount) 762 if (!isUseCounterEnabledForMode(cssParserMode) || m_muteCount)
752 return; 763 return;
753 764
765 if (!m_CSSFeatureBits.quickGet(feature)) {
766 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"), "CSSFeatu reFirstUsed", "feature", feature);
767 }
754 m_CSSFeatureBits.quickSet(feature); 768 m_CSSFeatureBits.quickSet(feature);
755 } 769 }
756 770
757 void UseCounter::count(Feature feature) 771 void UseCounter::count(Feature feature)
758 { 772 {
759 ASSERT(Deprecation::deprecationMessage(feature).isEmpty()); 773 ASSERT(Deprecation::deprecationMessage(feature).isEmpty());
760 recordMeasurement(feature); 774 recordMeasurement(feature);
761 } 775 }
762 776
763 UseCounter* UseCounter::getFrom(const Document* document) 777 UseCounter* UseCounter::getFrom(const Document* document)
(...skipping 13 matching lines...) Expand all
777 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) 791 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents)
778 { 792 {
779 // FIXME: We may want to handle stylesheets that have multiple owners 793 // FIXME: We may want to handle stylesheets that have multiple owners
780 // https://crbug.com/242125 794 // https://crbug.com/242125
781 if (sheetContents && sheetContents->hasSingleOwnerNode()) 795 if (sheetContents && sheetContents->hasSingleOwnerNode())
782 return getFrom(sheetContents->singleOwnerDocument()); 796 return getFrom(sheetContents->singleOwnerDocument());
783 return 0; 797 return 0;
784 } 798 }
785 799
786 } // namespace blink 800 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698