| 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 * @implements {WebInspector.Searchable} | 5 * @implements {UI.Searchable} |
| 6 * @unrestricted | 6 * @unrestricted |
| 7 */ | 7 */ |
| 8 WebInspector.ProfileView = class extends WebInspector.SimpleView { | 8 Profiler.ProfileView = class extends UI.SimpleView { |
| 9 constructor() { | 9 constructor() { |
| 10 super(WebInspector.UIString('Profile')); | 10 super(Common.UIString('Profile')); |
| 11 | 11 |
| 12 this._searchableView = new WebInspector.SearchableView(this); | 12 this._searchableView = new UI.SearchableView(this); |
| 13 this._searchableView.setPlaceholder(WebInspector.UIString('Find by cost (>50
ms), name or file')); | 13 this._searchableView.setPlaceholder(Common.UIString('Find by cost (>50ms), n
ame or file')); |
| 14 this._searchableView.show(this.element); | 14 this._searchableView.show(this.element); |
| 15 | 15 |
| 16 var columns = /** @type {!Array<!WebInspector.DataGrid.ColumnDescriptor>} */
([]); | 16 var columns = /** @type {!Array<!UI.DataGrid.ColumnDescriptor>} */ ([]); |
| 17 columns.push({ | 17 columns.push({ |
| 18 id: 'self', | 18 id: 'self', |
| 19 title: this.columnHeader('self'), | 19 title: this.columnHeader('self'), |
| 20 width: '120px', | 20 width: '120px', |
| 21 fixedWidth: true, | 21 fixedWidth: true, |
| 22 sortable: true, | 22 sortable: true, |
| 23 sort: WebInspector.DataGrid.Order.Descending | 23 sort: UI.DataGrid.Order.Descending |
| 24 }); | 24 }); |
| 25 columns.push({id: 'total', title: this.columnHeader('total'), width: '120px'
, fixedWidth: true, sortable: true}); | 25 columns.push({id: 'total', title: this.columnHeader('total'), width: '120px'
, fixedWidth: true, sortable: true}); |
| 26 columns.push({id: 'function', title: WebInspector.UIString('Function'), disc
losure: true, sortable: true}); | 26 columns.push({id: 'function', title: Common.UIString('Function'), disclosure
: true, sortable: true}); |
| 27 | 27 |
| 28 this.dataGrid = new WebInspector.DataGrid(columns); | 28 this.dataGrid = new UI.DataGrid(columns); |
| 29 this.dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged,
this._sortProfile, this); | 29 this.dataGrid.addEventListener(UI.DataGrid.Events.SortingChanged, this._sort
Profile, this); |
| 30 this.dataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode, th
is._nodeSelected.bind(this, true)); | 30 this.dataGrid.addEventListener(UI.DataGrid.Events.SelectedNode, this._nodeSe
lected.bind(this, true)); |
| 31 this.dataGrid.addEventListener(WebInspector.DataGrid.Events.DeselectedNode,
this._nodeSelected.bind(this, false)); | 31 this.dataGrid.addEventListener(UI.DataGrid.Events.DeselectedNode, this._node
Selected.bind(this, false)); |
| 32 | 32 |
| 33 this.viewSelectComboBox = new WebInspector.ToolbarComboBox(this._changeView.
bind(this)); | 33 this.viewSelectComboBox = new UI.ToolbarComboBox(this._changeView.bind(this)
); |
| 34 | 34 |
| 35 this.focusButton = | 35 this.focusButton = |
| 36 new WebInspector.ToolbarButton(WebInspector.UIString('Focus selected fun
ction'), 'largeicon-visibility'); | 36 new UI.ToolbarButton(Common.UIString('Focus selected function'), 'largei
con-visibility'); |
| 37 this.focusButton.setEnabled(false); | 37 this.focusButton.setEnabled(false); |
| 38 this.focusButton.addEventListener('click', this._focusClicked, this); | 38 this.focusButton.addEventListener('click', this._focusClicked, this); |
| 39 | 39 |
| 40 this.excludeButton = | 40 this.excludeButton = |
| 41 new WebInspector.ToolbarButton(WebInspector.UIString('Exclude selected f
unction'), 'largeicon-delete'); | 41 new UI.ToolbarButton(Common.UIString('Exclude selected function'), 'larg
eicon-delete'); |
| 42 this.excludeButton.setEnabled(false); | 42 this.excludeButton.setEnabled(false); |
| 43 this.excludeButton.addEventListener('click', this._excludeClicked, this); | 43 this.excludeButton.addEventListener('click', this._excludeClicked, this); |
| 44 | 44 |
| 45 this.resetButton = | 45 this.resetButton = |
| 46 new WebInspector.ToolbarButton(WebInspector.UIString('Restore all functi
ons'), 'largeicon-refresh'); | 46 new UI.ToolbarButton(Common.UIString('Restore all functions'), 'largeico
n-refresh'); |
| 47 this.resetButton.setEnabled(false); | 47 this.resetButton.setEnabled(false); |
| 48 this.resetButton.addEventListener('click', this._resetClicked, this); | 48 this.resetButton.addEventListener('click', this._resetClicked, this); |
| 49 | 49 |
| 50 this._linkifier = new WebInspector.Linkifier(WebInspector.ProfileView._maxLi
nkLength); | 50 this._linkifier = new Components.Linkifier(Profiler.ProfileView._maxLinkLeng
th); |
| 51 } | 51 } |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * @param {!Array<!{title: string, value: string}>} entryInfo | 54 * @param {!Array<!{title: string, value: string}>} entryInfo |
| 55 * @return {!Element} | 55 * @return {!Element} |
| 56 */ | 56 */ |
| 57 static buildPopoverTable(entryInfo) { | 57 static buildPopoverTable(entryInfo) { |
| 58 var table = createElement('table'); | 58 var table = createElement('table'); |
| 59 for (var entry of entryInfo) { | 59 for (var entry of entryInfo) { |
| 60 var row = table.createChild('tr'); | 60 var row = table.createChild('tr'); |
| 61 row.createChild('td').textContent = entry.title; | 61 row.createChild('td').textContent = entry.title; |
| 62 row.createChild('td').textContent = entry.value; | 62 row.createChild('td').textContent = entry.value; |
| 63 } | 63 } |
| 64 return table; | 64 return table; |
| 65 } | 65 } |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * @param {!WebInspector.ProfileDataGridNode.Formatter} nodeFormatter | 68 * @param {!Profiler.ProfileDataGridNode.Formatter} nodeFormatter |
| 69 * @param {!Array<string>=} viewTypes | 69 * @param {!Array<string>=} viewTypes |
| 70 * @protected | 70 * @protected |
| 71 */ | 71 */ |
| 72 initialize(nodeFormatter, viewTypes) { | 72 initialize(nodeFormatter, viewTypes) { |
| 73 this._nodeFormatter = nodeFormatter; | 73 this._nodeFormatter = nodeFormatter; |
| 74 | 74 |
| 75 this._viewType = WebInspector.settings.createSetting('profileView', WebInspe
ctor.ProfileView.ViewTypes.Heavy); | 75 this._viewType = Common.settings.createSetting('profileView', Profiler.Profi
leView.ViewTypes.Heavy); |
| 76 viewTypes = viewTypes || [ | 76 viewTypes = viewTypes || [ |
| 77 WebInspector.ProfileView.ViewTypes.Flame, WebInspector.ProfileView.ViewTyp
es.Heavy, | 77 Profiler.ProfileView.ViewTypes.Flame, Profiler.ProfileView.ViewTypes.Heavy
, |
| 78 WebInspector.ProfileView.ViewTypes.Tree | 78 Profiler.ProfileView.ViewTypes.Tree |
| 79 ]; | 79 ]; |
| 80 | 80 |
| 81 var optionNames = new Map([ | 81 var optionNames = new Map([ |
| 82 [WebInspector.ProfileView.ViewTypes.Flame, WebInspector.UIString('Chart')]
, | 82 [Profiler.ProfileView.ViewTypes.Flame, Common.UIString('Chart')], |
| 83 [WebInspector.ProfileView.ViewTypes.Heavy, WebInspector.UIString('Heavy (B
ottom Up)')], | 83 [Profiler.ProfileView.ViewTypes.Heavy, Common.UIString('Heavy (Bottom Up)'
)], |
| 84 [WebInspector.ProfileView.ViewTypes.Tree, WebInspector.UIString('Tree (Top
Down)')], | 84 [Profiler.ProfileView.ViewTypes.Tree, Common.UIString('Tree (Top Down)')], |
| 85 ]); | 85 ]); |
| 86 | 86 |
| 87 var options = | 87 var options = |
| 88 new Map(viewTypes.map(type => [type, this.viewSelectComboBox.createOptio
n(optionNames.get(type), '', type)])); | 88 new Map(viewTypes.map(type => [type, this.viewSelectComboBox.createOptio
n(optionNames.get(type), '', type)])); |
| 89 var optionName = this._viewType.get() || viewTypes[0]; | 89 var optionName = this._viewType.get() || viewTypes[0]; |
| 90 var option = options.get(optionName) || options.get(viewTypes[0]); | 90 var option = options.get(optionName) || options.get(viewTypes[0]); |
| 91 this.viewSelectComboBox.select(option); | 91 this.viewSelectComboBox.select(option); |
| 92 | 92 |
| 93 this._changeView(); | 93 this._changeView(); |
| 94 if (this._flameChart) | 94 if (this._flameChart) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 107 | 107 |
| 108 /** | 108 /** |
| 109 * @param {string} columnId | 109 * @param {string} columnId |
| 110 * @return {string} | 110 * @return {string} |
| 111 */ | 111 */ |
| 112 columnHeader(columnId) { | 112 columnHeader(columnId) { |
| 113 throw 'Not implemented'; | 113 throw 'Not implemented'; |
| 114 } | 114 } |
| 115 | 115 |
| 116 /** | 116 /** |
| 117 * @return {?WebInspector.Target} | 117 * @return {?SDK.Target} |
| 118 */ | 118 */ |
| 119 target() { | 119 target() { |
| 120 return this._profileHeader.target(); | 120 return this._profileHeader.target(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 /** | 123 /** |
| 124 * @param {number} timeLeft | 124 * @param {number} timeLeft |
| 125 * @param {number} timeRight | 125 * @param {number} timeRight |
| 126 */ | 126 */ |
| 127 selectRange(timeLeft, timeRight) { | 127 selectRange(timeLeft, timeRight) { |
| 128 if (!this._flameChart) | 128 if (!this._flameChart) |
| 129 return; | 129 return; |
| 130 this._flameChart.selectRange(timeLeft, timeRight); | 130 this._flameChart.selectRange(timeLeft, timeRight); |
| 131 } | 131 } |
| 132 | 132 |
| 133 /** | 133 /** |
| 134 * @override | 134 * @override |
| 135 * @return {!Array.<!WebInspector.ToolbarItem>} | 135 * @return {!Array.<!UI.ToolbarItem>} |
| 136 */ | 136 */ |
| 137 syncToolbarItems() { | 137 syncToolbarItems() { |
| 138 return [this.viewSelectComboBox, this.focusButton, this.excludeButton, this.
resetButton]; | 138 return [this.viewSelectComboBox, this.focusButton, this.excludeButton, this.
resetButton]; |
| 139 } | 139 } |
| 140 | 140 |
| 141 /** | 141 /** |
| 142 * @return {!WebInspector.ProfileDataGridTree} | 142 * @return {!Profiler.ProfileDataGridTree} |
| 143 */ | 143 */ |
| 144 _getBottomUpProfileDataGridTree() { | 144 _getBottomUpProfileDataGridTree() { |
| 145 if (!this._bottomUpProfileDataGridTree) | 145 if (!this._bottomUpProfileDataGridTree) |
| 146 this._bottomUpProfileDataGridTree = new WebInspector.BottomUpProfileDataGr
idTree( | 146 this._bottomUpProfileDataGridTree = new Profiler.BottomUpProfileDataGridTr
ee( |
| 147 this._nodeFormatter, this._searchableView, this.profile.root, this.adj
ustedTotal); | 147 this._nodeFormatter, this._searchableView, this.profile.root, this.adj
ustedTotal); |
| 148 return this._bottomUpProfileDataGridTree; | 148 return this._bottomUpProfileDataGridTree; |
| 149 } | 149 } |
| 150 | 150 |
| 151 /** | 151 /** |
| 152 * @return {!WebInspector.ProfileDataGridTree} | 152 * @return {!Profiler.ProfileDataGridTree} |
| 153 */ | 153 */ |
| 154 _getTopDownProfileDataGridTree() { | 154 _getTopDownProfileDataGridTree() { |
| 155 if (!this._topDownProfileDataGridTree) | 155 if (!this._topDownProfileDataGridTree) |
| 156 this._topDownProfileDataGridTree = new WebInspector.TopDownProfileDataGrid
Tree( | 156 this._topDownProfileDataGridTree = new Profiler.TopDownProfileDataGridTree
( |
| 157 this._nodeFormatter, this._searchableView, this.profile.root, this.adj
ustedTotal); | 157 this._nodeFormatter, this._searchableView, this.profile.root, this.adj
ustedTotal); |
| 158 return this._topDownProfileDataGridTree; | 158 return this._topDownProfileDataGridTree; |
| 159 } | 159 } |
| 160 | 160 |
| 161 /** | 161 /** |
| 162 * @override | 162 * @override |
| 163 */ | 163 */ |
| 164 willHide() { | 164 willHide() { |
| 165 this._currentSearchResultIndex = -1; | 165 this._currentSearchResultIndex = -1; |
| 166 } | 166 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 182 | 182 |
| 183 refreshVisibleData() { | 183 refreshVisibleData() { |
| 184 var child = this.dataGrid.rootNode().children[0]; | 184 var child = this.dataGrid.rootNode().children[0]; |
| 185 while (child) { | 185 while (child) { |
| 186 child.refresh(); | 186 child.refresh(); |
| 187 child = child.traverseNextNode(false, null, true); | 187 child = child.traverseNextNode(false, null, true); |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 | 190 |
| 191 /** | 191 /** |
| 192 * @return {!WebInspector.SearchableView} | 192 * @return {!UI.SearchableView} |
| 193 */ | 193 */ |
| 194 searchableView() { | 194 searchableView() { |
| 195 return this._searchableView; | 195 return this._searchableView; |
| 196 } | 196 } |
| 197 | 197 |
| 198 /** | 198 /** |
| 199 * @override | 199 * @override |
| 200 * @return {boolean} | 200 * @return {boolean} |
| 201 */ | 201 */ |
| 202 supportsCaseSensitiveSearch() { | 202 supportsCaseSensitiveSearch() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 213 | 213 |
| 214 /** | 214 /** |
| 215 * @override | 215 * @override |
| 216 */ | 216 */ |
| 217 searchCanceled() { | 217 searchCanceled() { |
| 218 this._searchableElement.searchCanceled(); | 218 this._searchableElement.searchCanceled(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 /** | 221 /** |
| 222 * @override | 222 * @override |
| 223 * @param {!WebInspector.SearchableView.SearchConfig} searchConfig | 223 * @param {!UI.SearchableView.SearchConfig} searchConfig |
| 224 * @param {boolean} shouldJump | 224 * @param {boolean} shouldJump |
| 225 * @param {boolean=} jumpBackwards | 225 * @param {boolean=} jumpBackwards |
| 226 */ | 226 */ |
| 227 performSearch(searchConfig, shouldJump, jumpBackwards) { | 227 performSearch(searchConfig, shouldJump, jumpBackwards) { |
| 228 this._searchableElement.performSearch(searchConfig, shouldJump, jumpBackward
s); | 228 this._searchableElement.performSearch(searchConfig, shouldJump, jumpBackward
s); |
| 229 } | 229 } |
| 230 | 230 |
| 231 /** | 231 /** |
| 232 * @override | 232 * @override |
| 233 */ | 233 */ |
| 234 jumpToNextSearchResult() { | 234 jumpToNextSearchResult() { |
| 235 this._searchableElement.jumpToNextSearchResult(); | 235 this._searchableElement.jumpToNextSearchResult(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 /** | 238 /** |
| 239 * @override | 239 * @override |
| 240 */ | 240 */ |
| 241 jumpToPreviousSearchResult() { | 241 jumpToPreviousSearchResult() { |
| 242 this._searchableElement.jumpToPreviousSearchResult(); | 242 this._searchableElement.jumpToPreviousSearchResult(); |
| 243 } | 243 } |
| 244 | 244 |
| 245 /** | 245 /** |
| 246 * @return {!WebInspector.Linkifier} | 246 * @return {!Components.Linkifier} |
| 247 */ | 247 */ |
| 248 linkifier() { | 248 linkifier() { |
| 249 return this._linkifier; | 249 return this._linkifier; |
| 250 } | 250 } |
| 251 | 251 |
| 252 /** | 252 /** |
| 253 * @return {!WebInspector.FlameChartDataProvider} | 253 * @return {!UI.FlameChartDataProvider} |
| 254 */ | 254 */ |
| 255 createFlameChartDataProvider() { | 255 createFlameChartDataProvider() { |
| 256 throw 'Not implemented'; | 256 throw 'Not implemented'; |
| 257 } | 257 } |
| 258 | 258 |
| 259 _ensureFlameChartCreated() { | 259 _ensureFlameChartCreated() { |
| 260 if (this._flameChart) | 260 if (this._flameChart) |
| 261 return; | 261 return; |
| 262 this._dataProvider = this.createFlameChartDataProvider(); | 262 this._dataProvider = this.createFlameChartDataProvider(); |
| 263 this._flameChart = new WebInspector.CPUProfileFlameChart(this._searchableVie
w, this._dataProvider); | 263 this._flameChart = new Profiler.CPUProfileFlameChart(this._searchableView, t
his._dataProvider); |
| 264 this._flameChart.addEventListener(WebInspector.FlameChart.Events.EntrySelect
ed, this._onEntrySelected.bind(this)); | 264 this._flameChart.addEventListener(UI.FlameChart.Events.EntrySelected, this._
onEntrySelected.bind(this)); |
| 265 } | 265 } |
| 266 | 266 |
| 267 /** | 267 /** |
| 268 * @param {!WebInspector.Event} event | 268 * @param {!Common.Event} event |
| 269 */ | 269 */ |
| 270 _onEntrySelected(event) { | 270 _onEntrySelected(event) { |
| 271 var entryIndex = event.data; | 271 var entryIndex = event.data; |
| 272 var node = this._dataProvider._entryNodes[entryIndex]; | 272 var node = this._dataProvider._entryNodes[entryIndex]; |
| 273 var debuggerModel = this._profileHeader._debuggerModel; | 273 var debuggerModel = this._profileHeader._debuggerModel; |
| 274 if (!node || !node.scriptId || !debuggerModel) | 274 if (!node || !node.scriptId || !debuggerModel) |
| 275 return; | 275 return; |
| 276 var script = debuggerModel.scriptForId(node.scriptId); | 276 var script = debuggerModel.scriptForId(node.scriptId); |
| 277 if (!script) | 277 if (!script) |
| 278 return; | 278 return; |
| 279 var location = /** @type {!WebInspector.DebuggerModel.Location} */ ( | 279 var location = /** @type {!SDK.DebuggerModel.Location} */ ( |
| 280 debuggerModel.createRawLocation(script, node.lineNumber, node.columnNumb
er)); | 280 debuggerModel.createRawLocation(script, node.lineNumber, node.columnNumb
er)); |
| 281 WebInspector.Revealer.reveal(WebInspector.debuggerWorkspaceBinding.rawLocati
onToUILocation(location)); | 281 Common.Revealer.reveal(Bindings.debuggerWorkspaceBinding.rawLocationToUILoca
tion(location)); |
| 282 } | 282 } |
| 283 | 283 |
| 284 _changeView() { | 284 _changeView() { |
| 285 if (!this.profile) | 285 if (!this.profile) |
| 286 return; | 286 return; |
| 287 | 287 |
| 288 this._searchableView.closeSearch(); | 288 this._searchableView.closeSearch(); |
| 289 | 289 |
| 290 if (this._visibleView) | 290 if (this._visibleView) |
| 291 this._visibleView.detach(); | 291 this._visibleView.detach(); |
| 292 | 292 |
| 293 this._viewType.set(this.viewSelectComboBox.selectedOption().value); | 293 this._viewType.set(this.viewSelectComboBox.selectedOption().value); |
| 294 switch (this._viewType.get()) { | 294 switch (this._viewType.get()) { |
| 295 case WebInspector.ProfileView.ViewTypes.Flame: | 295 case Profiler.ProfileView.ViewTypes.Flame: |
| 296 this._ensureFlameChartCreated(); | 296 this._ensureFlameChartCreated(); |
| 297 this._visibleView = this._flameChart; | 297 this._visibleView = this._flameChart; |
| 298 this._searchableElement = this._flameChart; | 298 this._searchableElement = this._flameChart; |
| 299 break; | 299 break; |
| 300 case WebInspector.ProfileView.ViewTypes.Tree: | 300 case Profiler.ProfileView.ViewTypes.Tree: |
| 301 this.profileDataGridTree = this._getTopDownProfileDataGridTree(); | 301 this.profileDataGridTree = this._getTopDownProfileDataGridTree(); |
| 302 this._sortProfile(); | 302 this._sortProfile(); |
| 303 this._visibleView = this.dataGrid.asWidget(); | 303 this._visibleView = this.dataGrid.asWidget(); |
| 304 this._searchableElement = this.profileDataGridTree; | 304 this._searchableElement = this.profileDataGridTree; |
| 305 break; | 305 break; |
| 306 case WebInspector.ProfileView.ViewTypes.Heavy: | 306 case Profiler.ProfileView.ViewTypes.Heavy: |
| 307 this.profileDataGridTree = this._getBottomUpProfileDataGridTree(); | 307 this.profileDataGridTree = this._getBottomUpProfileDataGridTree(); |
| 308 this._sortProfile(); | 308 this._sortProfile(); |
| 309 this._visibleView = this.dataGrid.asWidget(); | 309 this._visibleView = this.dataGrid.asWidget(); |
| 310 this._searchableElement = this.profileDataGridTree; | 310 this._searchableElement = this.profileDataGridTree; |
| 311 break; | 311 break; |
| 312 } | 312 } |
| 313 | 313 |
| 314 var isFlame = this._viewType.get() === WebInspector.ProfileView.ViewTypes.Fl
ame; | 314 var isFlame = this._viewType.get() === Profiler.ProfileView.ViewTypes.Flame; |
| 315 this.focusButton.setVisible(!isFlame); | 315 this.focusButton.setVisible(!isFlame); |
| 316 this.excludeButton.setVisible(!isFlame); | 316 this.excludeButton.setVisible(!isFlame); |
| 317 this.resetButton.setVisible(!isFlame); | 317 this.resetButton.setVisible(!isFlame); |
| 318 | 318 |
| 319 this._visibleView.show(this._searchableView.element); | 319 this._visibleView.show(this._searchableView.element); |
| 320 } | 320 } |
| 321 | 321 |
| 322 /** | 322 /** |
| 323 * @param {boolean} selected | 323 * @param {boolean} selected |
| 324 */ | 324 */ |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 this.profileDataGridTree.restore(); | 356 this.profileDataGridTree.restore(); |
| 357 this._linkifier.reset(); | 357 this._linkifier.reset(); |
| 358 this.refresh(); | 358 this.refresh(); |
| 359 this.refreshVisibleData(); | 359 this.refreshVisibleData(); |
| 360 } | 360 } |
| 361 | 361 |
| 362 _sortProfile() { | 362 _sortProfile() { |
| 363 var sortAscending = this.dataGrid.isSortOrderAscending(); | 363 var sortAscending = this.dataGrid.isSortOrderAscending(); |
| 364 var sortColumnId = this.dataGrid.sortColumnId(); | 364 var sortColumnId = this.dataGrid.sortColumnId(); |
| 365 var sortProperty = sortColumnId === 'function' ? 'functionName' : sortColumn
Id || ''; | 365 var sortProperty = sortColumnId === 'function' ? 'functionName' : sortColumn
Id || ''; |
| 366 this.profileDataGridTree.sort(WebInspector.ProfileDataGridTree.propertyCompa
rator(sortProperty, sortAscending)); | 366 this.profileDataGridTree.sort(Profiler.ProfileDataGridTree.propertyComparato
r(sortProperty, sortAscending)); |
| 367 | 367 |
| 368 this.refresh(); | 368 this.refresh(); |
| 369 } | 369 } |
| 370 }; | 370 }; |
| 371 | 371 |
| 372 WebInspector.ProfileView._maxLinkLength = 30; | 372 Profiler.ProfileView._maxLinkLength = 30; |
| 373 | 373 |
| 374 /** @enum {string} */ | 374 /** @enum {string} */ |
| 375 WebInspector.ProfileView.ViewTypes = { | 375 Profiler.ProfileView.ViewTypes = { |
| 376 Flame: 'Flame', | 376 Flame: 'Flame', |
| 377 Tree: 'Tree', | 377 Tree: 'Tree', |
| 378 Heavy: 'Heavy' | 378 Heavy: 'Heavy' |
| 379 }; | 379 }; |
| 380 | 380 |
| 381 | 381 |
| 382 /** | 382 /** |
| 383 * @implements {WebInspector.OutputStream} | 383 * @implements {Common.OutputStream} |
| 384 * @implements {WebInspector.OutputStreamDelegate} | 384 * @implements {Bindings.OutputStreamDelegate} |
| 385 * @unrestricted | 385 * @unrestricted |
| 386 */ | 386 */ |
| 387 WebInspector.WritableProfileHeader = class extends WebInspector.ProfileHeader { | 387 Profiler.WritableProfileHeader = class extends Profiler.ProfileHeader { |
| 388 /** | 388 /** |
| 389 * @param {?WebInspector.Target} target | 389 * @param {?SDK.Target} target |
| 390 * @param {!WebInspector.ProfileType} type | 390 * @param {!Profiler.ProfileType} type |
| 391 * @param {string=} title | 391 * @param {string=} title |
| 392 */ | 392 */ |
| 393 constructor(target, type, title) { | 393 constructor(target, type, title) { |
| 394 super(target, type, title || WebInspector.UIString('Profile %d', type.nextPr
ofileUid())); | 394 super(target, type, title || Common.UIString('Profile %d', type.nextProfileU
id())); |
| 395 this._debuggerModel = WebInspector.DebuggerModel.fromTarget(target); | 395 this._debuggerModel = SDK.DebuggerModel.fromTarget(target); |
| 396 this._tempFile = null; | 396 this._tempFile = null; |
| 397 } | 397 } |
| 398 | 398 |
| 399 /** | 399 /** |
| 400 * @override | 400 * @override |
| 401 */ | 401 */ |
| 402 onTransferStarted() { | 402 onTransferStarted() { |
| 403 this._jsonifiedProfile = ''; | 403 this._jsonifiedProfile = ''; |
| 404 this.updateStatus( | 404 this.updateStatus( |
| 405 WebInspector.UIString('Loading\u2026 %s', Number.bytesToString(this._jso
nifiedProfile.length)), true); | 405 Common.UIString('Loading\u2026 %s', Number.bytesToString(this._jsonified
Profile.length)), true); |
| 406 } | 406 } |
| 407 | 407 |
| 408 /** | 408 /** |
| 409 * @override | 409 * @override |
| 410 * @param {!WebInspector.ChunkedReader} reader | 410 * @param {!Bindings.ChunkedReader} reader |
| 411 */ | 411 */ |
| 412 onChunkTransferred(reader) { | 412 onChunkTransferred(reader) { |
| 413 this.updateStatus(WebInspector.UIString('Loading\u2026 %d%%', Number.bytesTo
String(this._jsonifiedProfile.length))); | 413 this.updateStatus(Common.UIString('Loading\u2026 %d%%', Number.bytesToString
(this._jsonifiedProfile.length))); |
| 414 } | 414 } |
| 415 | 415 |
| 416 /** | 416 /** |
| 417 * @override | 417 * @override |
| 418 */ | 418 */ |
| 419 onTransferFinished() { | 419 onTransferFinished() { |
| 420 this.updateStatus(WebInspector.UIString('Parsing\u2026'), true); | 420 this.updateStatus(Common.UIString('Parsing\u2026'), true); |
| 421 this._profile = JSON.parse(this._jsonifiedProfile); | 421 this._profile = JSON.parse(this._jsonifiedProfile); |
| 422 this._jsonifiedProfile = null; | 422 this._jsonifiedProfile = null; |
| 423 this.updateStatus(WebInspector.UIString('Loaded'), false); | 423 this.updateStatus(Common.UIString('Loaded'), false); |
| 424 | 424 |
| 425 if (this._profileType.profileBeingRecorded() === this) | 425 if (this._profileType.profileBeingRecorded() === this) |
| 426 this._profileType.setProfileBeingRecorded(null); | 426 this._profileType.setProfileBeingRecorded(null); |
| 427 } | 427 } |
| 428 | 428 |
| 429 /** | 429 /** |
| 430 * @override | 430 * @override |
| 431 * @param {!WebInspector.ChunkedReader} reader | 431 * @param {!Bindings.ChunkedReader} reader |
| 432 * @param {!Event} e | 432 * @param {!Event} e |
| 433 */ | 433 */ |
| 434 onError(reader, e) { | 434 onError(reader, e) { |
| 435 var subtitle; | 435 var subtitle; |
| 436 switch (e.target.error.code) { | 436 switch (e.target.error.code) { |
| 437 case e.target.error.NOT_FOUND_ERR: | 437 case e.target.error.NOT_FOUND_ERR: |
| 438 subtitle = WebInspector.UIString('\'%s\' not found.', reader.fileName())
; | 438 subtitle = Common.UIString('\'%s\' not found.', reader.fileName()); |
| 439 break; | 439 break; |
| 440 case e.target.error.NOT_READABLE_ERR: | 440 case e.target.error.NOT_READABLE_ERR: |
| 441 subtitle = WebInspector.UIString('\'%s\' is not readable', reader.fileNa
me()); | 441 subtitle = Common.UIString('\'%s\' is not readable', reader.fileName()); |
| 442 break; | 442 break; |
| 443 case e.target.error.ABORT_ERR: | 443 case e.target.error.ABORT_ERR: |
| 444 return; | 444 return; |
| 445 default: | 445 default: |
| 446 subtitle = WebInspector.UIString('\'%s\' error %d', reader.fileName(), e
.target.error.code); | 446 subtitle = Common.UIString('\'%s\' error %d', reader.fileName(), e.targe
t.error.code); |
| 447 } | 447 } |
| 448 this.updateStatus(subtitle); | 448 this.updateStatus(subtitle); |
| 449 } | 449 } |
| 450 | 450 |
| 451 /** | 451 /** |
| 452 * @override | 452 * @override |
| 453 * @param {string} text | 453 * @param {string} text |
| 454 */ | 454 */ |
| 455 write(text) { | 455 write(text) { |
| 456 this._jsonifiedProfile += text; | 456 this._jsonifiedProfile += text; |
| 457 } | 457 } |
| 458 | 458 |
| 459 /** | 459 /** |
| 460 * @override | 460 * @override |
| 461 */ | 461 */ |
| 462 close() { | 462 close() { |
| 463 } | 463 } |
| 464 | 464 |
| 465 /** | 465 /** |
| 466 * @override | 466 * @override |
| 467 */ | 467 */ |
| 468 dispose() { | 468 dispose() { |
| 469 this.removeTempFile(); | 469 this.removeTempFile(); |
| 470 } | 470 } |
| 471 | 471 |
| 472 /** | 472 /** |
| 473 * @override | 473 * @override |
| 474 * @param {!WebInspector.ProfileType.DataDisplayDelegate} panel | 474 * @param {!Profiler.ProfileType.DataDisplayDelegate} panel |
| 475 * @return {!WebInspector.ProfileSidebarTreeElement} | 475 * @return {!Profiler.ProfileSidebarTreeElement} |
| 476 */ | 476 */ |
| 477 createSidebarTreeElement(panel) { | 477 createSidebarTreeElement(panel) { |
| 478 return new WebInspector.ProfileSidebarTreeElement(panel, this, 'profile-side
bar-tree-item'); | 478 return new Profiler.ProfileSidebarTreeElement(panel, this, 'profile-sidebar-
tree-item'); |
| 479 } | 479 } |
| 480 | 480 |
| 481 /** | 481 /** |
| 482 * @override | 482 * @override |
| 483 * @return {boolean} | 483 * @return {boolean} |
| 484 */ | 484 */ |
| 485 canSaveToFile() { | 485 canSaveToFile() { |
| 486 return !this.fromFile() && this._protocolProfile; | 486 return !this.fromFile() && this._protocolProfile; |
| 487 } | 487 } |
| 488 | 488 |
| 489 /** | 489 /** |
| 490 * @override | 490 * @override |
| 491 */ | 491 */ |
| 492 saveToFile() { | 492 saveToFile() { |
| 493 var fileOutputStream = new WebInspector.FileOutputStream(); | 493 var fileOutputStream = new Bindings.FileOutputStream(); |
| 494 | 494 |
| 495 /** | 495 /** |
| 496 * @param {boolean} accepted | 496 * @param {boolean} accepted |
| 497 * @this {WebInspector.WritableProfileHeader} | 497 * @this {Profiler.WritableProfileHeader} |
| 498 */ | 498 */ |
| 499 function onOpenForSave(accepted) { | 499 function onOpenForSave(accepted) { |
| 500 if (!accepted) | 500 if (!accepted) |
| 501 return; | 501 return; |
| 502 function didRead(data) { | 502 function didRead(data) { |
| 503 if (data) | 503 if (data) |
| 504 fileOutputStream.write(data, fileOutputStream.close.bind(fileOutputStr
eam)); | 504 fileOutputStream.write(data, fileOutputStream.close.bind(fileOutputStr
eam)); |
| 505 else | 505 else |
| 506 fileOutputStream.close(); | 506 fileOutputStream.close(); |
| 507 } | 507 } |
| 508 if (this._failedToCreateTempFile) { | 508 if (this._failedToCreateTempFile) { |
| 509 WebInspector.console.error('Failed to open temp file with heap snapshot'
); | 509 Common.console.error('Failed to open temp file with heap snapshot'); |
| 510 fileOutputStream.close(); | 510 fileOutputStream.close(); |
| 511 } else if (this._tempFile) { | 511 } else if (this._tempFile) { |
| 512 this._tempFile.read(didRead); | 512 this._tempFile.read(didRead); |
| 513 } else { | 513 } else { |
| 514 this._onTempFileReady = onOpenForSave.bind(this, accepted); | 514 this._onTempFileReady = onOpenForSave.bind(this, accepted); |
| 515 } | 515 } |
| 516 } | 516 } |
| 517 this._fileName = this._fileName || | 517 this._fileName = this._fileName || |
| 518 `${this._profileType.typeName()}-${new Date().toISO8601Compact()}${this.
_profileType.fileExtension()}`; | 518 `${this._profileType.typeName()}-${new Date().toISO8601Compact()}${this.
_profileType.fileExtension()}`; |
| 519 fileOutputStream.open(this._fileName, onOpenForSave.bind(this)); | 519 fileOutputStream.open(this._fileName, onOpenForSave.bind(this)); |
| 520 } | 520 } |
| 521 | 521 |
| 522 /** | 522 /** |
| 523 * @override | 523 * @override |
| 524 * @param {!File} file | 524 * @param {!File} file |
| 525 */ | 525 */ |
| 526 loadFromFile(file) { | 526 loadFromFile(file) { |
| 527 this.updateStatus(WebInspector.UIString('Loading\u2026'), true); | 527 this.updateStatus(Common.UIString('Loading\u2026'), true); |
| 528 var fileReader = new WebInspector.ChunkedFileReader(file, 10000000, this); | 528 var fileReader = new Bindings.ChunkedFileReader(file, 10000000, this); |
| 529 fileReader.start(this); | 529 fileReader.start(this); |
| 530 } | 530 } |
| 531 | 531 |
| 532 /** | 532 /** |
| 533 * @param {*} profile | 533 * @param {*} profile |
| 534 */ | 534 */ |
| 535 setProtocolProfile(profile) { | 535 setProtocolProfile(profile) { |
| 536 this._protocolProfile = profile; | 536 this._protocolProfile = profile; |
| 537 this._saveProfileDataToTempFile(profile); | 537 this._saveProfileDataToTempFile(profile); |
| 538 if (this.canSaveToFile()) | 538 if (this.canSaveToFile()) |
| 539 this.dispatchEventToListeners(WebInspector.ProfileHeader.Events.ProfileRec
eived); | 539 this.dispatchEventToListeners(Profiler.ProfileHeader.Events.ProfileReceive
d); |
| 540 } | 540 } |
| 541 | 541 |
| 542 /** | 542 /** |
| 543 * @param {*} data | 543 * @param {*} data |
| 544 */ | 544 */ |
| 545 _saveProfileDataToTempFile(data) { | 545 _saveProfileDataToTempFile(data) { |
| 546 var serializedData = JSON.stringify(data); | 546 var serializedData = JSON.stringify(data); |
| 547 | 547 |
| 548 /** | 548 /** |
| 549 * @this {WebInspector.WritableProfileHeader} | 549 * @this {Profiler.WritableProfileHeader} |
| 550 */ | 550 */ |
| 551 function didCreateTempFile(tempFile) { | 551 function didCreateTempFile(tempFile) { |
| 552 this._writeToTempFile(tempFile, serializedData); | 552 this._writeToTempFile(tempFile, serializedData); |
| 553 } | 553 } |
| 554 WebInspector.TempFile.create('cpu-profiler', String(this.uid)).then(didCreat
eTempFile.bind(this)); | 554 Bindings.TempFile.create('cpu-profiler', String(this.uid)).then(didCreateTem
pFile.bind(this)); |
| 555 } | 555 } |
| 556 | 556 |
| 557 /** | 557 /** |
| 558 * @param {?WebInspector.TempFile} tempFile | 558 * @param {?Bindings.TempFile} tempFile |
| 559 * @param {string} serializedData | 559 * @param {string} serializedData |
| 560 */ | 560 */ |
| 561 _writeToTempFile(tempFile, serializedData) { | 561 _writeToTempFile(tempFile, serializedData) { |
| 562 this._tempFile = tempFile; | 562 this._tempFile = tempFile; |
| 563 if (!tempFile) { | 563 if (!tempFile) { |
| 564 this._failedToCreateTempFile = true; | 564 this._failedToCreateTempFile = true; |
| 565 this._notifyTempFileReady(); | 565 this._notifyTempFileReady(); |
| 566 return; | 566 return; |
| 567 } | 567 } |
| 568 /** | 568 /** |
| 569 * @param {number} fileSize | 569 * @param {number} fileSize |
| 570 * @this {WebInspector.WritableProfileHeader} | 570 * @this {Profiler.WritableProfileHeader} |
| 571 */ | 571 */ |
| 572 function didWriteToTempFile(fileSize) { | 572 function didWriteToTempFile(fileSize) { |
| 573 if (!fileSize) | 573 if (!fileSize) |
| 574 this._failedToCreateTempFile = true; | 574 this._failedToCreateTempFile = true; |
| 575 tempFile.finishWriting(); | 575 tempFile.finishWriting(); |
| 576 this._notifyTempFileReady(); | 576 this._notifyTempFileReady(); |
| 577 } | 577 } |
| 578 tempFile.write([serializedData], didWriteToTempFile.bind(this)); | 578 tempFile.write([serializedData], didWriteToTempFile.bind(this)); |
| 579 } | 579 } |
| 580 | 580 |
| 581 _notifyTempFileReady() { | 581 _notifyTempFileReady() { |
| 582 if (this._onTempFileReady) { | 582 if (this._onTempFileReady) { |
| 583 this._onTempFileReady(); | 583 this._onTempFileReady(); |
| 584 this._onTempFileReady = null; | 584 this._onTempFileReady = null; |
| 585 } | 585 } |
| 586 } | 586 } |
| 587 }; | 587 }; |
| OLD | NEW |