| OLD | NEW |
| 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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 if (columnId === 'activity') | 506 if (columnId === 'activity') |
| 507 return this._createNameCell(columnId); | 507 return this._createNameCell(columnId); |
| 508 return this._createValueCell(columnId) || super.createCell(columnId); | 508 return this._createValueCell(columnId) || super.createCell(columnId); |
| 509 } | 509 } |
| 510 | 510 |
| 511 /** | 511 /** |
| 512 * @param {string} columnId | 512 * @param {string} columnId |
| 513 * @return {!Element} | 513 * @return {!Element} |
| 514 */ | 514 */ |
| 515 _createNameCell(columnId) { | 515 _createNameCell(columnId) { |
| 516 const cell = this.createTD(columnId); | 516 var cell = this.createTD(columnId); |
| 517 const container = cell.createChild('div', 'name-container'); | 517 var container = cell.createChild('div', 'name-container'); |
| 518 const icon = container.createChild('div', 'activity-icon'); | 518 var iconContainer = container.createChild('div', 'activity-icon-container'); |
| 519 const name = container.createChild('div', 'activity-name'); | 519 var icon = iconContainer.createChild('div', 'activity-icon'); |
| 520 const event = this._profileNode.event; | 520 var name = container.createChild('div', 'activity-name'); |
| 521 var event = this._profileNode.event; |
| 521 if (this._profileNode.isGroupNode()) { | 522 if (this._profileNode.isGroupNode()) { |
| 522 const treeView = /** @type {!Timeline.AggregatedTimelineTreeView} */ (this
._treeView); | 523 var treeView = /** @type {!Timeline.AggregatedTimelineTreeView} */ (this._
treeView); |
| 523 const info = treeView._displayInfoForGroupNode(this._profileNode); | 524 var info = treeView._displayInfoForGroupNode(this._profileNode); |
| 524 name.textContent = info.name; | 525 name.textContent = info.name; |
| 525 icon.style.backgroundColor = info.color; | 526 icon.style.backgroundColor = info.color; |
| 527 if (info.icon) |
| 528 iconContainer.insertBefore(info.icon, icon); |
| 526 } else if (event) { | 529 } else if (event) { |
| 527 const data = event.args['data']; | 530 var data = event.args['data']; |
| 528 const deoptReason = data && data['deoptReason']; | 531 var deoptReason = data && data['deoptReason']; |
| 529 if (deoptReason) | 532 if (deoptReason) |
| 530 container.createChild('div', 'activity-warning').title = Common.UIString
('Not optimized: %s', deoptReason); | 533 container.createChild('div', 'activity-warning').title = Common.UIString
('Not optimized: %s', deoptReason); |
| 531 | 534 |
| 532 name.textContent = Timeline.TimelineUIUtils.eventTitle(event); | 535 name.textContent = Timeline.TimelineUIUtils.eventTitle(event); |
| 533 const link = this._treeView._linkifyLocation(event); | 536 var link = this._treeView._linkifyLocation(event); |
| 534 if (link) | 537 if (link) |
| 535 container.createChild('div', 'activity-link').appendChild(link); | 538 container.createChild('div', 'activity-link').appendChild(link); |
| 536 icon.style.backgroundColor = Timeline.TimelineUIUtils.eventColor(event); | 539 icon.style.backgroundColor = Timeline.TimelineUIUtils.eventColor(event); |
| 537 } | 540 } |
| 538 return cell; | 541 return cell; |
| 539 } | 542 } |
| 540 | 543 |
| 541 /** | 544 /** |
| 542 * @param {string} columnId | 545 * @param {string} columnId |
| 543 * @return {?Element} | 546 * @return {?Element} |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 */ | 632 */ |
| 630 constructor(filters) { | 633 constructor(filters) { |
| 631 super(); | 634 super(); |
| 632 this._groupBySetting = | 635 this._groupBySetting = |
| 633 Common.settings.createSetting('timelineTreeGroupBy', Timeline.Aggregated
TimelineTreeView.GroupBy.None); | 636 Common.settings.createSetting('timelineTreeGroupBy', Timeline.Aggregated
TimelineTreeView.GroupBy.None); |
| 634 this._groupBySetting.addChangeListener(this.refreshTree.bind(this)); | 637 this._groupBySetting.addChangeListener(this.refreshTree.bind(this)); |
| 635 this.init(filters); | 638 this.init(filters); |
| 636 this._stackView = new Timeline.TimelineStackView(this); | 639 this._stackView = new Timeline.TimelineStackView(this); |
| 637 this._stackView.addEventListener( | 640 this._stackView.addEventListener( |
| 638 Timeline.TimelineStackView.Events.SelectionChanged, this._onStackViewSel
ectionChanged, this); | 641 Timeline.TimelineStackView.Events.SelectionChanged, this._onStackViewSel
ectionChanged, this); |
| 642 this._badgePool = new ProductRegistry.BadgePool(true); |
| 639 /** @type {!Map<string, string>} */ | 643 /** @type {!Map<string, string>} */ |
| 640 this._productByURLCache = new Map(); | 644 this._productByURLCache = new Map(); |
| 645 /** @type {!Map<string, string>} */ |
| 646 this._colorByURLCache = new Map(); |
| 641 ProductRegistry.instance().then(registry => { | 647 ProductRegistry.instance().then(registry => { |
| 642 this._productRegistry = registry; | 648 this._productRegistry = registry; |
| 643 this.refreshTree(); | 649 this.refreshTree(); |
| 644 }); | 650 }); |
| 645 } | 651 } |
| 646 | 652 |
| 647 /** | 653 /** |
| 648 * @override | 654 * @override |
| 655 * @param {?Timeline.PerformanceModel} model |
| 656 */ |
| 657 setModel(model) { |
| 658 this._badgePool.reset(); |
| 659 super.setModel(model); |
| 660 } |
| 661 |
| 662 /** |
| 663 * @override |
| 649 * @param {!Timeline.TimelineSelection} selection | 664 * @param {!Timeline.TimelineSelection} selection |
| 650 */ | 665 */ |
| 651 updateContents(selection) { | 666 updateContents(selection) { |
| 652 this._updateExtensionResolver(); | 667 this._updateExtensionResolver(); |
| 653 super.updateContents(selection); | 668 super.updateContents(selection); |
| 654 var rootNode = this._dataGrid.rootNode(); | 669 var rootNode = this._dataGrid.rootNode(); |
| 655 if (rootNode.children.length) | 670 if (rootNode.children.length) |
| 656 rootNode.children[0].revealAndSelect(); | 671 rootNode.children[0].revealAndSelect(); |
| 657 } | 672 } |
| 658 | 673 |
| 659 _updateExtensionResolver() { | 674 _updateExtensionResolver() { |
| 660 this._executionContextNamesByOrigin = new Map(); | 675 this._executionContextNamesByOrigin = new Map(); |
| 661 for (var runtimeModel of SDK.targetManager.models(SDK.RuntimeModel)) { | 676 for (var runtimeModel of SDK.targetManager.models(SDK.RuntimeModel)) { |
| 662 for (var context of runtimeModel.executionContexts()) | 677 for (var context of runtimeModel.executionContexts()) |
| 663 this._executionContextNamesByOrigin.set(context.origin, context.name); | 678 this._executionContextNamesByOrigin.set(context.origin, context.name); |
| 664 } | 679 } |
| 665 } | 680 } |
| 666 | 681 |
| 667 /** | 682 /** |
| 683 * @param {string} name |
| 684 * @return {string} |
| 685 * @this {Timeline.AggregatedTimelineTreeView} |
| 686 */ |
| 687 _beautifyDomainName(name) { |
| 688 if (Timeline.AggregatedTimelineTreeView._isExtensionInternalURL(name)) |
| 689 name = Common.UIString('[Chrome extensions overhead]'); |
| 690 else if (Timeline.AggregatedTimelineTreeView._isV8NativeURL(name)) |
| 691 name = Common.UIString('[V8 Runtime]'); |
| 692 else if (name.startsWith('chrome-extension')) |
| 693 name = this._executionContextNamesByOrigin.get(name) || name; |
| 694 return name; |
| 695 } |
| 696 |
| 697 /** |
| 668 * @param {!TimelineModel.TimelineProfileTree.Node} node | 698 * @param {!TimelineModel.TimelineProfileTree.Node} node |
| 669 * @return {!{name: string, color: string}} | 699 * @return {!{name: string, color: string, icon: (!Element|undefined)}} |
| 670 */ | 700 */ |
| 671 _displayInfoForGroupNode(node) { | 701 _displayInfoForGroupNode(node) { |
| 672 var categories = Timeline.TimelineUIUtils.categories(); | 702 var categories = Timeline.TimelineUIUtils.categories(); |
| 673 var color = node.id ? Timeline.TimelineUIUtils.eventColor(/** @type {!SDK.Tr
acingModel.Event} */ (node.event)) : | 703 var color = node.id ? Timeline.TimelineUIUtils.eventColor(/** @type {!SDK.Tr
acingModel.Event} */ (node.event)) : |
| 674 categories['other'].color; | 704 categories['other'].color; |
| 675 var unattributed = Common.UIString('[unattributed]'); | 705 var unattributed = Common.UIString('[unattributed]'); |
| 676 /** | 706 |
| 677 * @param {string} name | |
| 678 * @return {string} | |
| 679 * @this {Timeline.AggregatedTimelineTreeView} | |
| 680 */ | |
| 681 function beautifyDomainName(name) { | |
| 682 if (Timeline.AggregatedTimelineTreeView._isExtensionInternalURL(name)) | |
| 683 name = Common.UIString('[Chrome extensions overhead]'); | |
| 684 else if (Timeline.AggregatedTimelineTreeView._isV8NativeURL(name)) | |
| 685 name = Common.UIString('[V8 Runtime]'); | |
| 686 else if (name.startsWith('chrome-extension')) | |
| 687 name = this._executionContextNamesByOrigin.get(name) || name; | |
| 688 return name; | |
| 689 } | |
| 690 switch (this._groupBySetting.get()) { | 707 switch (this._groupBySetting.get()) { |
| 691 case Timeline.AggregatedTimelineTreeView.GroupBy.Category: | 708 case Timeline.AggregatedTimelineTreeView.GroupBy.Category: |
| 692 var category = categories[node.id] || categories['other']; | 709 var category = categories[node.id] || categories['other']; |
| 693 return {name: category.title, color: category.color}; | 710 return {name: category.title, color: category.color}; |
| 694 | 711 |
| 695 case Timeline.AggregatedTimelineTreeView.GroupBy.Domain: | 712 case Timeline.AggregatedTimelineTreeView.GroupBy.Domain: |
| 696 case Timeline.AggregatedTimelineTreeView.GroupBy.Subdomain: | 713 case Timeline.AggregatedTimelineTreeView.GroupBy.Subdomain: |
| 697 var domainName = beautifyDomainName.call(this, node.id); | 714 var domainName = this._beautifyDomainName(node.id); |
| 698 if (domainName) { | 715 if (domainName) { |
| 699 var productName = this._productByEvent(/** @type {!SDK.TracingModel.Ev
ent} */ (node.event)); | 716 var productName = this._productByEvent(/** @type {!SDK.TracingModel.Ev
ent} */ (node.event)); |
| 700 if (productName) | 717 if (productName) |
| 701 domainName += ' \u2014 ' + productName; | 718 domainName += ' \u2014 ' + productName; |
| 702 } | 719 } |
| 703 return {name: domainName || unattributed, color: color}; | 720 return {name: domainName || unattributed, color: color}; |
| 704 | 721 |
| 705 case Timeline.AggregatedTimelineTreeView.GroupBy.EventName: | 722 case Timeline.AggregatedTimelineTreeView.GroupBy.EventName: |
| 706 var name = node.event.name === TimelineModel.TimelineModel.RecordType.JS
Frame ? | 723 var name = node.event.name === TimelineModel.TimelineModel.RecordType.JS
Frame ? |
| 707 Common.UIString('JavaScript') : | 724 Common.UIString('JavaScript') : |
| 708 Timeline.TimelineUIUtils.eventTitle(node.event); | 725 Timeline.TimelineUIUtils.eventTitle(node.event); |
| 709 return { | 726 return { |
| 710 name: name, | 727 name: name, |
| 711 color: node.event.name === TimelineModel.TimelineModel.RecordType.JSFr
ame ? | 728 color: node.event.name === TimelineModel.TimelineModel.RecordType.JSFr
ame ? |
| 712 Timeline.TimelineUIUtils.eventStyle(node.event).category.color : | 729 Timeline.TimelineUIUtils.eventStyle(node.event).category.color : |
| 713 color | 730 color |
| 714 }; | 731 }; |
| 715 | 732 |
| 716 case Timeline.AggregatedTimelineTreeView.GroupBy.Product: | 733 case Timeline.AggregatedTimelineTreeView.GroupBy.Product: |
| 717 var productName = this._productByEvent(/** @type {!SDK.TracingModel.Even
t} */ (node.event)); | 734 var event = /** @type {!SDK.TracingModel.Event} */ (node.event); |
| 718 color = productName ? ProductRegistry.BadgePool.colorForEntryName(produc
tName) : '#eee'; | 735 var info = this._productAndBadgeByEvent(event); |
| 719 var name = productName || this._domainByEvent(true, /** @type {!SDK.Trac
ingModel.Event} */ (node.event)) || ''; | 736 var name = info && info.name || unattributed; |
| 720 return {name: beautifyDomainName.call(this, name) || unattributed, color
: color}; | 737 color = Timeline.TimelineUIUtils.eventColorByProduct( |
| 738 this._productRegistry, this._model.timelineModel(), this._colorByURL
Cache, event); |
| 739 return {name: name, color: color, icon: info && info.badge || undefined}
; |
| 721 | 740 |
| 722 case Timeline.AggregatedTimelineTreeView.GroupBy.URL: | 741 case Timeline.AggregatedTimelineTreeView.GroupBy.URL: |
| 723 break; | 742 break; |
| 724 | 743 |
| 725 case Timeline.AggregatedTimelineTreeView.GroupBy.Frame: | 744 case Timeline.AggregatedTimelineTreeView.GroupBy.Frame: |
| 726 var frame = this._model.timelineModel().pageFrameById(node.id); | 745 var frame = this._model.timelineModel().pageFrameById(node.id); |
| 727 var frameName = frame ? Timeline.TimelineUIUtils.displayNameForFrame(fra
me, 80) : Common.UIString('Page'); | 746 var frameName = frame ? Timeline.TimelineUIUtils.displayNameForFrame(fra
me, 80) : Common.UIString('Page'); |
| 728 return {name: frameName, color: color}; | 747 return {name: frameName, color: color}; |
| 729 | 748 |
| 730 default: | 749 default: |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 return null; | 830 return null; |
| 812 case GroupBy.EventName: | 831 case GroupBy.EventName: |
| 813 return event => Timeline.TimelineUIUtils.eventStyle(event).title; | 832 return event => Timeline.TimelineUIUtils.eventStyle(event).title; |
| 814 case GroupBy.Category: | 833 case GroupBy.Category: |
| 815 return event => Timeline.TimelineUIUtils.eventStyle(event).category.name
; | 834 return event => Timeline.TimelineUIUtils.eventStyle(event).category.name
; |
| 816 case GroupBy.Subdomain: | 835 case GroupBy.Subdomain: |
| 817 return this._domainByEvent.bind(this, false); | 836 return this._domainByEvent.bind(this, false); |
| 818 case GroupBy.Domain: | 837 case GroupBy.Domain: |
| 819 return this._domainByEvent.bind(this, true); | 838 return this._domainByEvent.bind(this, true); |
| 820 case GroupBy.Product: | 839 case GroupBy.Product: |
| 821 return event => this._productByEvent(event) || this._domainByEvent(true,
event); | 840 return event => this._productByEvent(event) || this._domainByEvent(true,
event) || ''; |
| 822 case GroupBy.URL: | 841 case GroupBy.URL: |
| 823 return event => TimelineModel.TimelineProfileTree.eventURL(event) || ''; | 842 return event => TimelineModel.TimelineProfileTree.eventURL(event) || ''; |
| 824 case GroupBy.Frame: | 843 case GroupBy.Frame: |
| 825 return event => TimelineModel.TimelineData.forEvent(event).frameId; | 844 return event => TimelineModel.TimelineData.forEvent(event).frameId; |
| 826 default: | 845 default: |
| 827 console.assert(false, `Unexpected aggregation setting: ${groupBy}`); | 846 console.assert(false, `Unexpected aggregation setting: ${groupBy}`); |
| 828 return null; | 847 return null; |
| 829 } | 848 } |
| 830 } | 849 } |
| 831 | 850 |
| 832 /** | 851 /** |
| 833 * @param {boolean} groupSubdomains | 852 * @param {boolean} groupSubdomains |
| 834 * @param {!SDK.TracingModel.Event} event | 853 * @param {!SDK.TracingModel.Event} event |
| 835 * @return {string} | 854 * @return {string} |
| 836 */ | 855 */ |
| 837 _domainByEvent(groupSubdomains, event) { | 856 _domainByEvent(groupSubdomains, event) { |
| 838 var url = TimelineModel.TimelineProfileTree.eventURL(event) || ''; | 857 var url = TimelineModel.TimelineProfileTree.eventURL(event); |
| 858 if (!url) |
| 859 return ''; |
| 839 if (Timeline.AggregatedTimelineTreeView._isExtensionInternalURL(url)) | 860 if (Timeline.AggregatedTimelineTreeView._isExtensionInternalURL(url)) |
| 840 return Timeline.AggregatedTimelineTreeView._extensionInternalPrefix; | 861 return Timeline.AggregatedTimelineTreeView._extensionInternalPrefix; |
| 841 if (Timeline.AggregatedTimelineTreeView._isV8NativeURL(url)) | 862 if (Timeline.AggregatedTimelineTreeView._isV8NativeURL(url)) |
| 842 return Timeline.AggregatedTimelineTreeView._v8NativePrefix; | 863 return Timeline.AggregatedTimelineTreeView._v8NativePrefix; |
| 843 var parsedURL = url.asParsedURL(); | 864 var parsedURL = url.asParsedURL(); |
| 844 if (!parsedURL) | 865 if (!parsedURL) |
| 845 return ''; | 866 return ''; |
| 846 if (parsedURL.scheme === 'chrome-extension') | 867 if (parsedURL.scheme === 'chrome-extension') |
| 847 return parsedURL.scheme + '://' + parsedURL.host; | 868 return parsedURL.scheme + '://' + parsedURL.host; |
| 848 if (!groupSubdomains) | 869 if (!groupSubdomains) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 865 return this._productByURLCache.get(url); | 886 return this._productByURLCache.get(url); |
| 866 if (!this._productRegistry) | 887 if (!this._productRegistry) |
| 867 return ''; | 888 return ''; |
| 868 var parsedURL = url.asParsedURL(); | 889 var parsedURL = url.asParsedURL(); |
| 869 var name = parsedURL && this._productRegistry.nameForUrl(parsedURL) || ''; | 890 var name = parsedURL && this._productRegistry.nameForUrl(parsedURL) || ''; |
| 870 this._productByURLCache.set(url, name); | 891 this._productByURLCache.set(url, name); |
| 871 return name; | 892 return name; |
| 872 } | 893 } |
| 873 | 894 |
| 874 /** | 895 /** |
| 896 * @param {!SDK.TracingModel.Event} event |
| 897 * @return {?{name: string, badge: ?Element}} |
| 898 */ |
| 899 _productAndBadgeByEvent(event) { |
| 900 var url = TimelineModel.TimelineProfileTree.eventURL(event); |
| 901 if (!url || !this._productRegistry) |
| 902 return null; |
| 903 var parsedURL = url.asParsedURL(); |
| 904 var name = parsedURL && this._productRegistry.nameForUrl(parsedURL) || this.
_domainByEvent(true, event); |
| 905 if (!name) |
| 906 return null; |
| 907 var icon = parsedURL && this._badgePool.badgeForURL(parsedURL); |
| 908 return {name: this._beautifyDomainName(name), badge: icon}; |
| 909 } |
| 910 |
| 911 /** |
| 875 * @override | 912 * @override |
| 876 * @param {!UI.ContextMenu} contextMenu | 913 * @param {!UI.ContextMenu} contextMenu |
| 877 * @param {!TimelineModel.TimelineProfileTree.Node} node | 914 * @param {!TimelineModel.TimelineProfileTree.Node} node |
| 878 */ | 915 */ |
| 879 _appendContextMenuItems(contextMenu, node) { | 916 _appendContextMenuItems(contextMenu, node) { |
| 880 if (this._groupBySetting.get() !== Timeline.AggregatedTimelineTreeView.Group
By.Frame) | 917 if (this._groupBySetting.get() !== Timeline.AggregatedTimelineTreeView.Group
By.Frame) |
| 881 return; | 918 return; |
| 882 if (!node.isGroupNode()) | 919 if (!node.isGroupNode()) |
| 883 return; | 920 return; |
| 884 var frame = this._model.timelineModel().pageFrameById(node.id); | 921 var frame = this._model.timelineModel().pageFrameById(node.id); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 | 1050 |
| 1014 _onSelectionChanged() { | 1051 _onSelectionChanged() { |
| 1015 this.dispatchEventToListeners(Timeline.TimelineStackView.Events.SelectionCha
nged); | 1052 this.dispatchEventToListeners(Timeline.TimelineStackView.Events.SelectionCha
nged); |
| 1016 } | 1053 } |
| 1017 }; | 1054 }; |
| 1018 | 1055 |
| 1019 /** @enum {symbol} */ | 1056 /** @enum {symbol} */ |
| 1020 Timeline.TimelineStackView.Events = { | 1057 Timeline.TimelineStackView.Events = { |
| 1021 SelectionChanged: Symbol('SelectionChanged') | 1058 SelectionChanged: Symbol('SelectionChanged') |
| 1022 }; | 1059 }; |
| OLD | NEW |