Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * @constructor | 6 * @constructor |
| 7 * @implements {WebInspector.Searchable} | 7 * @implements {WebInspector.Searchable} |
| 8 * @extends {WebInspector.SimpleView} | 8 * @extends {WebInspector.SimpleView} |
| 9 * @param {!WebInspector.ProfileDataGridNode.Formatter} nodeFormatter | |
| 10 * @param {!Array<string>=} viewTypes | |
| 11 */ | 9 */ |
| 12 WebInspector.ProfileView = function(nodeFormatter, viewTypes) | 10 WebInspector.ProfileView = function() |
| 13 { | 11 { |
| 14 WebInspector.SimpleView.call(this, WebInspector.UIString("Profile")); | 12 WebInspector.SimpleView.call(this, WebInspector.UIString("Profile")); |
| 15 | 13 |
| 16 this._searchableView = new WebInspector.SearchableView(this); | 14 this._searchableView = new WebInspector.SearchableView(this); |
| 17 this._searchableView.setPlaceholder(WebInspector.UIString("Find by cost (>50 ms), name or file")); | 15 this._searchableView.setPlaceholder(WebInspector.UIString("Find by cost (>50 ms), name or file")); |
| 18 this._searchableView.show(this.element); | 16 this._searchableView.show(this.element); |
| 19 | 17 |
| 20 viewTypes = viewTypes || [ | |
| 21 WebInspector.ProfileView.ViewTypes.Flame, | |
| 22 WebInspector.ProfileView.ViewTypes.Heavy, | |
| 23 WebInspector.ProfileView.ViewTypes.Tree | |
| 24 ]; | |
| 25 this._viewType = WebInspector.settings.createSetting("profileView", WebInspe ctor.ProfileView.ViewTypes.Heavy); | |
| 26 this._nodeFormatter = nodeFormatter; | |
| 27 | |
| 28 var columns = /** @type {!Array<!WebInspector.DataGrid.ColumnDescriptor>} */ ([]); | 18 var columns = /** @type {!Array<!WebInspector.DataGrid.ColumnDescriptor>} */ ([]); |
| 29 columns.push({id: "self", title: this.columnHeader("self"), width: "120px", fixedWidth: true, sortable: true, sort: WebInspector.DataGrid.Order.Descending}) ; | 19 columns.push({id: "self", title: this.columnHeader("self"), width: "120px", fixedWidth: true, sortable: true, sort: WebInspector.DataGrid.Order.Descending}) ; |
| 30 columns.push({id: "total", title: this.columnHeader("total"), width: "120px" , fixedWidth: true, sortable: true}); | 20 columns.push({id: "total", title: this.columnHeader("total"), width: "120px" , fixedWidth: true, sortable: true}); |
| 31 columns.push({id: "function", title: WebInspector.UIString("Function"), disc losure: true, sortable: true}); | 21 columns.push({id: "function", title: WebInspector.UIString("Function"), disc losure: true, sortable: true}); |
| 32 | 22 |
| 33 this.dataGrid = new WebInspector.DataGrid(columns); | 23 this.dataGrid = new WebInspector.DataGrid(columns); |
| 34 this.dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._sortProfile, this); | 24 this.dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._sortProfile, this); |
| 35 this.dataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode, th is._nodeSelected.bind(this, true)); | 25 this.dataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode, th is._nodeSelected.bind(this, true)); |
| 36 this.dataGrid.addEventListener(WebInspector.DataGrid.Events.DeselectedNode, this._nodeSelected.bind(this, false)); | 26 this.dataGrid.addEventListener(WebInspector.DataGrid.Events.DeselectedNode, this._nodeSelected.bind(this, false)); |
| 37 | 27 |
| 38 this.viewSelectComboBox = new WebInspector.ToolbarComboBox(this._changeView. bind(this)); | 28 this.viewSelectComboBox = new WebInspector.ToolbarComboBox(this._changeView. bind(this)); |
| 39 var optionNames = new Map([ | |
| 40 [WebInspector.ProfileView.ViewTypes.Flame, WebInspector.UIString("Chart" )], | |
| 41 [WebInspector.ProfileView.ViewTypes.Heavy, WebInspector.UIString("Heavy (Bottom Up)")], | |
| 42 [WebInspector.ProfileView.ViewTypes.Tree, WebInspector.UIString("Tree (T op Down)")], | |
| 43 ]); | |
| 44 var options = new Map(viewTypes.map(type => [type, this.viewSelectComboBox.c reateOption(optionNames.get(type), "", type)])); | |
| 45 var optionName = this._viewType.get() || viewTypes[0]; | |
| 46 var option = options.get(optionName) || options.get(viewTypes[0]); | |
| 47 this.viewSelectComboBox.select(option); | |
| 48 | 29 |
| 49 this.focusButton = new WebInspector.ToolbarButton(WebInspector.UIString("Foc us selected function"), "visibility-toolbar-item"); | 30 this.focusButton = new WebInspector.ToolbarButton(WebInspector.UIString("Foc us selected function"), "visibility-toolbar-item"); |
| 50 this.focusButton.setEnabled(false); | 31 this.focusButton.setEnabled(false); |
| 51 this.focusButton.addEventListener("click", this._focusClicked, this); | 32 this.focusButton.addEventListener("click", this._focusClicked, this); |
| 52 | 33 |
| 53 this.excludeButton = new WebInspector.ToolbarButton(WebInspector.UIString("E xclude selected function"), "delete-toolbar-item"); | 34 this.excludeButton = new WebInspector.ToolbarButton(WebInspector.UIString("E xclude selected function"), "delete-toolbar-item"); |
| 54 this.excludeButton.setEnabled(false); | 35 this.excludeButton.setEnabled(false); |
| 55 this.excludeButton.addEventListener("click", this._excludeClicked, this); | 36 this.excludeButton.addEventListener("click", this._excludeClicked, this); |
| 56 | 37 |
| 57 this.resetButton = new WebInspector.ToolbarButton(WebInspector.UIString("Res tore all functions"), "refresh-toolbar-item"); | 38 this.resetButton = new WebInspector.ToolbarButton(WebInspector.UIString("Res tore all functions"), "refresh-toolbar-item"); |
| 58 this.resetButton.setEnabled(false); | 39 this.resetButton.setEnabled(false); |
| 59 this.resetButton.addEventListener("click", this._resetClicked, this); | 40 this.resetButton.addEventListener("click", this._resetClicked, this); |
| 60 | 41 |
| 61 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa ultFormatter(30)); | 42 this._linkifier = new WebInspector.Linkifier(new WebInspector.Linkifier.Defa ultFormatter(30)); |
| 62 | |
| 63 this._changeView(); | |
| 64 if (this._flameChart) | |
| 65 this._flameChart.update(); | |
| 66 }; | 43 }; |
| 67 | 44 |
| 68 /** @enum {string} */ | 45 /** @enum {string} */ |
| 69 WebInspector.ProfileView.ViewTypes = { | 46 WebInspector.ProfileView.ViewTypes = { |
| 70 Flame: "Flame", | 47 Flame: "Flame", |
| 71 Tree: "Tree", | 48 Tree: "Tree", |
| 72 Heavy: "Heavy" | 49 Heavy: "Heavy" |
| 73 }; | 50 }; |
| 74 | 51 |
| 75 /** | 52 /** |
| 76 * @param {!Array<!{title: string, value: string}>} entryInfo | 53 * @param {!Array<!{title: string, value: string}>} entryInfo |
| 77 * @return {!Element} | 54 * @return {!Element} |
| 78 */ | 55 */ |
| 79 WebInspector.ProfileView.buildPopoverTable = function(entryInfo) | 56 WebInspector.ProfileView.buildPopoverTable = function(entryInfo) |
| 80 { | 57 { |
| 81 var table = createElement("table"); | 58 var table = createElement("table"); |
| 82 for (var entry of entryInfo) { | 59 for (var entry of entryInfo) { |
| 83 var row = table.createChild("tr"); | 60 var row = table.createChild("tr"); |
| 84 row.createChild("td").textContent = entry.title; | 61 row.createChild("td").textContent = entry.title; |
| 85 row.createChild("td").textContent = entry.value; | 62 row.createChild("td").textContent = entry.value; |
| 86 } | 63 } |
| 87 return table; | 64 return table; |
| 88 }; | 65 }; |
| 89 | 66 |
| 90 WebInspector.ProfileView.prototype = { | 67 WebInspector.ProfileView.prototype = { |
| 68 /** | |
| 69 * @param {!WebInspector.ProfileDataGridNode.Formatter} nodeFormatter | |
| 70 * @param {!Array<string>=} viewTypes | |
| 71 */ | |
| 72 initialize: function(nodeFormatter, viewTypes) | |
|
dgozman
2016/10/26 00:31:01
@protected
| |
| 73 { | |
| 74 this._nodeFormatter = nodeFormatter; | |
| 75 | |
| 76 this._viewType = WebInspector.settings.createSetting("profileView", WebI nspector.ProfileView.ViewTypes.Heavy); | |
| 77 viewTypes = viewTypes || [ | |
| 78 WebInspector.ProfileView.ViewTypes.Flame, | |
| 79 WebInspector.ProfileView.ViewTypes.Heavy, | |
| 80 WebInspector.ProfileView.ViewTypes.Tree | |
| 81 ]; | |
| 82 | |
| 83 var optionNames = new Map([ | |
| 84 [WebInspector.ProfileView.ViewTypes.Flame, WebInspector.UIString("Ch art")], | |
| 85 [WebInspector.ProfileView.ViewTypes.Heavy, WebInspector.UIString("He avy (Bottom Up)")], | |
| 86 [WebInspector.ProfileView.ViewTypes.Tree, WebInspector.UIString("Tre e (Top Down)")], | |
| 87 ]); | |
| 88 | |
| 89 var options = new Map(viewTypes.map(type => [type, this.viewSelectComboB ox.createOption(optionNames.get(type), "", type)])); | |
| 90 var optionName = this._viewType.get() || viewTypes[0]; | |
| 91 var option = options.get(optionName) || options.get(viewTypes[0]); | |
| 92 this.viewSelectComboBox.select(option); | |
| 93 | |
| 94 this._changeView(); | |
| 95 if (this._flameChart) | |
| 96 this._flameChart.update(); | |
| 97 }, | |
| 98 | |
| 91 focus: function() | 99 focus: function() |
| 92 { | 100 { |
| 93 if (this._flameChart) | 101 if (this._flameChart) |
| 94 this._flameChart.focus(); | 102 this._flameChart.focus(); |
| 95 else | 103 else |
| 96 WebInspector.Widget.prototype.focus.call(this); | 104 WebInspector.Widget.prototype.focus.call(this); |
| 97 }, | 105 }, |
| 98 | 106 |
| 99 /** | 107 /** |
| 100 * @param {string} columnId | 108 * @param {string} columnId |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 599 _notifyTempFileReady: function() | 607 _notifyTempFileReady: function() |
| 600 { | 608 { |
| 601 if (this._onTempFileReady) { | 609 if (this._onTempFileReady) { |
| 602 this._onTempFileReady(); | 610 this._onTempFileReady(); |
| 603 this._onTempFileReady = null; | 611 this._onTempFileReady = null; |
| 604 } | 612 } |
| 605 }, | 613 }, |
| 606 | 614 |
| 607 __proto__: WebInspector.ProfileHeader.prototype | 615 __proto__: WebInspector.ProfileHeader.prototype |
| 608 }; | 616 }; |
| OLD | NEW |