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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelineTreeView.js

Issue 2872853002: DevTools: Support grouping by Product in performance tree views. (Closed)
Patch Set: addressing comments Created 3 years, 7 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @unrestricted 6 * @unrestricted
7 * @implements {UI.Searchable} 7 * @implements {UI.Searchable}
8 */ 8 */
9 Timeline.TimelineTreeView = class extends UI.VBox { 9 Timeline.TimelineTreeView = class extends UI.VBox {
10 constructor() { 10 constructor() {
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 * @unrestricted 624 * @unrestricted
625 */ 625 */
626 Timeline.AggregatedTimelineTreeView = class extends Timeline.TimelineTreeView { 626 Timeline.AggregatedTimelineTreeView = class extends Timeline.TimelineTreeView {
627 /** 627 /**
628 * @param {!Array<!TimelineModel.TimelineModelFilter>} filters 628 * @param {!Array<!TimelineModel.TimelineModelFilter>} filters
629 */ 629 */
630 constructor(filters) { 630 constructor(filters) {
631 super(); 631 super();
632 this._groupBySetting = 632 this._groupBySetting =
633 Common.settings.createSetting('timelineTreeGroupBy', Timeline.Aggregated TimelineTreeView.GroupBy.None); 633 Common.settings.createSetting('timelineTreeGroupBy', Timeline.Aggregated TimelineTreeView.GroupBy.None);
634 this._groupByCombobox = new UI.ToolbarComboBox(this._onGroupByChanged.bind(t his)); 634 this._groupBySetting.addChangeListener(this.refreshTree.bind(this));
635 this.init(filters); 635 this.init(filters);
636 this._stackView = new Timeline.TimelineStackView(this); 636 this._stackView = new Timeline.TimelineStackView(this);
637 this._stackView.addEventListener( 637 this._stackView.addEventListener(
638 Timeline.TimelineStackView.Events.SelectionChanged, this._onStackViewSel ectionChanged, this); 638 Timeline.TimelineStackView.Events.SelectionChanged, this._onStackViewSel ectionChanged, this);
639 if (!Runtime.experiments.isEnabled('timelineColorByProduct'))
640 return;
641 /** @type {!Map<string, string>} */
642 this._productByURLCache = new Map();
643 ProductRegistry.instance().then(registry => {
644 this._productRegistry = registry;
645 this.refreshTree();
646 });
639 } 647 }
640 648
641 /** 649 /**
642 * @override
643 */
644 wasShown() {
645 var groupById = this._groupBySetting.get();
646 var option = this._groupByCombobox.options().find(option => option.value === groupById);
647 if (option)
648 this._groupByCombobox.select(option);
649 }
650
651 /**
652 * @override 650 * @override
653 * @param {!Timeline.TimelineSelection} selection 651 * @param {!Timeline.TimelineSelection} selection
654 */ 652 */
655 updateContents(selection) { 653 updateContents(selection) {
656 this._updateExtensionResolver(); 654 this._updateExtensionResolver();
657 super.updateContents(selection); 655 super.updateContents(selection);
658 var rootNode = this._dataGrid.rootNode(); 656 var rootNode = this._dataGrid.rootNode();
659 if (rootNode.children.length) 657 if (rootNode.children.length)
660 rootNode.children[0].revealAndSelect(); 658 rootNode.children[0].revealAndSelect();
661 } 659 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 var name = node.event.name === TimelineModel.TimelineModel.RecordType.JS Frame ? 695 var name = node.event.name === TimelineModel.TimelineModel.RecordType.JS Frame ?
698 Common.UIString('JavaScript') : 696 Common.UIString('JavaScript') :
699 Timeline.TimelineUIUtils.eventTitle(node.event); 697 Timeline.TimelineUIUtils.eventTitle(node.event);
700 return { 698 return {
701 name: name, 699 name: name,
702 color: node.event.name === TimelineModel.TimelineModel.RecordType.JSFr ame ? 700 color: node.event.name === TimelineModel.TimelineModel.RecordType.JSFr ame ?
703 Timeline.TimelineUIUtils.eventStyle(node.event).category.color : 701 Timeline.TimelineUIUtils.eventStyle(node.event).category.color :
704 color 702 color
705 }; 703 };
706 704
705 case Timeline.AggregatedTimelineTreeView.GroupBy.Product:
706 var name = node.event ? this._productByEvent(node.event) : '';
707 return {name: name || Common.UIString('unattributed'), color: Timeline.T imelineUIUtils.colorForId(name)};
708
707 case Timeline.AggregatedTimelineTreeView.GroupBy.URL: 709 case Timeline.AggregatedTimelineTreeView.GroupBy.URL:
708 break; 710 break;
711
709 case Timeline.AggregatedTimelineTreeView.GroupBy.Frame: 712 case Timeline.AggregatedTimelineTreeView.GroupBy.Frame:
710 var frame = this._model.timelineModel().pageFrameById(node.id); 713 var frame = this._model.timelineModel().pageFrameById(node.id);
711 var frameName = frame ? Timeline.TimelineUIUtils.displayNameForFrame(fra me, 80) : Common.UIString('Page'); 714 var frameName = frame ? Timeline.TimelineUIUtils.displayNameForFrame(fra me, 80) : Common.UIString('Page');
712 return {name: frameName, color: color}; 715 return {name: frameName, color: color};
713 716
714 default: 717 default:
715 console.assert(false, 'Unexpected aggregation type'); 718 console.assert(false, 'Unexpected aggregation type');
716 } 719 }
717 return {name: node.id || Common.UIString('unattributed'), color: color}; 720 return {name: node.id || Common.UIString('unattributed'), color: color};
718 } 721 }
719 722
720 /** 723 /**
721 * @override 724 * @override
722 * @param {!UI.Toolbar} toolbar 725 * @param {!UI.Toolbar} toolbar
723 */ 726 */
724 populateToolbar(toolbar) { 727 populateToolbar(toolbar) {
725 super.populateToolbar(toolbar); 728 super.populateToolbar(toolbar);
726 /** 729 var groupBy = Timeline.AggregatedTimelineTreeView.GroupBy;
727 * @param {string} name 730 var options = [
728 * @param {string} id 731 {label: Common.UIString('No Grouping'), value: groupBy.None},
729 * @this {Timeline.TimelineTreeView} 732 {label: Common.UIString('Group by Activity'), value: groupBy.EventName},
730 */ 733 {label: Common.UIString('Group by Category'), value: groupBy.Category},
731 function addGroupingOption(name, id) { 734 {label: Common.UIString('Group by Domain'), value: groupBy.Domain},
732 var option = this._groupByCombobox.createOption(name, '', id); 735 {label: Common.UIString('Group by Subdomain'), value: groupBy.Subdomain},
733 this._groupByCombobox.addOption(option); 736 {label: Common.UIString('Group by Product'), value: groupBy.Product},
734 if (id === this._groupBySetting.get()) 737 {label: Common.UIString('Group by URL'), value: groupBy.URL},
735 this._groupByCombobox.select(option); 738 {label: Common.UIString('Group by Frame'), value: groupBy.Frame},
736 } 739 ];
737 const groupBy = Timeline.AggregatedTimelineTreeView.GroupBy; 740 if (!Runtime.experiments.isEnabled('timelineColorByProduct'))
738 addGroupingOption.call(this, Common.UIString('No Grouping'), groupBy.None); 741 options = options.filter(option => option.value !== groupBy.Product);
739 addGroupingOption.call(this, Common.UIString('Group by Activity'), groupBy.E ventName); 742 toolbar.appendToolbarItem(new UI.ToolbarSettingComboBox(options, this._group BySetting));
740 addGroupingOption.call(this, Common.UIString('Group by Category'), groupBy.C ategory);
741 addGroupingOption.call(this, Common.UIString('Group by Domain'), groupBy.Dom ain);
742 addGroupingOption.call(this, Common.UIString('Group by Subdomain'), groupBy. Subdomain);
743 addGroupingOption.call(this, Common.UIString('Group by URL'), groupBy.URL);
744 addGroupingOption.call(this, Common.UIString('Group by Frame'), groupBy.Fram e);
745 toolbar.appendToolbarItem(this._groupByCombobox);
746 toolbar.appendSpacer(); 743 toolbar.appendSpacer();
747 toolbar.appendToolbarItem(this._splitWidget.createShowHideSidebarButton(Comm on.UIString('heaviest stack'))); 744 toolbar.appendToolbarItem(this._splitWidget.createShowHideSidebarButton(Comm on.UIString('heaviest stack')));
748 } 745 }
749 746
750 /** 747 /**
751 * @param {!TimelineModel.TimelineProfileTree.Node} treeNode 748 * @param {!TimelineModel.TimelineProfileTree.Node} treeNode
752 * @return {!Array<!TimelineModel.TimelineProfileTree.Node>} 749 * @return {!Array<!TimelineModel.TimelineProfileTree.Node>}
753 */ 750 */
754 _buildHeaviestStack(treeNode) { 751 _buildHeaviestStack(treeNode) {
755 console.assert(!!treeNode.parent, 'Attempt to build stack for tree root'); 752 console.assert(!!treeNode.parent, 'Attempt to build stack for tree root');
(...skipping 11 matching lines...) Expand all
767 } 764 }
768 765
769 /** 766 /**
770 * @override 767 * @override
771 * @return {boolean} 768 * @return {boolean}
772 */ 769 */
773 _exposePercentages() { 770 _exposePercentages() {
774 return true; 771 return true;
775 } 772 }
776 773
777 _onGroupByChanged() {
778 this._groupBySetting.set(this._groupByCombobox.selectedOption().value);
779 this.refreshTree();
780 }
781
782 _onStackViewSelectionChanged() { 774 _onStackViewSelectionChanged() {
783 var treeNode = this._stackView.selectedTreeNode(); 775 var treeNode = this._stackView.selectedTreeNode();
784 if (treeNode) 776 if (treeNode)
785 this.selectProfileNode(treeNode, true); 777 this.selectProfileNode(treeNode, true);
786 } 778 }
787 779
788 /** 780 /**
789 * @override 781 * @override
790 * @param {!TimelineModel.TimelineProfileTree.Node} node 782 * @param {!TimelineModel.TimelineProfileTree.Node} node
791 * @return {boolean} 783 * @return {boolean}
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 case Timeline.AggregatedTimelineTreeView.GroupBy.None: 830 case Timeline.AggregatedTimelineTreeView.GroupBy.None:
839 return null; 831 return null;
840 case Timeline.AggregatedTimelineTreeView.GroupBy.EventName: 832 case Timeline.AggregatedTimelineTreeView.GroupBy.EventName:
841 return event => Timeline.TimelineUIUtils.eventStyle(event).title; 833 return event => Timeline.TimelineUIUtils.eventStyle(event).title;
842 case Timeline.AggregatedTimelineTreeView.GroupBy.Category: 834 case Timeline.AggregatedTimelineTreeView.GroupBy.Category:
843 return event => Timeline.TimelineUIUtils.eventStyle(event).category.name ; 835 return event => Timeline.TimelineUIUtils.eventStyle(event).category.name ;
844 case Timeline.AggregatedTimelineTreeView.GroupBy.Subdomain: 836 case Timeline.AggregatedTimelineTreeView.GroupBy.Subdomain:
845 return groupByDomain.bind(null, false); 837 return groupByDomain.bind(null, false);
846 case Timeline.AggregatedTimelineTreeView.GroupBy.Domain: 838 case Timeline.AggregatedTimelineTreeView.GroupBy.Domain:
847 return groupByDomain.bind(null, true); 839 return groupByDomain.bind(null, true);
840 case Timeline.AggregatedTimelineTreeView.GroupBy.Product:
841 return this._productByEvent.bind(this);
848 case Timeline.AggregatedTimelineTreeView.GroupBy.URL: 842 case Timeline.AggregatedTimelineTreeView.GroupBy.URL:
849 return groupByURL; 843 return groupByURL;
850 case Timeline.AggregatedTimelineTreeView.GroupBy.Frame: 844 case Timeline.AggregatedTimelineTreeView.GroupBy.Frame:
851 return event => TimelineModel.TimelineData.forEvent(event).frameId; 845 return event => TimelineModel.TimelineData.forEvent(event).frameId;
852 default: 846 default:
853 console.assert(false, `Unexpected aggregation setting: ${groupBy}`); 847 console.assert(false, `Unexpected aggregation setting: ${groupBy}`);
854 return null; 848 return null;
855 } 849 }
856 } 850 }
857 851
858 /** 852 /**
853 * @param {!SDK.TracingModel.Event} event
854 * @return {string}
855 */
856 _productByEvent(event) {
857 if (!this._productRegistry)
858 return '';
859 var url = TimelineModel.TimelineProfileTree.eventURL(event) || '';
860 var name = this._productByURLCache.get(url);
861 if (name)
862 return name;
863 var parsedURL = url.asParsedURL();
864 name = parsedURL && this._productRegistry.nameForUrl(parsedURL) || '';
865 this._productByURLCache.set(url, name);
866 return name;
867 }
868
869 /**
859 * @override 870 * @override
860 * @param {!UI.ContextMenu} contextMenu 871 * @param {!UI.ContextMenu} contextMenu
861 * @param {!TimelineModel.TimelineProfileTree.Node} node 872 * @param {!TimelineModel.TimelineProfileTree.Node} node
862 */ 873 */
863 _appendContextMenuItems(contextMenu, node) { 874 _appendContextMenuItems(contextMenu, node) {
864 if (this._groupBySetting.get() !== Timeline.AggregatedTimelineTreeView.Group By.Frame) 875 if (this._groupBySetting.get() !== Timeline.AggregatedTimelineTreeView.Group By.Frame)
865 return; 876 return;
866 if (!node.isGroupNode()) 877 if (!node.isGroupNode())
867 return; 878 return;
868 var frame = this._model.timelineModel().pageFrameById(node.id); 879 var frame = this._model.timelineModel().pageFrameById(node.id);
(...skipping 24 matching lines...) Expand all
893 904
894 /** 905 /**
895 * @enum {string} 906 * @enum {string}
896 */ 907 */
897 Timeline.AggregatedTimelineTreeView.GroupBy = { 908 Timeline.AggregatedTimelineTreeView.GroupBy = {
898 None: 'None', 909 None: 'None',
899 EventName: 'EventName', 910 EventName: 'EventName',
900 Category: 'Category', 911 Category: 'Category',
901 Domain: 'Domain', 912 Domain: 'Domain',
902 Subdomain: 'Subdomain', 913 Subdomain: 'Subdomain',
914 Product: 'Product',
903 URL: 'URL', 915 URL: 'URL',
904 Frame: 'Frame' 916 Frame: 'Frame'
905 }; 917 };
906 918
907 /** 919 /**
908 * @unrestricted 920 * @unrestricted
909 */ 921 */
910 Timeline.CallTreeTimelineTreeView = class extends Timeline.AggregatedTimelineTre eView { 922 Timeline.CallTreeTimelineTreeView = class extends Timeline.AggregatedTimelineTre eView {
911 /** 923 /**
912 * @param {!Array<!TimelineModel.TimelineModelFilter>} filters 924 * @param {!Array<!TimelineModel.TimelineModelFilter>} filters
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 1008
997 _onSelectionChanged() { 1009 _onSelectionChanged() {
998 this.dispatchEventToListeners(Timeline.TimelineStackView.Events.SelectionCha nged); 1010 this.dispatchEventToListeners(Timeline.TimelineStackView.Events.SelectionCha nged);
999 } 1011 }
1000 }; 1012 };
1001 1013
1002 /** @enum {symbol} */ 1014 /** @enum {symbol} */
1003 Timeline.TimelineStackView.Events = { 1015 Timeline.TimelineStackView.Events = {
1004 SelectionChanged: Symbol('SelectionChanged') 1016 SelectionChanged: Symbol('SelectionChanged')
1005 }; 1017 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698