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

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: Fixed CSS name, Eliminated duplicate code 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 | « no previous file | 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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
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
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());
761 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("blink.feature_usage"), "FeatureUsed" , "feature", feature);
foolip 2016/08/03 14:53:27 This relates to https://codereview.chromium.org/22
Pat Meenan 2016/08/03 18:43:25 Done.
760 recordMeasurement(feature); 762 recordMeasurement(feature);
761 } 763 }
762 764
763 UseCounter* UseCounter::getFrom(const Document* document) 765 UseCounter* UseCounter::getFrom(const Document* document)
764 { 766 {
765 if (document && document->frameHost()) 767 if (document && document->frameHost())
766 return &document->frameHost()->useCounter(); 768 return &document->frameHost()->useCounter();
767 return 0; 769 return 0;
768 } 770 }
769 771
770 UseCounter* UseCounter::getFrom(const CSSStyleSheet* sheet) 772 UseCounter* UseCounter::getFrom(const CSSStyleSheet* sheet)
771 { 773 {
772 if (sheet) 774 if (sheet)
773 return getFrom(sheet->contents()); 775 return getFrom(sheet->contents());
774 return 0; 776 return 0;
775 } 777 }
776 778
777 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents) 779 UseCounter* UseCounter::getFrom(const StyleSheetContents* sheetContents)
778 { 780 {
779 // FIXME: We may want to handle stylesheets that have multiple owners 781 // FIXME: We may want to handle stylesheets that have multiple owners
780 // https://crbug.com/242125 782 // https://crbug.com/242125
781 if (sheetContents && sheetContents->hasSingleOwnerNode()) 783 if (sheetContents && sheetContents->hasSingleOwnerNode())
782 return getFrom(sheetContents->singleOwnerDocument()); 784 return getFrom(sheetContents->singleOwnerDocument());
783 return 0; 785 return 0;
784 } 786 }
785 787
786 } // namespace blink 788 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698