Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 */ | 34 */ |
| 35 Profiler.HeapSnapshotView = class extends UI.SimpleView { | 35 Profiler.HeapSnapshotView = class extends UI.SimpleView { |
| 36 /** | 36 /** |
| 37 * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate | 37 * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate |
| 38 * @param {!Profiler.HeapProfileHeader} profile | 38 * @param {!Profiler.HeapProfileHeader} profile |
| 39 */ | 39 */ |
| 40 constructor(dataDisplayDelegate, profile) { | 40 constructor(dataDisplayDelegate, profile) { |
| 41 super(Common.UIString('Heap Snapshot')); | 41 super(Common.UIString('Heap Snapshot')); |
| 42 | 42 |
| 43 this.element.classList.add('heap-snapshot-view'); | 43 this.element.classList.add('heap-snapshot-view'); |
| 44 this._profile = profile; | |
| 44 | 45 |
| 45 profile.profileType().addEventListener( | 46 profile.profileType().addEventListener( |
| 46 Profiler.HeapSnapshotProfileType.SnapshotReceived, this._onReceiveSnapsh ot, this); | 47 Profiler.HeapSnapshotProfileType.SnapshotReceived, this._onReceiveSnapsh ot, this); |
| 47 profile.profileType().addEventListener( | 48 profile.profileType().addEventListener( |
| 48 Profiler.ProfileType.Events.RemoveProfileHeader, this._onProfileHeaderRe moved, this); | 49 Profiler.ProfileType.Events.RemoveProfileHeader, this._onProfileHeaderRe moved, this); |
| 49 | 50 |
| 50 var isHeapTimeline = profile.profileType().id === Profiler.TrackingHeapSnaps hotProfileType.TypeId; | 51 var isHeapTimeline = profile.profileType().id === Profiler.TrackingHeapSnaps hotProfileType.TypeId; |
| 51 if (isHeapTimeline) { | 52 if (isHeapTimeline) { |
| 52 this._trackingOverviewGrid = new Profiler.HeapTrackingOverviewGrid(profile ); | 53 this._trackingOverviewGrid = new Profiler.HeapTrackingOverviewGrid(profile ); |
| 53 this._trackingOverviewGrid.addEventListener( | 54 this._trackingOverviewGrid.addEventListener( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 this._objectDetailsView.element.appendChild(retainmentViewHeader); | 117 this._objectDetailsView.element.appendChild(retainmentViewHeader); |
| 117 this._retainmentWidget.show(this._objectDetailsView.element); | 118 this._retainmentWidget.show(this._objectDetailsView.element); |
| 118 } | 119 } |
| 119 this._splitWidget.hideDefaultResizer(); | 120 this._splitWidget.hideDefaultResizer(); |
| 120 this._splitWidget.installResizer(splitWidgetResizer); | 121 this._splitWidget.installResizer(splitWidgetResizer); |
| 121 | 122 |
| 122 this._retainmentDataGrid.addEventListener(UI.DataGrid.Events.SelectedNode, t his._inspectedObjectChanged, this); | 123 this._retainmentDataGrid.addEventListener(UI.DataGrid.Events.SelectedNode, t his._inspectedObjectChanged, this); |
| 123 this._retainmentDataGrid.reset(); | 124 this._retainmentDataGrid.reset(); |
| 124 | 125 |
| 125 this._perspectives = []; | 126 this._perspectives = []; |
| 127 this._comparisonPerspective = new Profiler.HeapSnapshotView.ComparisonPerspe ctive(); | |
| 126 this._perspectives.push(new Profiler.HeapSnapshotView.SummaryPerspective()); | 128 this._perspectives.push(new Profiler.HeapSnapshotView.SummaryPerspective()); |
| 127 if (profile.profileType() !== Profiler.ProfileTypeRegistry.instance.tracking HeapSnapshotProfileType) | 129 if (profile.profileType() !== Profiler.ProfileTypeRegistry.instance.tracking HeapSnapshotProfileType) |
| 128 this._perspectives.push(new Profiler.HeapSnapshotView.ComparisonPerspectiv e()); | 130 this._perspectives.push(this._comparisonPerspective); |
| 129 this._perspectives.push(new Profiler.HeapSnapshotView.ContainmentPerspective ()); | 131 this._perspectives.push(new Profiler.HeapSnapshotView.ContainmentPerspective ()); |
| 130 if (this._allocationWidget) | 132 if (this._allocationWidget) |
| 131 this._perspectives.push(new Profiler.HeapSnapshotView.AllocationPerspectiv e()); | 133 this._perspectives.push(new Profiler.HeapSnapshotView.AllocationPerspectiv e()); |
| 132 this._perspectives.push(new Profiler.HeapSnapshotView.StatisticsPerspective( )); | 134 this._perspectives.push(new Profiler.HeapSnapshotView.StatisticsPerspective( )); |
| 133 | 135 |
| 134 this._perspectiveSelect = new UI.ToolbarComboBox(this._onSelectedPerspective Changed.bind(this)); | 136 this._perspectiveSelect = new UI.ToolbarComboBox(this._onSelectedPerspective Changed.bind(this)); |
| 135 for (var i = 0; i < this._perspectives.length; ++i) | 137 this._updatePerspectiveOptions(); |
| 136 this._perspectiveSelect.createOption(this._perspectives[i].title()); | |
| 137 | |
| 138 this._profile = profile; | |
| 139 | 138 |
| 140 this._baseSelect = new UI.ToolbarComboBox(this._changeBase.bind(this)); | 139 this._baseSelect = new UI.ToolbarComboBox(this._changeBase.bind(this)); |
| 141 this._baseSelect.setVisible(false); | 140 this._baseSelect.setVisible(false); |
| 142 this._updateBaseOptions(); | 141 this._updateBaseOptions(); |
| 143 | 142 |
| 144 this._filterSelect = new UI.ToolbarComboBox(this._changeFilter.bind(this)); | 143 this._filterSelect = new UI.ToolbarComboBox(this._changeFilter.bind(this)); |
| 145 this._filterSelect.setVisible(false); | 144 this._filterSelect.setVisible(false); |
| 146 this._updateFilterOptions(); | 145 this._updateFilterOptions(); |
| 147 | 146 |
| 148 this._classNameFilter = new UI.ToolbarInput('Class filter'); | 147 this._classNameFilter = new UI.ToolbarInput('Class filter'); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 this._allocationStackView.clear(); | 481 this._allocationStackView.clear(); |
| 483 this._retainmentDataGrid.reset(); | 482 this._retainmentDataGrid.reset(); |
| 484 } | 483 } |
| 485 } | 484 } |
| 486 | 485 |
| 487 /** | 486 /** |
| 488 * @param {string} perspectiveTitle | 487 * @param {string} perspectiveTitle |
| 489 * @param {function()} callback | 488 * @param {function()} callback |
| 490 */ | 489 */ |
| 491 _changePerspectiveAndWait(perspectiveTitle, callback) { | 490 _changePerspectiveAndWait(perspectiveTitle, callback) { |
| 492 var perspectiveIndex = null; | 491 const perspectiveIndex = this._perspectives.findIndex(perspective => perspec tive.title() === perspectiveTitle); |
| 493 for (var i = 0; i < this._perspectives.length; ++i) { | 492 if (perspectiveIndex === -1 || this._currentPerspectiveIndex === perspective Index) { |
| 494 if (this._perspectives[i].title() === perspectiveTitle) { | |
| 495 perspectiveIndex = i; | |
| 496 break; | |
| 497 } | |
| 498 } | |
| 499 if (this._currentPerspectiveIndex === perspectiveIndex || perspectiveIndex = == null) { | |
| 500 setTimeout(callback, 0); | 493 setTimeout(callback, 0); |
| 501 return; | 494 return; |
| 502 } | 495 } |
| 503 | 496 |
| 504 /** | 497 /** |
| 498 * @param {!Common.Event} event | |
| 505 * @this {Profiler.HeapSnapshotView} | 499 * @this {Profiler.HeapSnapshotView} |
| 506 */ | 500 */ |
| 507 function dataGridContentShown(event) { | 501 function dataGridContentShown(event) { |
| 508 var dataGrid = event.data; | 502 var dataGrid = event.data; |
| 509 dataGrid.removeEventListener( | 503 dataGrid.removeEventListener( |
| 510 Profiler.HeapSnapshotSortableDataGrid.Events.ContentShown, dataGridCon tentShown, this); | 504 Profiler.HeapSnapshotSortableDataGrid.Events.ContentShown, dataGridCon tentShown, this); |
| 511 if (dataGrid === this._dataGrid) | 505 if (dataGrid === this._dataGrid) |
| 512 callback(); | 506 callback(); |
| 513 } | 507 } |
| 514 this._perspectives[perspectiveIndex].masterGrid(this).addEventListener( | 508 this._perspectives[perspectiveIndex].masterGrid(this).addEventListener( |
| 515 Profiler.HeapSnapshotSortableDataGrid.Events.ContentShown, dataGridConte ntShown, this); | 509 Profiler.HeapSnapshotSortableDataGrid.Events.ContentShown, dataGridConte ntShown, this); |
| 516 | 510 |
| 517 this._perspectiveSelect.setSelectedIndex(perspectiveIndex); | 511 const option = this._perspectiveSelect.options().find(option => option.value === perspectiveIndex); |
|
caseq
2016/12/14 00:43:37
nit: I'd rather have a perspective option associat
alph
2016/12/14 22:38:55
I tried that, and it doesn't seem to make the code
| |
| 512 this._perspectiveSelect.select(/** @type {!Element} */ (option)); | |
| 518 this._changePerspective(perspectiveIndex); | 513 this._changePerspective(perspectiveIndex); |
| 519 } | 514 } |
| 520 | 515 |
| 521 _updateDataSourceAndView() { | 516 _updateDataSourceAndView() { |
| 522 var dataGrid = this._dataGrid; | 517 var dataGrid = this._dataGrid; |
| 523 if (!dataGrid || dataGrid.snapshot) | 518 if (!dataGrid || dataGrid.snapshot) |
| 524 return; | 519 return; |
| 525 | 520 |
| 526 this._profile._loadPromise.then(didLoadSnapshot.bind(this)); | 521 this._profile._loadPromise.then(didLoadSnapshot.bind(this)); |
| 527 | 522 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 543 /** | 538 /** |
| 544 * @this {Profiler.HeapSnapshotView} | 539 * @this {Profiler.HeapSnapshotView} |
| 545 */ | 540 */ |
| 546 function didLoadBaseSnapshot(baseSnapshotProxy) { | 541 function didLoadBaseSnapshot(baseSnapshotProxy) { |
| 547 if (this._diffDataGrid.baseSnapshot !== baseSnapshotProxy) | 542 if (this._diffDataGrid.baseSnapshot !== baseSnapshotProxy) |
| 548 this._diffDataGrid.setBaseDataSource(baseSnapshotProxy); | 543 this._diffDataGrid.setBaseDataSource(baseSnapshotProxy); |
| 549 } | 544 } |
| 550 } | 545 } |
| 551 | 546 |
| 552 _onSelectedPerspectiveChanged(event) { | 547 _onSelectedPerspectiveChanged(event) { |
| 553 this._changePerspective(event.target.selectedIndex); | 548 this._changePerspective(event.target.selectedOptions[0].value); |
| 554 } | 549 } |
| 555 | 550 |
| 556 /** | 551 /** |
| 557 * @param {number} selectedIndex | 552 * @param {number} selectedIndex |
| 558 */ | 553 */ |
| 559 _changePerspective(selectedIndex) { | 554 _changePerspective(selectedIndex) { |
| 560 if (selectedIndex === this._currentPerspectiveIndex) | 555 if (selectedIndex === this._currentPerspectiveIndex) |
| 561 return; | 556 return; |
| 562 | 557 |
| 563 this._currentPerspectiveIndex = selectedIndex; | 558 this._currentPerspectiveIndex = selectedIndex; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 620 } | 615 } |
| 621 | 616 |
| 622 _resolveObjectForPopover(element, showCallback, objectGroupName) { | 617 _resolveObjectForPopover(element, showCallback, objectGroupName) { |
| 623 if (!this._profile.target()) | 618 if (!this._profile.target()) |
| 624 return; | 619 return; |
| 625 if (!element.node) | 620 if (!element.node) |
| 626 return; | 621 return; |
| 627 element.node.queryObjectContent(this._profile.target(), showCallback, object GroupName); | 622 element.node.queryObjectContent(this._profile.target(), showCallback, object GroupName); |
| 628 } | 623 } |
| 629 | 624 |
| 625 _updatePerspectiveOptions() { | |
| 626 const multipleSnapshots = this._profiles().length > 1; | |
| 627 this._perspectiveSelect.removeOptions(); | |
| 628 this._perspectives.forEach((perspective, index) => { | |
| 629 if (multipleSnapshots || perspective !== this._comparisonPerspective) | |
| 630 this._perspectiveSelect.createOption(perspective.title(), '', String(ind ex)); | |
| 631 }); | |
| 632 } | |
| 633 | |
| 630 _updateBaseOptions() { | 634 _updateBaseOptions() { |
| 631 var list = this._profiles(); | 635 var list = this._profiles(); |
| 632 // We're assuming that snapshots can only be added. | 636 // We're assuming that snapshots can only be added. |
| 633 if (this._baseSelect.size() === list.length) | 637 if (this._baseSelect.size() === list.length) |
| 634 return; | 638 return; |
| 635 | 639 |
| 636 for (var i = this._baseSelect.size(), n = list.length; i < n; ++i) { | 640 for (var i = this._baseSelect.size(), n = list.length; i < n; ++i) { |
| 637 var title = list[i].title; | 641 var title = list[i].title; |
| 638 this._baseSelect.createOption(title); | 642 this._baseSelect.createOption(title); |
| 639 } | 643 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 652 var title = list[i].title; | 656 var title = list[i].title; |
| 653 if (!i) | 657 if (!i) |
| 654 title = Common.UIString('Objects allocated before %s', title); | 658 title = Common.UIString('Objects allocated before %s', title); |
| 655 else | 659 else |
| 656 title = Common.UIString('Objects allocated between %s and %s', list[i - 1].title, title); | 660 title = Common.UIString('Objects allocated between %s and %s', list[i - 1].title, title); |
| 657 this._filterSelect.createOption(title); | 661 this._filterSelect.createOption(title); |
| 658 } | 662 } |
| 659 } | 663 } |
| 660 | 664 |
| 661 _updateControls() { | 665 _updateControls() { |
| 666 this._updatePerspectiveOptions(); | |
| 662 this._updateBaseOptions(); | 667 this._updateBaseOptions(); |
| 663 this._updateFilterOptions(); | 668 this._updateFilterOptions(); |
| 664 } | 669 } |
| 665 | 670 |
| 666 /** | 671 /** |
| 667 * @param {!Common.Event} event | 672 * @param {!Common.Event} event |
| 668 */ | 673 */ |
| 669 _onReceiveSnapshot(event) { | 674 _onReceiveSnapshot(event) { |
| 670 this._updateControls(); | 675 this._updateControls(); |
| 671 } | 676 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 766 /** | 771 /** |
| 767 * @override | 772 * @override |
| 768 * @param {!Profiler.HeapSnapshotView} heapSnapshotView | 773 * @param {!Profiler.HeapSnapshotView} heapSnapshotView |
| 769 */ | 774 */ |
| 770 activate(heapSnapshotView) { | 775 activate(heapSnapshotView) { |
| 771 heapSnapshotView._splitWidget.setMainWidget(heapSnapshotView._constructorsWi dget); | 776 heapSnapshotView._splitWidget.setMainWidget(heapSnapshotView._constructorsWi dget); |
| 772 heapSnapshotView._splitWidget.setSidebarWidget(heapSnapshotView._objectDetai lsView); | 777 heapSnapshotView._splitWidget.setSidebarWidget(heapSnapshotView._objectDetai lsView); |
| 773 heapSnapshotView._splitWidget.show(heapSnapshotView._searchableView.element) ; | 778 heapSnapshotView._splitWidget.show(heapSnapshotView._searchableView.element) ; |
| 774 heapSnapshotView._filterSelect.setVisible(true); | 779 heapSnapshotView._filterSelect.setVisible(true); |
| 775 heapSnapshotView._classNameFilter.setVisible(true); | 780 heapSnapshotView._classNameFilter.setVisible(true); |
| 776 if (heapSnapshotView._trackingOverviewGrid) { | 781 if (!heapSnapshotView._trackingOverviewGrid) |
| 777 heapSnapshotView._trackingOverviewGrid.show( | 782 return; |
| 778 heapSnapshotView._searchableView.element, heapSnapshotView._splitWidge t.element); | 783 heapSnapshotView._trackingOverviewGrid.show( |
| 779 heapSnapshotView._trackingOverviewGrid.update(); | 784 heapSnapshotView._searchableView.element, heapSnapshotView._splitWidget. element); |
| 780 heapSnapshotView._trackingOverviewGrid._updateGrid(); | 785 heapSnapshotView._trackingOverviewGrid.update(); |
| 781 } | 786 heapSnapshotView._trackingOverviewGrid._updateGrid(); |
| 782 } | 787 } |
| 783 | 788 |
| 784 /** | 789 /** |
| 785 * @override | 790 * @override |
| 786 * @param {!Profiler.HeapSnapshotView} heapSnapshotView | 791 * @param {!Profiler.HeapSnapshotView} heapSnapshotView |
| 787 * @return {?UI.DataGrid} | 792 * @return {?UI.DataGrid} |
| 788 */ | 793 */ |
| 789 masterGrid(heapSnapshotView) { | 794 masterGrid(heapSnapshotView) { |
| 790 return heapSnapshotView._constructorsDataGrid; | 795 return heapSnapshotView._constructorsDataGrid; |
| 791 } | 796 } |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2091 var name = frameDiv.createChild('div'); | 2096 var name = frameDiv.createChild('div'); |
| 2092 name.textContent = UI.beautifyFunctionName(frame.functionName); | 2097 name.textContent = UI.beautifyFunctionName(frame.functionName); |
| 2093 if (frame.scriptId) { | 2098 if (frame.scriptId) { |
| 2094 var urlElement = this._linkifier.linkifyScriptLocation( | 2099 var urlElement = this._linkifier.linkifyScriptLocation( |
| 2095 this._target, String(frame.scriptId), frame.scriptName, frame.line - 1, frame.column - 1); | 2100 this._target, String(frame.scriptId), frame.scriptName, frame.line - 1, frame.column - 1); |
| 2096 frameDiv.appendChild(urlElement); | 2101 frameDiv.appendChild(urlElement); |
| 2097 } | 2102 } |
| 2098 } | 2103 } |
| 2099 } | 2104 } |
| 2100 }; | 2105 }; |
| OLD | NEW |