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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/profiler/HeapSnapshotView.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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 /* 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 10 matching lines...) Expand all
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 /** 30 /**
31 * @implements {WebInspector.ProfileType.DataDisplayDelegate} 31 * @implements {Profiler.ProfileType.DataDisplayDelegate}
32 * @implements {WebInspector.Searchable} 32 * @implements {UI.Searchable}
33 * @unrestricted 33 * @unrestricted
34 */ 34 */
35 WebInspector.HeapSnapshotView = class extends WebInspector.SimpleView { 35 Profiler.HeapSnapshotView = class extends UI.SimpleView {
36 /** 36 /**
37 * @param {!WebInspector.ProfileType.DataDisplayDelegate} dataDisplayDelegate 37 * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate
38 * @param {!WebInspector.HeapProfileHeader} profile 38 * @param {!Profiler.HeapProfileHeader} profile
39 */ 39 */
40 constructor(dataDisplayDelegate, profile) { 40 constructor(dataDisplayDelegate, profile) {
41 super(WebInspector.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 44
45 profile.profileType().addEventListener( 45 profile.profileType().addEventListener(
46 WebInspector.HeapSnapshotProfileType.SnapshotReceived, this._onReceiveSn apshot, this); 46 Profiler.HeapSnapshotProfileType.SnapshotReceived, this._onReceiveSnapsh ot, this);
47 profile.profileType().addEventListener( 47 profile.profileType().addEventListener(
48 WebInspector.ProfileType.Events.RemoveProfileHeader, this._onProfileHead erRemoved, this); 48 Profiler.ProfileType.Events.RemoveProfileHeader, this._onProfileHeaderRe moved, this);
49 49
50 var isHeapTimeline = profile.profileType().id === WebInspector.TrackingHeapS napshotProfileType.TypeId; 50 var isHeapTimeline = profile.profileType().id === Profiler.TrackingHeapSnaps hotProfileType.TypeId;
51 if (isHeapTimeline) { 51 if (isHeapTimeline) {
52 this._trackingOverviewGrid = new WebInspector.HeapTrackingOverviewGrid(pro file); 52 this._trackingOverviewGrid = new Profiler.HeapTrackingOverviewGrid(profile );
53 this._trackingOverviewGrid.addEventListener( 53 this._trackingOverviewGrid.addEventListener(
54 WebInspector.HeapTrackingOverviewGrid.IdsRangeChanged, this._onIdsRang eChanged.bind(this)); 54 Profiler.HeapTrackingOverviewGrid.IdsRangeChanged, this._onIdsRangeCha nged.bind(this));
55 } 55 }
56 56
57 this._parentDataDisplayDelegate = dataDisplayDelegate; 57 this._parentDataDisplayDelegate = dataDisplayDelegate;
58 58
59 this._searchableView = new WebInspector.SearchableView(this); 59 this._searchableView = new UI.SearchableView(this);
60 this._searchableView.show(this.element); 60 this._searchableView.show(this.element);
61 61
62 this._splitWidget = new WebInspector.SplitWidget(false, true, 'heapSnapshotS plitViewState', 200, 200); 62 this._splitWidget = new UI.SplitWidget(false, true, 'heapSnapshotSplitViewSt ate', 200, 200);
63 this._splitWidget.show(this._searchableView.element); 63 this._splitWidget.show(this._searchableView.element);
64 64
65 this._containmentDataGrid = new WebInspector.HeapSnapshotContainmentDataGrid (this); 65 this._containmentDataGrid = new Profiler.HeapSnapshotContainmentDataGrid(thi s);
66 this._containmentDataGrid.addEventListener(WebInspector.DataGrid.Events.Sele ctedNode, this._selectionChanged, this); 66 this._containmentDataGrid.addEventListener(UI.DataGrid.Events.SelectedNode, this._selectionChanged, this);
67 this._containmentWidget = this._containmentDataGrid.asWidget(); 67 this._containmentWidget = this._containmentDataGrid.asWidget();
68 this._containmentWidget.setMinimumSize(50, 25); 68 this._containmentWidget.setMinimumSize(50, 25);
69 69
70 this._statisticsView = new WebInspector.HeapSnapshotStatisticsView(); 70 this._statisticsView = new Profiler.HeapSnapshotStatisticsView();
71 71
72 this._constructorsDataGrid = new WebInspector.HeapSnapshotConstructorsDataGr id(this); 72 this._constructorsDataGrid = new Profiler.HeapSnapshotConstructorsDataGrid(t his);
73 this._constructorsDataGrid.addEventListener( 73 this._constructorsDataGrid.addEventListener(
74 WebInspector.DataGrid.Events.SelectedNode, this._selectionChanged, this) ; 74 UI.DataGrid.Events.SelectedNode, this._selectionChanged, this);
75 this._constructorsWidget = this._constructorsDataGrid.asWidget(); 75 this._constructorsWidget = this._constructorsDataGrid.asWidget();
76 this._constructorsWidget.setMinimumSize(50, 25); 76 this._constructorsWidget.setMinimumSize(50, 25);
77 77
78 this._diffDataGrid = new WebInspector.HeapSnapshotDiffDataGrid(this); 78 this._diffDataGrid = new Profiler.HeapSnapshotDiffDataGrid(this);
79 this._diffDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNod e, this._selectionChanged, this); 79 this._diffDataGrid.addEventListener(UI.DataGrid.Events.SelectedNode, this._s electionChanged, this);
80 this._diffWidget = this._diffDataGrid.asWidget(); 80 this._diffWidget = this._diffDataGrid.asWidget();
81 this._diffWidget.setMinimumSize(50, 25); 81 this._diffWidget.setMinimumSize(50, 25);
82 82
83 if (isHeapTimeline && WebInspector.moduleSetting('recordAllocationStacks').g et()) { 83 if (isHeapTimeline && Common.moduleSetting('recordAllocationStacks').get()) {
84 this._allocationDataGrid = new WebInspector.AllocationDataGrid(profile.tar get(), this); 84 this._allocationDataGrid = new Profiler.AllocationDataGrid(profile.target( ), this);
85 this._allocationDataGrid.addEventListener( 85 this._allocationDataGrid.addEventListener(
86 WebInspector.DataGrid.Events.SelectedNode, this._onSelectAllocationNod e, this); 86 UI.DataGrid.Events.SelectedNode, this._onSelectAllocationNode, this);
87 this._allocationWidget = this._allocationDataGrid.asWidget(); 87 this._allocationWidget = this._allocationDataGrid.asWidget();
88 this._allocationWidget.setMinimumSize(50, 25); 88 this._allocationWidget.setMinimumSize(50, 25);
89 89
90 this._allocationStackView = new WebInspector.HeapAllocationStackView(profi le.target()); 90 this._allocationStackView = new Profiler.HeapAllocationStackView(profile.t arget());
91 this._allocationStackView.setMinimumSize(50, 25); 91 this._allocationStackView.setMinimumSize(50, 25);
92 92
93 this._tabbedPane = new WebInspector.TabbedPane(); 93 this._tabbedPane = new UI.TabbedPane();
94 } 94 }
95 95
96 this._retainmentDataGrid = new WebInspector.HeapSnapshotRetainmentDataGrid(t his); 96 this._retainmentDataGrid = new Profiler.HeapSnapshotRetainmentDataGrid(this) ;
97 this._retainmentWidget = this._retainmentDataGrid.asWidget(); 97 this._retainmentWidget = this._retainmentDataGrid.asWidget();
98 this._retainmentWidget.setMinimumSize(50, 21); 98 this._retainmentWidget.setMinimumSize(50, 21);
99 this._retainmentWidget.element.classList.add('retaining-paths-view'); 99 this._retainmentWidget.element.classList.add('retaining-paths-view');
100 100
101 var splitWidgetResizer; 101 var splitWidgetResizer;
102 if (this._allocationStackView) { 102 if (this._allocationStackView) {
103 this._tabbedPane = new WebInspector.TabbedPane(); 103 this._tabbedPane = new UI.TabbedPane();
104 104
105 this._tabbedPane.appendTab('retainers', WebInspector.UIString('Retainers') , this._retainmentWidget); 105 this._tabbedPane.appendTab('retainers', Common.UIString('Retainers'), this ._retainmentWidget);
106 this._tabbedPane.appendTab( 106 this._tabbedPane.appendTab(
107 'allocation-stack', WebInspector.UIString('Allocation stack'), this._a llocationStackView); 107 'allocation-stack', Common.UIString('Allocation stack'), this._allocat ionStackView);
108 108
109 splitWidgetResizer = this._tabbedPane.headerElement(); 109 splitWidgetResizer = this._tabbedPane.headerElement();
110 this._objectDetailsView = this._tabbedPane; 110 this._objectDetailsView = this._tabbedPane;
111 } else { 111 } else {
112 var retainmentViewHeader = createElementWithClass('div', 'heap-snapshot-vi ew-resizer'); 112 var retainmentViewHeader = createElementWithClass('div', 'heap-snapshot-vi ew-resizer');
113 var retainingPathsTitleDiv = retainmentViewHeader.createChild('div', 'titl e'); 113 var retainingPathsTitleDiv = retainmentViewHeader.createChild('div', 'titl e');
114 var retainingPathsTitle = retainingPathsTitleDiv.createChild('span'); 114 var retainingPathsTitle = retainingPathsTitleDiv.createChild('span');
115 retainingPathsTitle.textContent = WebInspector.UIString('Retainers'); 115 retainingPathsTitle.textContent = Common.UIString('Retainers');
116 116
117 splitWidgetResizer = retainmentViewHeader; 117 splitWidgetResizer = retainmentViewHeader;
118 this._objectDetailsView = new WebInspector.VBox(); 118 this._objectDetailsView = new UI.VBox();
119 this._objectDetailsView.element.appendChild(retainmentViewHeader); 119 this._objectDetailsView.element.appendChild(retainmentViewHeader);
120 this._retainmentWidget.show(this._objectDetailsView.element); 120 this._retainmentWidget.show(this._objectDetailsView.element);
121 } 121 }
122 this._splitWidget.hideDefaultResizer(); 122 this._splitWidget.hideDefaultResizer();
123 this._splitWidget.installResizer(splitWidgetResizer); 123 this._splitWidget.installResizer(splitWidgetResizer);
124 124
125 this._retainmentDataGrid.addEventListener( 125 this._retainmentDataGrid.addEventListener(
126 WebInspector.DataGrid.Events.SelectedNode, this._inspectedObjectChanged, this); 126 UI.DataGrid.Events.SelectedNode, this._inspectedObjectChanged, this);
127 this._retainmentDataGrid.reset(); 127 this._retainmentDataGrid.reset();
128 128
129 this._perspectives = []; 129 this._perspectives = [];
130 this._perspectives.push(new WebInspector.HeapSnapshotView.SummaryPerspective ()); 130 this._perspectives.push(new Profiler.HeapSnapshotView.SummaryPerspective());
131 if (profile.profileType() !== WebInspector.ProfileTypeRegistry.instance.trac kingHeapSnapshotProfileType) 131 if (profile.profileType() !== Profiler.ProfileTypeRegistry.instance.tracking HeapSnapshotProfileType)
132 this._perspectives.push(new WebInspector.HeapSnapshotView.ComparisonPerspe ctive()); 132 this._perspectives.push(new Profiler.HeapSnapshotView.ComparisonPerspectiv e());
133 this._perspectives.push(new WebInspector.HeapSnapshotView.ContainmentPerspec tive()); 133 this._perspectives.push(new Profiler.HeapSnapshotView.ContainmentPerspective ());
134 if (this._allocationWidget) 134 if (this._allocationWidget)
135 this._perspectives.push(new WebInspector.HeapSnapshotView.AllocationPerspe ctive()); 135 this._perspectives.push(new Profiler.HeapSnapshotView.AllocationPerspectiv e());
136 this._perspectives.push(new WebInspector.HeapSnapshotView.StatisticsPerspect ive()); 136 this._perspectives.push(new Profiler.HeapSnapshotView.StatisticsPerspective( ));
137 137
138 this._perspectiveSelect = new WebInspector.ToolbarComboBox(this._onSelectedP erspectiveChanged.bind(this)); 138 this._perspectiveSelect = new UI.ToolbarComboBox(this._onSelectedPerspective Changed.bind(this));
139 for (var i = 0; i < this._perspectives.length; ++i) 139 for (var i = 0; i < this._perspectives.length; ++i)
140 this._perspectiveSelect.createOption(this._perspectives[i].title()); 140 this._perspectiveSelect.createOption(this._perspectives[i].title());
141 141
142 this._profile = profile; 142 this._profile = profile;
143 143
144 this._baseSelect = new WebInspector.ToolbarComboBox(this._changeBase.bind(th is)); 144 this._baseSelect = new UI.ToolbarComboBox(this._changeBase.bind(this));
145 this._baseSelect.setVisible(false); 145 this._baseSelect.setVisible(false);
146 this._updateBaseOptions(); 146 this._updateBaseOptions();
147 147
148 this._filterSelect = new WebInspector.ToolbarComboBox(this._changeFilter.bin d(this)); 148 this._filterSelect = new UI.ToolbarComboBox(this._changeFilter.bind(this));
149 this._filterSelect.setVisible(false); 149 this._filterSelect.setVisible(false);
150 this._updateFilterOptions(); 150 this._updateFilterOptions();
151 151
152 this._classNameFilter = new WebInspector.ToolbarInput('Class filter'); 152 this._classNameFilter = new UI.ToolbarInput('Class filter');
153 this._classNameFilter.setVisible(false); 153 this._classNameFilter.setVisible(false);
154 this._constructorsDataGrid.setNameFilter(this._classNameFilter); 154 this._constructorsDataGrid.setNameFilter(this._classNameFilter);
155 this._diffDataGrid.setNameFilter(this._classNameFilter); 155 this._diffDataGrid.setNameFilter(this._classNameFilter);
156 156
157 this._selectedSizeText = new WebInspector.ToolbarText(); 157 this._selectedSizeText = new UI.ToolbarText();
158 158
159 this._popoverHelper = new WebInspector.ObjectPopoverHelper( 159 this._popoverHelper = new Components.ObjectPopoverHelper(
160 this.element, this._getHoverAnchor.bind(this), this._resolveObjectForPop over.bind(this), undefined, true); 160 this.element, this._getHoverAnchor.bind(this), this._resolveObjectForPop over.bind(this), undefined, true);
161 161
162 this._currentPerspectiveIndex = 0; 162 this._currentPerspectiveIndex = 0;
163 this._currentPerspective = this._perspectives[0]; 163 this._currentPerspective = this._perspectives[0];
164 this._currentPerspective.activate(this); 164 this._currentPerspective.activate(this);
165 this._dataGrid = this._currentPerspective.masterGrid(this); 165 this._dataGrid = this._currentPerspective.masterGrid(this);
166 166
167 this._populate(); 167 this._populate();
168 this._searchThrottler = new WebInspector.Throttler(0); 168 this._searchThrottler = new Common.Throttler(0);
169 } 169 }
170 170
171 /** 171 /**
172 * @return {!WebInspector.SearchableView} 172 * @return {!UI.SearchableView}
173 */ 173 */
174 searchableView() { 174 searchableView() {
175 return this._searchableView; 175 return this._searchableView;
176 } 176 }
177 177
178 /** 178 /**
179 * @override 179 * @override
180 * @param {?WebInspector.ProfileHeader} profile 180 * @param {?Profiler.ProfileHeader} profile
181 * @return {?WebInspector.Widget} 181 * @return {?UI.Widget}
182 */ 182 */
183 showProfile(profile) { 183 showProfile(profile) {
184 return this._parentDataDisplayDelegate.showProfile(profile); 184 return this._parentDataDisplayDelegate.showProfile(profile);
185 } 185 }
186 186
187 /** 187 /**
188 * @override 188 * @override
189 * @param {!Protocol.HeapProfiler.HeapSnapshotObjectId} snapshotObjectId 189 * @param {!Protocol.HeapProfiler.HeapSnapshotObjectId} snapshotObjectId
190 * @param {string} perspectiveName 190 * @param {string} perspectiveName
191 */ 191 */
192 showObject(snapshotObjectId, perspectiveName) { 192 showObject(snapshotObjectId, perspectiveName) {
193 if (snapshotObjectId <= this._profile.maxJSObjectId) 193 if (snapshotObjectId <= this._profile.maxJSObjectId)
194 this.selectLiveObject(perspectiveName, snapshotObjectId); 194 this.selectLiveObject(perspectiveName, snapshotObjectId);
195 else 195 else
196 this._parentDataDisplayDelegate.showObject(snapshotObjectId, perspectiveNa me); 196 this._parentDataDisplayDelegate.showObject(snapshotObjectId, perspectiveNa me);
197 } 197 }
198 198
199 _populate() { 199 _populate() {
200 this._profile._loadPromise 200 this._profile._loadPromise
201 .then(heapSnapshotProxy => { 201 .then(heapSnapshotProxy => {
202 heapSnapshotProxy.getStatistics().then(this._gotStatistics.bind(this)) ; 202 heapSnapshotProxy.getStatistics().then(this._gotStatistics.bind(this)) ;
203 this._dataGrid.setDataSource(heapSnapshotProxy); 203 this._dataGrid.setDataSource(heapSnapshotProxy);
204 if (this._profile.profileType().id === WebInspector.TrackingHeapSnapsh otProfileType.TypeId && 204 if (this._profile.profileType().id === Profiler.TrackingHeapSnapshotPr ofileType.TypeId &&
205 this._profile.fromFile()) 205 this._profile.fromFile())
206 return heapSnapshotProxy.getSamples().then(samples => this._tracking OverviewGrid._setSamples(samples)); 206 return heapSnapshotProxy.getSamples().then(samples => this._tracking OverviewGrid._setSamples(samples));
207 }) 207 })
208 .then(_ => { 208 .then(_ => {
209 var list = this._profiles(); 209 var list = this._profiles();
210 var profileIndex = list.indexOf(this._profile); 210 var profileIndex = list.indexOf(this._profile);
211 this._baseSelect.setSelectedIndex(Math.max(0, profileIndex - 1)); 211 this._baseSelect.setSelectedIndex(Math.max(0, profileIndex - 1));
212 if (this._trackingOverviewGrid) 212 if (this._trackingOverviewGrid)
213 this._trackingOverviewGrid._updateGrid(); 213 this._trackingOverviewGrid._updateGrid();
214 }); 214 });
215 } 215 }
216 216
217 /** 217 /**
218 * @param {!WebInspector.HeapSnapshotCommon.Statistics} statistics 218 * @param {!Profiler.HeapSnapshotCommon.Statistics} statistics
219 */ 219 */
220 _gotStatistics(statistics) { 220 _gotStatistics(statistics) {
221 this._statisticsView.setTotal(statistics.total); 221 this._statisticsView.setTotal(statistics.total);
222 this._statisticsView.addRecord(statistics.code, WebInspector.UIString('Code' ), '#f77'); 222 this._statisticsView.addRecord(statistics.code, Common.UIString('Code'), '#f 77');
223 this._statisticsView.addRecord(statistics.strings, WebInspector.UIString('St rings'), '#5e5'); 223 this._statisticsView.addRecord(statistics.strings, Common.UIString('Strings' ), '#5e5');
224 this._statisticsView.addRecord(statistics.jsArrays, WebInspector.UIString('J S Arrays'), '#7af'); 224 this._statisticsView.addRecord(statistics.jsArrays, Common.UIString('JS Arra ys'), '#7af');
225 this._statisticsView.addRecord(statistics.native, WebInspector.UIString('Typ ed Arrays'), '#fc5'); 225 this._statisticsView.addRecord(statistics.native, Common.UIString('Typed Arr ays'), '#fc5');
226 this._statisticsView.addRecord(statistics.system, WebInspector.UIString('Sys tem Objects'), '#98f'); 226 this._statisticsView.addRecord(statistics.system, Common.UIString('System Ob jects'), '#98f');
227 this._statisticsView.addRecord(statistics.total, WebInspector.UIString('Tota l')); 227 this._statisticsView.addRecord(statistics.total, Common.UIString('Total'));
228 } 228 }
229 229
230 /** 230 /**
231 * @param {!WebInspector.Event} event 231 * @param {!Common.Event} event
232 */ 232 */
233 _onIdsRangeChanged(event) { 233 _onIdsRangeChanged(event) {
234 var minId = event.data.minId; 234 var minId = event.data.minId;
235 var maxId = event.data.maxId; 235 var maxId = event.data.maxId;
236 this._selectedSizeText.setText(WebInspector.UIString('Selected size: %s', Nu mber.bytesToString(event.data.size))); 236 this._selectedSizeText.setText(Common.UIString('Selected size: %s', Number.b ytesToString(event.data.size)));
237 if (this._constructorsDataGrid.snapshot) 237 if (this._constructorsDataGrid.snapshot)
238 this._constructorsDataGrid.setSelectionRange(minId, maxId); 238 this._constructorsDataGrid.setSelectionRange(minId, maxId);
239 } 239 }
240 240
241 /** 241 /**
242 * @override 242 * @override
243 * @return {!Array.<!WebInspector.ToolbarItem>} 243 * @return {!Array.<!UI.ToolbarItem>}
244 */ 244 */
245 syncToolbarItems() { 245 syncToolbarItems() {
246 var result = [this._perspectiveSelect, this._classNameFilter]; 246 var result = [this._perspectiveSelect, this._classNameFilter];
247 if (this._profile.profileType() !== WebInspector.ProfileTypeRegistry.instanc e.trackingHeapSnapshotProfileType) 247 if (this._profile.profileType() !== Profiler.ProfileTypeRegistry.instance.tr ackingHeapSnapshotProfileType)
248 result.push(this._baseSelect, this._filterSelect); 248 result.push(this._baseSelect, this._filterSelect);
249 result.push(this._selectedSizeText); 249 result.push(this._selectedSizeText);
250 return result; 250 return result;
251 } 251 }
252 252
253 /** 253 /**
254 * @override 254 * @override
255 */ 255 */
256 wasShown() { 256 wasShown() {
257 this._profile._loadPromise.then(this._profile._wasShown.bind(this._profile)) ; 257 this._profile._loadPromise.then(this._profile._wasShown.bind(this._profile)) ;
(...skipping 27 matching lines...) Expand all
285 285
286 /** 286 /**
287 * @override 287 * @override
288 */ 288 */
289 searchCanceled() { 289 searchCanceled() {
290 this._currentSearchResultIndex = -1; 290 this._currentSearchResultIndex = -1;
291 this._searchResults = []; 291 this._searchResults = [];
292 } 292 }
293 293
294 /** 294 /**
295 * @param {?WebInspector.HeapSnapshotGridNode} node 295 * @param {?Profiler.HeapSnapshotGridNode} node
296 */ 296 */
297 _selectRevealedNode(node) { 297 _selectRevealedNode(node) {
298 if (node) 298 if (node)
299 node.select(); 299 node.select();
300 } 300 }
301 301
302 /** 302 /**
303 * @override 303 * @override
304 * @param {!WebInspector.SearchableView.SearchConfig} searchConfig 304 * @param {!UI.SearchableView.SearchConfig} searchConfig
305 * @param {boolean} shouldJump 305 * @param {boolean} shouldJump
306 * @param {boolean=} jumpBackwards 306 * @param {boolean=} jumpBackwards
307 */ 307 */
308 performSearch(searchConfig, shouldJump, jumpBackwards) { 308 performSearch(searchConfig, shouldJump, jumpBackwards) {
309 var nextQuery = new WebInspector.HeapSnapshotCommon.SearchConfig( 309 var nextQuery = new Profiler.HeapSnapshotCommon.SearchConfig(
310 searchConfig.query.trim(), searchConfig.caseSensitive, searchConfig.isRe gex, shouldJump, 310 searchConfig.query.trim(), searchConfig.caseSensitive, searchConfig.isRe gex, shouldJump,
311 jumpBackwards || false); 311 jumpBackwards || false);
312 312
313 this._searchThrottler.schedule(this._performSearch.bind(this, nextQuery)); 313 this._searchThrottler.schedule(this._performSearch.bind(this, nextQuery));
314 } 314 }
315 315
316 /** 316 /**
317 * @param {!WebInspector.HeapSnapshotCommon.SearchConfig} nextQuery 317 * @param {!Profiler.HeapSnapshotCommon.SearchConfig} nextQuery
318 * @return {!Promise<?>} 318 * @return {!Promise<?>}
319 */ 319 */
320 _performSearch(nextQuery) { 320 _performSearch(nextQuery) {
321 // Call searchCanceled since it will reset everything we need before doing a new search. 321 // Call searchCanceled since it will reset everything we need before doing a new search.
322 this.searchCanceled(); 322 this.searchCanceled();
323 323
324 if (!this._currentPerspective.supportsSearch()) 324 if (!this._currentPerspective.supportsSearch())
325 return Promise.resolve(); 325 return Promise.resolve();
326 326
327 this.currentQuery = nextQuery; 327 this.currentQuery = nextQuery;
328 var query = nextQuery.query.trim(); 328 var query = nextQuery.query.trim();
329 329
330 if (!query) 330 if (!query)
331 return Promise.resolve(); 331 return Promise.resolve();
332 332
333 if (query.charAt(0) === '@') { 333 if (query.charAt(0) === '@') {
334 var snapshotNodeId = parseInt(query.substring(1), 10); 334 var snapshotNodeId = parseInt(query.substring(1), 10);
335 if (isNaN(snapshotNodeId)) 335 if (isNaN(snapshotNodeId))
336 return Promise.resolve(); 336 return Promise.resolve();
337 return this._dataGrid.revealObjectByHeapSnapshotId(String(snapshotNodeId)) 337 return this._dataGrid.revealObjectByHeapSnapshotId(String(snapshotNodeId))
338 .then(this._selectRevealedNode.bind(this)); 338 .then(this._selectRevealedNode.bind(this));
339 } 339 }
340 340
341 /** 341 /**
342 * @param {!Array<number>} entryIds 342 * @param {!Array<number>} entryIds
343 * @return {!Promise<?>} 343 * @return {!Promise<?>}
344 * @this {WebInspector.HeapSnapshotView} 344 * @this {Profiler.HeapSnapshotView}
345 */ 345 */
346 function didSearch(entryIds) { 346 function didSearch(entryIds) {
347 this._searchResults = entryIds; 347 this._searchResults = entryIds;
348 this._searchableView.updateSearchMatchesCount(this._searchResults.length); 348 this._searchableView.updateSearchMatchesCount(this._searchResults.length);
349 if (this._searchResults.length) 349 if (this._searchResults.length)
350 this._currentSearchResultIndex = nextQuery.jumpBackwards ? this._searchR esults.length - 1 : 0; 350 this._currentSearchResultIndex = nextQuery.jumpBackwards ? this._searchR esults.length - 1 : 0;
351 return this._jumpToSearchResult(this._currentSearchResultIndex); 351 return this._jumpToSearchResult(this._currentSearchResultIndex);
352 } 352 }
353 353
354 return this._profile._snapshotProxy.search(this.currentQuery, this._dataGrid .nodeFilter()) 354 return this._profile._snapshotProxy.search(this.currentQuery, this._dataGrid .nodeFilter())
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 child.refresh(); 394 child.refresh();
395 child = child.traverseNextNode(false, null, true); 395 child = child.traverseNextNode(false, null, true);
396 } 396 }
397 } 397 }
398 398
399 _changeBase() { 399 _changeBase() {
400 if (this._baseProfile === this._profiles()[this._baseSelect.selectedIndex()] ) 400 if (this._baseProfile === this._profiles()[this._baseSelect.selectedIndex()] )
401 return; 401 return;
402 402
403 this._baseProfile = this._profiles()[this._baseSelect.selectedIndex()]; 403 this._baseProfile = this._profiles()[this._baseSelect.selectedIndex()];
404 var dataGrid = /** @type {!WebInspector.HeapSnapshotDiffDataGrid} */ (this._ dataGrid); 404 var dataGrid = /** @type {!Profiler.HeapSnapshotDiffDataGrid} */ (this._data Grid);
405 // Change set base data source only if main data source is already set. 405 // Change set base data source only if main data source is already set.
406 if (dataGrid.snapshot) 406 if (dataGrid.snapshot)
407 this._baseProfile._loadPromise.then(dataGrid.setBaseDataSource.bind(dataGr id)); 407 this._baseProfile._loadPromise.then(dataGrid.setBaseDataSource.bind(dataGr id));
408 408
409 if (!this.currentQuery || !this._searchResults) 409 if (!this.currentQuery || !this._searchResults)
410 return; 410 return;
411 411
412 // The current search needs to be performed again. First negate out previous match 412 // The current search needs to be performed again. First negate out previous match
413 // count by calling the search finished callback with a negative number of m atches. 413 // count by calling the search finished callback with a negative number of m atches.
414 // Then perform the search again with the same query and callback. 414 // Then perform the search again with the same query and callback.
415 this.performSearch(this.currentQuery, false); 415 this.performSearch(this.currentQuery, false);
416 } 416 }
417 417
418 _changeFilter() { 418 _changeFilter() {
419 var profileIndex = this._filterSelect.selectedIndex() - 1; 419 var profileIndex = this._filterSelect.selectedIndex() - 1;
420 this._dataGrid.filterSelectIndexChanged(this._profiles(), profileIndex); 420 this._dataGrid.filterSelectIndexChanged(this._profiles(), profileIndex);
421 421
422 if (!this.currentQuery || !this._searchResults) 422 if (!this.currentQuery || !this._searchResults)
423 return; 423 return;
424 424
425 // The current search needs to be performed again. First negate out previous match 425 // The current search needs to be performed again. First negate out previous match
426 // count by calling the search finished callback with a negative number of m atches. 426 // count by calling the search finished callback with a negative number of m atches.
427 // Then perform the search again with the same query and callback. 427 // Then perform the search again with the same query and callback.
428 this.performSearch(this.currentQuery, false); 428 this.performSearch(this.currentQuery, false);
429 } 429 }
430 430
431 /** 431 /**
432 * @return {!Array.<!WebInspector.ProfileHeader>} 432 * @return {!Array.<!Profiler.ProfileHeader>}
433 */ 433 */
434 _profiles() { 434 _profiles() {
435 return this._profile.profileType().getProfiles(); 435 return this._profile.profileType().getProfiles();
436 } 436 }
437 437
438 /** 438 /**
439 * @param {!WebInspector.ContextMenu} contextMenu 439 * @param {!UI.ContextMenu} contextMenu
440 * @param {!Event} event 440 * @param {!Event} event
441 */ 441 */
442 populateContextMenu(contextMenu, event) { 442 populateContextMenu(contextMenu, event) {
443 if (this._dataGrid) 443 if (this._dataGrid)
444 this._dataGrid.populateContextMenu(contextMenu, event); 444 this._dataGrid.populateContextMenu(contextMenu, event);
445 } 445 }
446 446
447 _selectionChanged(event) { 447 _selectionChanged(event) {
448 var selectedNode = event.target.selectedNode; 448 var selectedNode = event.target.selectedNode;
449 this._setSelectedNodeForDetailsView(selectedNode); 449 this._setSelectedNodeForDetailsView(selectedNode);
450 this._inspectedObjectChanged(event); 450 this._inspectedObjectChanged(event);
451 } 451 }
452 452
453 _onSelectAllocationNode(event) { 453 _onSelectAllocationNode(event) {
454 var selectedNode = event.target.selectedNode; 454 var selectedNode = event.target.selectedNode;
455 this._constructorsDataGrid.setAllocationNodeId(selectedNode.allocationNodeId ()); 455 this._constructorsDataGrid.setAllocationNodeId(selectedNode.allocationNodeId ());
456 this._setSelectedNodeForDetailsView(null); 456 this._setSelectedNodeForDetailsView(null);
457 } 457 }
458 458
459 _inspectedObjectChanged(event) { 459 _inspectedObjectChanged(event) {
460 var selectedNode = event.target.selectedNode; 460 var selectedNode = event.target.selectedNode;
461 var target = this._profile.target(); 461 var target = this._profile.target();
462 if (target && selectedNode instanceof WebInspector.HeapSnapshotGenericObject Node) 462 if (target && selectedNode instanceof Profiler.HeapSnapshotGenericObjectNode )
463 target.heapProfilerAgent().addInspectedHeapObject(String(selectedNode.snap shotNodeId)); 463 target.heapProfilerAgent().addInspectedHeapObject(String(selectedNode.snap shotNodeId));
464 } 464 }
465 465
466 /** 466 /**
467 * @param {?WebInspector.HeapSnapshotGridNode} nodeItem 467 * @param {?Profiler.HeapSnapshotGridNode} nodeItem
468 */ 468 */
469 _setSelectedNodeForDetailsView(nodeItem) { 469 _setSelectedNodeForDetailsView(nodeItem) {
470 var dataSource = nodeItem && nodeItem.retainersDataSource(); 470 var dataSource = nodeItem && nodeItem.retainersDataSource();
471 if (dataSource) { 471 if (dataSource) {
472 this._retainmentDataGrid.setDataSource(dataSource.snapshot, dataSource.sna pshotNodeIndex); 472 this._retainmentDataGrid.setDataSource(dataSource.snapshot, dataSource.sna pshotNodeIndex);
473 if (this._allocationStackView) 473 if (this._allocationStackView)
474 this._allocationStackView.setAllocatedObject(dataSource.snapshot, dataSo urce.snapshotNodeIndex); 474 this._allocationStackView.setAllocatedObject(dataSource.snapshot, dataSo urce.snapshotNodeIndex);
475 } else { 475 } else {
476 if (this._allocationStackView) 476 if (this._allocationStackView)
477 this._allocationStackView.clear(); 477 this._allocationStackView.clear();
(...skipping 12 matching lines...) Expand all
490 perspectiveIndex = i; 490 perspectiveIndex = i;
491 break; 491 break;
492 } 492 }
493 } 493 }
494 if (this._currentPerspectiveIndex === perspectiveIndex || perspectiveIndex = == null) { 494 if (this._currentPerspectiveIndex === perspectiveIndex || perspectiveIndex = == null) {
495 setTimeout(callback, 0); 495 setTimeout(callback, 0);
496 return; 496 return;
497 } 497 }
498 498
499 /** 499 /**
500 * @this {WebInspector.HeapSnapshotView} 500 * @this {Profiler.HeapSnapshotView}
501 */ 501 */
502 function dataGridContentShown(event) { 502 function dataGridContentShown(event) {
503 var dataGrid = event.data; 503 var dataGrid = event.data;
504 dataGrid.removeEventListener( 504 dataGrid.removeEventListener(
505 WebInspector.HeapSnapshotSortableDataGrid.Events.ContentShown, dataGri dContentShown, this); 505 Profiler.HeapSnapshotSortableDataGrid.Events.ContentShown, dataGridCon tentShown, this);
506 if (dataGrid === this._dataGrid) 506 if (dataGrid === this._dataGrid)
507 callback(); 507 callback();
508 } 508 }
509 this._perspectives[perspectiveIndex].masterGrid(this).addEventListener( 509 this._perspectives[perspectiveIndex].masterGrid(this).addEventListener(
510 WebInspector.HeapSnapshotSortableDataGrid.Events.ContentShown, dataGridC ontentShown, this); 510 Profiler.HeapSnapshotSortableDataGrid.Events.ContentShown, dataGridConte ntShown, this);
511 511
512 this._perspectiveSelect.setSelectedIndex(perspectiveIndex); 512 this._perspectiveSelect.setSelectedIndex(perspectiveIndex);
513 this._changePerspective(perspectiveIndex); 513 this._changePerspective(perspectiveIndex);
514 } 514 }
515 515
516 _updateDataSourceAndView() { 516 _updateDataSourceAndView() {
517 var dataGrid = this._dataGrid; 517 var dataGrid = this._dataGrid;
518 if (!dataGrid || dataGrid.snapshot) 518 if (!dataGrid || dataGrid.snapshot)
519 return; 519 return;
520 520
521 this._profile._loadPromise.then(didLoadSnapshot.bind(this)); 521 this._profile._loadPromise.then(didLoadSnapshot.bind(this));
522 522
523 /** 523 /**
524 * @this {WebInspector.HeapSnapshotView} 524 * @this {Profiler.HeapSnapshotView}
525 */ 525 */
526 function didLoadSnapshot(snapshotProxy) { 526 function didLoadSnapshot(snapshotProxy) {
527 if (this._dataGrid !== dataGrid) 527 if (this._dataGrid !== dataGrid)
528 return; 528 return;
529 if (dataGrid.snapshot !== snapshotProxy) 529 if (dataGrid.snapshot !== snapshotProxy)
530 dataGrid.setDataSource(snapshotProxy); 530 dataGrid.setDataSource(snapshotProxy);
531 if (dataGrid === this._diffDataGrid) { 531 if (dataGrid === this._diffDataGrid) {
532 if (!this._baseProfile) 532 if (!this._baseProfile)
533 this._baseProfile = this._profiles()[this._baseSelect.selectedIndex()] ; 533 this._baseProfile = this._profiles()[this._baseSelect.selectedIndex()] ;
534 this._baseProfile._loadPromise.then(didLoadBaseSnapshot.bind(this)); 534 this._baseProfile._loadPromise.then(didLoadBaseSnapshot.bind(this));
535 } 535 }
536 } 536 }
537 537
538 /** 538 /**
539 * @this {WebInspector.HeapSnapshotView} 539 * @this {Profiler.HeapSnapshotView}
540 */ 540 */
541 function didLoadBaseSnapshot(baseSnapshotProxy) { 541 function didLoadBaseSnapshot(baseSnapshotProxy) {
542 if (this._diffDataGrid.baseSnapshot !== baseSnapshotProxy) 542 if (this._diffDataGrid.baseSnapshot !== baseSnapshotProxy)
543 this._diffDataGrid.setBaseDataSource(baseSnapshotProxy); 543 this._diffDataGrid.setBaseDataSource(baseSnapshotProxy);
544 } 544 }
545 } 545 }
546 546
547 _onSelectedPerspectiveChanged(event) { 547 _onSelectedPerspectiveChanged(event) {
548 this._changePerspective(event.target.selectedIndex); 548 this._changePerspective(event.target.selectedIndex);
549 } 549 }
(...skipping 29 matching lines...) Expand all
579 } 579 }
580 580
581 /** 581 /**
582 * @param {string} perspectiveName 582 * @param {string} perspectiveName
583 * @param {!Protocol.HeapProfiler.HeapSnapshotObjectId} snapshotObjectId 583 * @param {!Protocol.HeapProfiler.HeapSnapshotObjectId} snapshotObjectId
584 */ 584 */
585 selectLiveObject(perspectiveName, snapshotObjectId) { 585 selectLiveObject(perspectiveName, snapshotObjectId) {
586 this._changePerspectiveAndWait(perspectiveName, didChangePerspective.bind(th is)); 586 this._changePerspectiveAndWait(perspectiveName, didChangePerspective.bind(th is));
587 587
588 /** 588 /**
589 * @this {WebInspector.HeapSnapshotView} 589 * @this {Profiler.HeapSnapshotView}
590 */ 590 */
591 function didChangePerspective() { 591 function didChangePerspective() {
592 this._dataGrid.revealObjectByHeapSnapshotId(snapshotObjectId, didRevealObj ect); 592 this._dataGrid.revealObjectByHeapSnapshotId(snapshotObjectId, didRevealObj ect);
593 } 593 }
594 594
595 /** 595 /**
596 * @param {?WebInspector.HeapSnapshotGridNode} node 596 * @param {?Profiler.HeapSnapshotGridNode} node
597 */ 597 */
598 function didRevealObject(node) { 598 function didRevealObject(node) {
599 if (node) 599 if (node)
600 node.select(); 600 node.select();
601 else 601 else
602 WebInspector.console.error('Cannot find corresponding heap snapshot node '); 602 Common.console.error('Cannot find corresponding heap snapshot node');
603 } 603 }
604 } 604 }
605 605
606 _getHoverAnchor(target) { 606 _getHoverAnchor(target) {
607 var span = target.enclosingNodeOrSelfWithNodeName('span'); 607 var span = target.enclosingNodeOrSelfWithNodeName('span');
608 if (!span) 608 if (!span)
609 return; 609 return;
610 var row = target.enclosingNodeOrSelfWithNodeName('tr'); 610 var row = target.enclosingNodeOrSelfWithNodeName('tr');
611 if (!row) 611 if (!row)
612 return; 612 return;
(...skipping 21 matching lines...) Expand all
634 } 634 }
635 } 635 }
636 636
637 _updateFilterOptions() { 637 _updateFilterOptions() {
638 var list = this._profiles(); 638 var list = this._profiles();
639 // We're assuming that snapshots can only be added. 639 // We're assuming that snapshots can only be added.
640 if (this._filterSelect.size() - 1 === list.length) 640 if (this._filterSelect.size() - 1 === list.length)
641 return; 641 return;
642 642
643 if (!this._filterSelect.size()) 643 if (!this._filterSelect.size())
644 this._filterSelect.createOption(WebInspector.UIString('All objects')); 644 this._filterSelect.createOption(Common.UIString('All objects'));
645 645
646 for (var i = this._filterSelect.size() - 1, n = list.length; i < n; ++i) { 646 for (var i = this._filterSelect.size() - 1, n = list.length; i < n; ++i) {
647 var title = list[i].title; 647 var title = list[i].title;
648 if (!i) 648 if (!i)
649 title = WebInspector.UIString('Objects allocated before %s', title); 649 title = Common.UIString('Objects allocated before %s', title);
650 else 650 else
651 title = WebInspector.UIString('Objects allocated between %s and %s', lis t[i - 1].title, title); 651 title = Common.UIString('Objects allocated between %s and %s', list[i - 1].title, title);
652 this._filterSelect.createOption(title); 652 this._filterSelect.createOption(title);
653 } 653 }
654 } 654 }
655 655
656 _updateControls() { 656 _updateControls() {
657 this._updateBaseOptions(); 657 this._updateBaseOptions();
658 this._updateFilterOptions(); 658 this._updateFilterOptions();
659 } 659 }
660 660
661 /** 661 /**
662 * @param {!WebInspector.Event} event 662 * @param {!Common.Event} event
663 */ 663 */
664 _onReceiveSnapshot(event) { 664 _onReceiveSnapshot(event) {
665 this._updateControls(); 665 this._updateControls();
666 } 666 }
667 667
668 /** 668 /**
669 * @param {!WebInspector.Event} event 669 * @param {!Common.Event} event
670 */ 670 */
671 _onProfileHeaderRemoved(event) { 671 _onProfileHeaderRemoved(event) {
672 var profile = event.data; 672 var profile = event.data;
673 if (this._profile === profile) { 673 if (this._profile === profile) {
674 this.detach(); 674 this.detach();
675 this._profile.profileType().removeEventListener( 675 this._profile.profileType().removeEventListener(
676 WebInspector.HeapSnapshotProfileType.SnapshotReceived, this._onReceive Snapshot, this); 676 Profiler.HeapSnapshotProfileType.SnapshotReceived, this._onReceiveSnap shot, this);
677 this._profile.profileType().removeEventListener( 677 this._profile.profileType().removeEventListener(
678 WebInspector.ProfileType.Events.RemoveProfileHeader, this._onProfileHe aderRemoved, this); 678 Profiler.ProfileType.Events.RemoveProfileHeader, this._onProfileHeader Removed, this);
679 this.dispose(); 679 this.dispose();
680 } else { 680 } else {
681 this._updateControls(); 681 this._updateControls();
682 } 682 }
683 } 683 }
684 684
685 dispose() { 685 dispose() {
686 if (this._allocationStackView) { 686 if (this._allocationStackView) {
687 this._allocationStackView.clear(); 687 this._allocationStackView.clear();
688 this._allocationDataGrid.dispose(); 688 this._allocationDataGrid.dispose();
689 } 689 }
690 if (this._trackingOverviewGrid) 690 if (this._trackingOverviewGrid)
691 this._trackingOverviewGrid.dispose(); 691 this._trackingOverviewGrid.dispose();
692 } 692 }
693 }; 693 };
694 694
695 /** 695 /**
696 * @unrestricted 696 * @unrestricted
697 */ 697 */
698 WebInspector.HeapSnapshotView.Perspective = class { 698 Profiler.HeapSnapshotView.Perspective = class {
699 /** 699 /**
700 * @param {string} title 700 * @param {string} title
701 */ 701 */
702 constructor(title) { 702 constructor(title) {
703 this._title = title; 703 this._title = title;
704 } 704 }
705 705
706 /** 706 /**
707 * @param {!WebInspector.HeapSnapshotView} heapSnapshotView 707 * @param {!Profiler.HeapSnapshotView} heapSnapshotView
708 */ 708 */
709 activate(heapSnapshotView) { 709 activate(heapSnapshotView) {
710 } 710 }
711 711
712 /** 712 /**
713 * @param {!WebInspector.HeapSnapshotView} heapSnapshotView 713 * @param {!Profiler.HeapSnapshotView} heapSnapshotView
714 */ 714 */
715 deactivate(heapSnapshotView) { 715 deactivate(heapSnapshotView) {
716 heapSnapshotView._baseSelect.setVisible(false); 716 heapSnapshotView._baseSelect.setVisible(false);
717 heapSnapshotView._filterSelect.setVisible(false); 717 heapSnapshotView._filterSelect.setVisible(false);
718 heapSnapshotView._classNameFilter.setVisible(false); 718 heapSnapshotView._classNameFilter.setVisible(false);
719 if (heapSnapshotView._trackingOverviewGrid) 719 if (heapSnapshotView._trackingOverviewGrid)
720 heapSnapshotView._trackingOverviewGrid.detach(); 720 heapSnapshotView._trackingOverviewGrid.detach();
721 if (heapSnapshotView._allocationWidget) 721 if (heapSnapshotView._allocationWidget)
722 heapSnapshotView._allocationWidget.detach(); 722 heapSnapshotView._allocationWidget.detach();
723 if (heapSnapshotView._statisticsView) 723 if (heapSnapshotView._statisticsView)
724 heapSnapshotView._statisticsView.detach(); 724 heapSnapshotView._statisticsView.detach();
725 725
726 heapSnapshotView._splitWidget.detach(); 726 heapSnapshotView._splitWidget.detach();
727 heapSnapshotView._splitWidget.detachChildWidgets(); 727 heapSnapshotView._splitWidget.detachChildWidgets();
728 } 728 }
729 729
730 /** 730 /**
731 * @param {!WebInspector.HeapSnapshotView} heapSnapshotView 731 * @param {!Profiler.HeapSnapshotView} heapSnapshotView
732 * @return {?WebInspector.DataGrid} 732 * @return {?UI.DataGrid}
733 */ 733 */
734 masterGrid(heapSnapshotView) { 734 masterGrid(heapSnapshotView) {
735 return null; 735 return null;
736 } 736 }
737 737
738 /** 738 /**
739 * @return {string} 739 * @return {string}
740 */ 740 */
741 title() { 741 title() {
742 return this._title; 742 return this._title;
743 } 743 }
744 744
745 /** 745 /**
746 * @return {boolean} 746 * @return {boolean}
747 */ 747 */
748 supportsSearch() { 748 supportsSearch() {
749 return false; 749 return false;
750 } 750 }
751 }; 751 };
752 752
753 /** 753 /**
754 * @unrestricted 754 * @unrestricted
755 */ 755 */
756 WebInspector.HeapSnapshotView.SummaryPerspective = class extends WebInspector.He apSnapshotView.Perspective { 756 Profiler.HeapSnapshotView.SummaryPerspective = class extends Profiler.HeapSnapsh otView.Perspective {
757 constructor() { 757 constructor() {
758 super(WebInspector.UIString('Summary')); 758 super(Common.UIString('Summary'));
759 } 759 }
760 760
761 /** 761 /**
762 * @override 762 * @override
763 * @param {!WebInspector.HeapSnapshotView} heapSnapshotView 763 * @param {!Profiler.HeapSnapshotView} heapSnapshotView
764 */ 764 */
765 activate(heapSnapshotView) { 765 activate(heapSnapshotView) {
766 heapSnapshotView._splitWidget.setMainWidget(heapSnapshotView._constructorsWi dget); 766 heapSnapshotView._splitWidget.setMainWidget(heapSnapshotView._constructorsWi dget);
767 heapSnapshotView._splitWidget.setSidebarWidget(heapSnapshotView._objectDetai lsView); 767 heapSnapshotView._splitWidget.setSidebarWidget(heapSnapshotView._objectDetai lsView);
768 heapSnapshotView._splitWidget.show(heapSnapshotView._searchableView.element) ; 768 heapSnapshotView._splitWidget.show(heapSnapshotView._searchableView.element) ;
769 heapSnapshotView._filterSelect.setVisible(true); 769 heapSnapshotView._filterSelect.setVisible(true);
770 heapSnapshotView._classNameFilter.setVisible(true); 770 heapSnapshotView._classNameFilter.setVisible(true);
771 if (heapSnapshotView._trackingOverviewGrid) { 771 if (heapSnapshotView._trackingOverviewGrid) {
772 heapSnapshotView._trackingOverviewGrid.show( 772 heapSnapshotView._trackingOverviewGrid.show(
773 heapSnapshotView._searchableView.element, heapSnapshotView._splitWidge t.element); 773 heapSnapshotView._searchableView.element, heapSnapshotView._splitWidge t.element);
774 heapSnapshotView._trackingOverviewGrid.update(); 774 heapSnapshotView._trackingOverviewGrid.update();
775 heapSnapshotView._trackingOverviewGrid._updateGrid(); 775 heapSnapshotView._trackingOverviewGrid._updateGrid();
776 } 776 }
777 } 777 }
778 778
779 /** 779 /**
780 * @override 780 * @override
781 * @param {!WebInspector.HeapSnapshotView} heapSnapshotView 781 * @param {!Profiler.HeapSnapshotView} heapSnapshotView
782 * @return {?WebInspector.DataGrid} 782 * @return {?UI.DataGrid}
783 */ 783 */
784 masterGrid(heapSnapshotView) { 784 masterGrid(heapSnapshotView) {
785 return heapSnapshotView._constructorsDataGrid; 785 return heapSnapshotView._constructorsDataGrid;
786 } 786 }
787 787
788 /** 788 /**
789 * @override 789 * @override
790 * @return {boolean} 790 * @return {boolean}
791 */ 791 */
792 supportsSearch() { 792 supportsSearch() {
793 return true; 793 return true;
794 } 794 }
795 }; 795 };
796 796
797 /** 797 /**
798 * @unrestricted 798 * @unrestricted
799 */ 799 */
800 WebInspector.HeapSnapshotView.ComparisonPerspective = class extends WebInspector .HeapSnapshotView.Perspective { 800 Profiler.HeapSnapshotView.ComparisonPerspective = class extends Profiler.HeapSna pshotView.Perspective {
801 constructor() { 801 constructor() {
802 super(WebInspector.UIString('Comparison')); 802 super(Common.UIString('Comparison'));
803 } 803 }
804 804
805 /** 805 /**
806 * @override 806 * @override
807 * @param {!WebInspector.HeapSnapshotView} heapSnapshotView 807 * @param {!Profiler.HeapSnapshotView} heapSnapshotView
808 */ 808 */
809 activate(heapSnapshotView) { 809 activate(heapSnapshotView) {
810 heapSnapshotView._splitWidget.setMainWidget(heapSnapshotView._diffWidget); 810 heapSnapshotView._splitWidget.setMainWidget(heapSnapshotView._diffWidget);
811 heapSnapshotView._splitWidget.setSidebarWidget(heapSnapshotView._objectDetai lsView); 811 heapSnapshotView._splitWidget.setSidebarWidget(heapSnapshotView._objectDetai lsView);
812 heapSnapshotView._splitWidget.show(heapSnapshotView._searchableView.element) ; 812 heapSnapshotView._splitWidget.show(heapSnapshotView._searchableView.element) ;
813 heapSnapshotView._baseSelect.setVisible(true); 813 heapSnapshotView._baseSelect.setVisible(true);
814 heapSnapshotView._classNameFilter.setVisible(true); 814 heapSnapshotView._classNameFilter.setVisible(true);
815 } 815 }
816 816
817 /** 817 /**
818 * @override 818 * @override
819 * @param {!WebInspector.HeapSnapshotView} heapSnapshotView 819 * @param {!Profiler.HeapSnapshotView} heapSnapshotView
820 * @return {?WebInspector.DataGrid} 820 * @return {?UI.DataGrid}
821 */ 821 */
822 masterGrid(heapSnapshotView) { 822 masterGrid(heapSnapshotView) {
823 return heapSnapshotView._diffDataGrid; 823 return heapSnapshotView._diffDataGrid;
824 } 824 }
825 825
826 /** 826 /**
827 * @override 827 * @override
828 * @return {boolean} 828 * @return {boolean}
829 */ 829 */
830 supportsSearch() { 830 supportsSearch() {
831 return true; 831 return true;
832 } 832 }
833 }; 833 };
834 834
835 /** 835 /**
836 * @unrestricted 836 * @unrestricted
837 */ 837 */
838 WebInspector.HeapSnapshotView.ContainmentPerspective = class extends WebInspecto r.HeapSnapshotView.Perspective { 838 Profiler.HeapSnapshotView.ContainmentPerspective = class extends Profiler.HeapSn apshotView.Perspective {
839 constructor() { 839 constructor() {
840 super(WebInspector.UIString('Containment')); 840 super(Common.UIString('Containment'));
841 } 841 }
842 842
843 /** 843 /**
844 * @override 844 * @override
845 * @param {!WebInspector.HeapSnapshotView} heapSnapshotView 845 * @param {!Profiler.HeapSnapshotView} heapSnapshotView
846 */ 846 */
847 activate(heapSnapshotView) { 847 activate(heapSnapshotView) {
848 heapSnapshotView._splitWidget.setMainWidget(heapSnapshotView._containmentWid get); 848 heapSnapshotView._splitWidget.setMainWidget(heapSnapshotView._containmentWid get);
849 heapSnapshotView._splitWidget.setSidebarWidget(heapSnapshotView._objectDetai lsView); 849 heapSnapshotView._splitWidget.setSidebarWidget(heapSnapshotView._objectDetai lsView);
850 heapSnapshotView._splitWidget.show(heapSnapshotView._searchableView.element) ; 850 heapSnapshotView._splitWidget.show(heapSnapshotView._searchableView.element) ;
851 } 851 }
852 852
853 /** 853 /**
854 * @override 854 * @override
855 * @param {!WebInspector.HeapSnapshotView} heapSnapshotView 855 * @param {!Profiler.HeapSnapshotView} heapSnapshotView
856 * @return {?WebInspector.DataGrid} 856 * @return {?UI.DataGrid}
857 */ 857 */
858 masterGrid(heapSnapshotView) { 858 masterGrid(heapSnapshotView) {
859 return heapSnapshotView._containmentDataGrid; 859 return heapSnapshotView._containmentDataGrid;
860 } 860 }
861 }; 861 };
862 862
863 /** 863 /**
864 * @unrestricted 864 * @unrestricted
865 */ 865 */
866 WebInspector.HeapSnapshotView.AllocationPerspective = class extends WebInspector .HeapSnapshotView.Perspective { 866 Profiler.HeapSnapshotView.AllocationPerspective = class extends Profiler.HeapSna pshotView.Perspective {
867 constructor() { 867 constructor() {
868 super(WebInspector.UIString('Allocation')); 868 super(Common.UIString('Allocation'));
869 this._allocationSplitWidget = 869 this._allocationSplitWidget =
870 new WebInspector.SplitWidget(false, true, 'heapSnapshotAllocationSplitVi ewState', 200, 200); 870 new UI.SplitWidget(false, true, 'heapSnapshotAllocationSplitViewState', 200, 200);
871 this._allocationSplitWidget.setSidebarWidget(new WebInspector.VBox()); 871 this._allocationSplitWidget.setSidebarWidget(new UI.VBox());
872 } 872 }
873 873
874 /** 874 /**
875 * @override 875 * @override
876 * @param {!WebInspector.HeapSnapshotView} heapSnapshotView 876 * @param {!Profiler.HeapSnapshotView} heapSnapshotView
877 */ 877 */
878 activate(heapSnapshotView) { 878 activate(heapSnapshotView) {
879 this._allocationSplitWidget.setMainWidget(heapSnapshotView._allocationWidget ); 879 this._allocationSplitWidget.setMainWidget(heapSnapshotView._allocationWidget );
880 heapSnapshotView._splitWidget.setMainWidget(heapSnapshotView._constructorsWi dget); 880 heapSnapshotView._splitWidget.setMainWidget(heapSnapshotView._constructorsWi dget);
881 heapSnapshotView._splitWidget.setSidebarWidget(heapSnapshotView._objectDetai lsView); 881 heapSnapshotView._splitWidget.setSidebarWidget(heapSnapshotView._objectDetai lsView);
882 882
883 var allocatedObjectsView = new WebInspector.VBox(); 883 var allocatedObjectsView = new UI.VBox();
884 var resizer = createElementWithClass('div', 'heap-snapshot-view-resizer'); 884 var resizer = createElementWithClass('div', 'heap-snapshot-view-resizer');
885 var title = resizer.createChild('div', 'title').createChild('span'); 885 var title = resizer.createChild('div', 'title').createChild('span');
886 title.textContent = WebInspector.UIString('Live objects'); 886 title.textContent = Common.UIString('Live objects');
887 this._allocationSplitWidget.hideDefaultResizer(); 887 this._allocationSplitWidget.hideDefaultResizer();
888 this._allocationSplitWidget.installResizer(resizer); 888 this._allocationSplitWidget.installResizer(resizer);
889 allocatedObjectsView.element.appendChild(resizer); 889 allocatedObjectsView.element.appendChild(resizer);
890 heapSnapshotView._splitWidget.show(allocatedObjectsView.element); 890 heapSnapshotView._splitWidget.show(allocatedObjectsView.element);
891 this._allocationSplitWidget.setSidebarWidget(allocatedObjectsView); 891 this._allocationSplitWidget.setSidebarWidget(allocatedObjectsView);
892 892
893 this._allocationSplitWidget.show(heapSnapshotView._searchableView.element); 893 this._allocationSplitWidget.show(heapSnapshotView._searchableView.element);
894 894
895 heapSnapshotView._constructorsDataGrid.clear(); 895 heapSnapshotView._constructorsDataGrid.clear();
896 var selectedNode = heapSnapshotView._allocationDataGrid.selectedNode; 896 var selectedNode = heapSnapshotView._allocationDataGrid.selectedNode;
897 if (selectedNode) 897 if (selectedNode)
898 heapSnapshotView._constructorsDataGrid.setAllocationNodeId(selectedNode.al locationNodeId()); 898 heapSnapshotView._constructorsDataGrid.setAllocationNodeId(selectedNode.al locationNodeId());
899 } 899 }
900 900
901 /** 901 /**
902 * @override 902 * @override
903 * @param {!WebInspector.HeapSnapshotView} heapSnapshotView 903 * @param {!Profiler.HeapSnapshotView} heapSnapshotView
904 */ 904 */
905 deactivate(heapSnapshotView) { 905 deactivate(heapSnapshotView) {
906 this._allocationSplitWidget.detach(); 906 this._allocationSplitWidget.detach();
907 super.deactivate(heapSnapshotView); 907 super.deactivate(heapSnapshotView);
908 } 908 }
909 909
910 /** 910 /**
911 * @override 911 * @override
912 * @param {!WebInspector.HeapSnapshotView} heapSnapshotView 912 * @param {!Profiler.HeapSnapshotView} heapSnapshotView
913 * @return {?WebInspector.DataGrid} 913 * @return {?UI.DataGrid}
914 */ 914 */
915 masterGrid(heapSnapshotView) { 915 masterGrid(heapSnapshotView) {
916 return heapSnapshotView._allocationDataGrid; 916 return heapSnapshotView._allocationDataGrid;
917 } 917 }
918 }; 918 };
919 919
920 /** 920 /**
921 * @unrestricted 921 * @unrestricted
922 */ 922 */
923 WebInspector.HeapSnapshotView.StatisticsPerspective = class extends WebInspector .HeapSnapshotView.Perspective { 923 Profiler.HeapSnapshotView.StatisticsPerspective = class extends Profiler.HeapSna pshotView.Perspective {
924 constructor() { 924 constructor() {
925 super(WebInspector.UIString('Statistics')); 925 super(Common.UIString('Statistics'));
926 } 926 }
927 927
928 /** 928 /**
929 * @override 929 * @override
930 * @param {!WebInspector.HeapSnapshotView} heapSnapshotView 930 * @param {!Profiler.HeapSnapshotView} heapSnapshotView
931 */ 931 */
932 activate(heapSnapshotView) { 932 activate(heapSnapshotView) {
933 heapSnapshotView._statisticsView.show(heapSnapshotView._searchableView.eleme nt); 933 heapSnapshotView._statisticsView.show(heapSnapshotView._searchableView.eleme nt);
934 } 934 }
935 935
936 /** 936 /**
937 * @override 937 * @override
938 * @param {!WebInspector.HeapSnapshotView} heapSnapshotView 938 * @param {!Profiler.HeapSnapshotView} heapSnapshotView
939 * @return {?WebInspector.DataGrid} 939 * @return {?UI.DataGrid}
940 */ 940 */
941 masterGrid(heapSnapshotView) { 941 masterGrid(heapSnapshotView) {
942 return null; 942 return null;
943 } 943 }
944 }; 944 };
945 945
946 /** 946 /**
947 * @implements {WebInspector.TargetManager.Observer} 947 * @implements {SDK.TargetManager.Observer}
948 * @unrestricted 948 * @unrestricted
949 */ 949 */
950 WebInspector.HeapSnapshotProfileType = class extends WebInspector.ProfileType { 950 Profiler.HeapSnapshotProfileType = class extends Profiler.ProfileType {
951 /** 951 /**
952 * @param {string=} id 952 * @param {string=} id
953 * @param {string=} title 953 * @param {string=} title
954 */ 954 */
955 constructor(id, title) { 955 constructor(id, title) {
956 super(id || WebInspector.HeapSnapshotProfileType.TypeId, title || WebInspect or.UIString('Take Heap Snapshot')); 956 super(id || Profiler.HeapSnapshotProfileType.TypeId, title || Common.UIStrin g('Take Heap Snapshot'));
957 WebInspector.targetManager.observeTargets(this); 957 SDK.targetManager.observeTargets(this);
958 WebInspector.targetManager.addModelListener( 958 SDK.targetManager.addModelListener(
959 WebInspector.HeapProfilerModel, WebInspector.HeapProfilerModel.Events.Re setProfiles, this._resetProfiles, this); 959 SDK.HeapProfilerModel, SDK.HeapProfilerModel.Events.ResetProfiles, this. _resetProfiles, this);
960 WebInspector.targetManager.addModelListener( 960 SDK.targetManager.addModelListener(
961 WebInspector.HeapProfilerModel, WebInspector.HeapProfilerModel.Events.Ad dHeapSnapshotChunk, 961 SDK.HeapProfilerModel, SDK.HeapProfilerModel.Events.AddHeapSnapshotChunk ,
962 this._addHeapSnapshotChunk, this); 962 this._addHeapSnapshotChunk, this);
963 WebInspector.targetManager.addModelListener( 963 SDK.targetManager.addModelListener(
964 WebInspector.HeapProfilerModel, WebInspector.HeapProfilerModel.Events.Re portHeapSnapshotProgress, 964 SDK.HeapProfilerModel, SDK.HeapProfilerModel.Events.ReportHeapSnapshotPr ogress,
965 this._reportHeapSnapshotProgress, this); 965 this._reportHeapSnapshotProgress, this);
966 } 966 }
967 967
968 /** 968 /**
969 * @override 969 * @override
970 * @param {!WebInspector.Target} target 970 * @param {!SDK.Target} target
971 */ 971 */
972 targetAdded(target) { 972 targetAdded(target) {
973 target.heapProfilerModel.enable(); 973 target.heapProfilerModel.enable();
974 } 974 }
975 975
976 /** 976 /**
977 * @override 977 * @override
978 * @param {!WebInspector.Target} target 978 * @param {!SDK.Target} target
979 */ 979 */
980 targetRemoved(target) { 980 targetRemoved(target) {
981 } 981 }
982 982
983 /** 983 /**
984 * @override 984 * @override
985 * @return {string} 985 * @return {string}
986 */ 986 */
987 fileExtension() { 987 fileExtension() {
988 return '.heapsnapshot'; 988 return '.heapsnapshot';
989 } 989 }
990 990
991 get buttonTooltip() { 991 get buttonTooltip() {
992 return WebInspector.UIString('Take heap snapshot'); 992 return Common.UIString('Take heap snapshot');
993 } 993 }
994 994
995 /** 995 /**
996 * @override 996 * @override
997 * @return {boolean} 997 * @return {boolean}
998 */ 998 */
999 isInstantProfile() { 999 isInstantProfile() {
1000 return true; 1000 return true;
1001 } 1001 }
1002 1002
1003 /** 1003 /**
1004 * @override 1004 * @override
1005 * @return {boolean} 1005 * @return {boolean}
1006 */ 1006 */
1007 buttonClicked() { 1007 buttonClicked() {
1008 this._takeHeapSnapshot(function() {}); 1008 this._takeHeapSnapshot(function() {});
1009 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Profile sHeapProfileTaken); 1009 Host.userMetrics.actionTaken(Host.UserMetrics.Action.ProfilesHeapProfileTake n);
1010 return false; 1010 return false;
1011 } 1011 }
1012 1012
1013 get treeItemTitle() { 1013 get treeItemTitle() {
1014 return WebInspector.UIString('HEAP SNAPSHOTS'); 1014 return Common.UIString('HEAP SNAPSHOTS');
1015 } 1015 }
1016 1016
1017 get description() { 1017 get description() {
1018 return WebInspector.UIString( 1018 return Common.UIString(
1019 'Heap snapshot profiles show memory distribution among your page\'s Java Script objects and related DOM nodes.'); 1019 'Heap snapshot profiles show memory distribution among your page\'s Java Script objects and related DOM nodes.');
1020 } 1020 }
1021 1021
1022 /** 1022 /**
1023 * @override 1023 * @override
1024 * @param {string} title 1024 * @param {string} title
1025 * @return {!WebInspector.ProfileHeader} 1025 * @return {!Profiler.ProfileHeader}
1026 */ 1026 */
1027 createProfileLoadedFromFile(title) { 1027 createProfileLoadedFromFile(title) {
1028 return new WebInspector.HeapProfileHeader(null, this, title); 1028 return new Profiler.HeapProfileHeader(null, this, title);
1029 } 1029 }
1030 1030
1031 _takeHeapSnapshot(callback) { 1031 _takeHeapSnapshot(callback) {
1032 if (this.profileBeingRecorded()) 1032 if (this.profileBeingRecorded())
1033 return; 1033 return;
1034 var target = /** @type {!WebInspector.Target} */ (WebInspector.context.flavo r(WebInspector.Target)); 1034 var target = /** @type {!SDK.Target} */ (UI.context.flavor(SDK.Target));
1035 var profile = new WebInspector.HeapProfileHeader(target, this); 1035 var profile = new Profiler.HeapProfileHeader(target, this);
1036 this.setProfileBeingRecorded(profile); 1036 this.setProfileBeingRecorded(profile);
1037 this.addProfile(profile); 1037 this.addProfile(profile);
1038 profile.updateStatus(WebInspector.UIString('Snapshotting\u2026')); 1038 profile.updateStatus(Common.UIString('Snapshotting\u2026'));
1039 1039
1040 /** 1040 /**
1041 * @param {?string} error 1041 * @param {?string} error
1042 * @this {WebInspector.HeapSnapshotProfileType} 1042 * @this {Profiler.HeapSnapshotProfileType}
1043 */ 1043 */
1044 function didTakeHeapSnapshot(error) { 1044 function didTakeHeapSnapshot(error) {
1045 var profile = this._profileBeingRecorded; 1045 var profile = this._profileBeingRecorded;
1046 profile.title = WebInspector.UIString('Snapshot %d', profile.uid); 1046 profile.title = Common.UIString('Snapshot %d', profile.uid);
1047 profile._finishLoad(); 1047 profile._finishLoad();
1048 this.setProfileBeingRecorded(null); 1048 this.setProfileBeingRecorded(null);
1049 this.dispatchEventToListeners(WebInspector.ProfileType.Events.ProfileCompl ete, profile); 1049 this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete, profile);
1050 callback(); 1050 callback();
1051 } 1051 }
1052 target.heapProfilerAgent().takeHeapSnapshot(true, didTakeHeapSnapshot.bind(t his)); 1052 target.heapProfilerAgent().takeHeapSnapshot(true, didTakeHeapSnapshot.bind(t his));
1053 } 1053 }
1054 1054
1055 /** 1055 /**
1056 * @param {!WebInspector.Event} event 1056 * @param {!Common.Event} event
1057 */ 1057 */
1058 _addHeapSnapshotChunk(event) { 1058 _addHeapSnapshotChunk(event) {
1059 if (!this.profileBeingRecorded()) 1059 if (!this.profileBeingRecorded())
1060 return; 1060 return;
1061 var chunk = /** @type {string} */ (event.data); 1061 var chunk = /** @type {string} */ (event.data);
1062 this.profileBeingRecorded().transferChunk(chunk); 1062 this.profileBeingRecorded().transferChunk(chunk);
1063 } 1063 }
1064 1064
1065 /** 1065 /**
1066 * @param {!WebInspector.Event} event 1066 * @param {!Common.Event} event
1067 */ 1067 */
1068 _reportHeapSnapshotProgress(event) { 1068 _reportHeapSnapshotProgress(event) {
1069 var profile = this.profileBeingRecorded(); 1069 var profile = this.profileBeingRecorded();
1070 if (!profile) 1070 if (!profile)
1071 return; 1071 return;
1072 var data = /** @type {{done: number, total: number, finished: boolean}} */ ( event.data); 1072 var data = /** @type {{done: number, total: number, finished: boolean}} */ ( event.data);
1073 profile.updateStatus(WebInspector.UIString('%.0f%%', (data.done / data.total ) * 100), true); 1073 profile.updateStatus(Common.UIString('%.0f%%', (data.done / data.total) * 10 0), true);
1074 if (data.finished) 1074 if (data.finished)
1075 profile._prepareToLoad(); 1075 profile._prepareToLoad();
1076 } 1076 }
1077 1077
1078 _resetProfiles() { 1078 _resetProfiles() {
1079 this._reset(); 1079 this._reset();
1080 } 1080 }
1081 1081
1082 _snapshotReceived(profile) { 1082 _snapshotReceived(profile) {
1083 if (this._profileBeingRecorded === profile) 1083 if (this._profileBeingRecorded === profile)
1084 this.setProfileBeingRecorded(null); 1084 this.setProfileBeingRecorded(null);
1085 this.dispatchEventToListeners(WebInspector.HeapSnapshotProfileType.SnapshotR eceived, profile); 1085 this.dispatchEventToListeners(Profiler.HeapSnapshotProfileType.SnapshotRecei ved, profile);
1086 } 1086 }
1087 }; 1087 };
1088 1088
1089 WebInspector.HeapSnapshotProfileType.TypeId = 'HEAP'; 1089 Profiler.HeapSnapshotProfileType.TypeId = 'HEAP';
1090 WebInspector.HeapSnapshotProfileType.SnapshotReceived = 'SnapshotReceived'; 1090 Profiler.HeapSnapshotProfileType.SnapshotReceived = 'SnapshotReceived';
1091 1091
1092 /** 1092 /**
1093 * @unrestricted 1093 * @unrestricted
1094 */ 1094 */
1095 WebInspector.TrackingHeapSnapshotProfileType = class extends WebInspector.HeapSn apshotProfileType { 1095 Profiler.TrackingHeapSnapshotProfileType = class extends Profiler.HeapSnapshotPr ofileType {
1096 constructor() { 1096 constructor() {
1097 super(WebInspector.TrackingHeapSnapshotProfileType.TypeId, WebInspector.UISt ring('Record Allocation Timeline')); 1097 super(Profiler.TrackingHeapSnapshotProfileType.TypeId, Common.UIString('Reco rd Allocation Timeline'));
1098 } 1098 }
1099 1099
1100 /** 1100 /**
1101 * @override 1101 * @override
1102 * @param {!WebInspector.Target} target 1102 * @param {!SDK.Target} target
1103 */ 1103 */
1104 targetAdded(target) { 1104 targetAdded(target) {
1105 super.targetAdded(target); 1105 super.targetAdded(target);
1106 target.heapProfilerModel.addEventListener( 1106 target.heapProfilerModel.addEventListener(
1107 WebInspector.HeapProfilerModel.Events.HeapStatsUpdate, this._heapStatsUp date, this); 1107 SDK.HeapProfilerModel.Events.HeapStatsUpdate, this._heapStatsUpdate, thi s);
1108 target.heapProfilerModel.addEventListener( 1108 target.heapProfilerModel.addEventListener(
1109 WebInspector.HeapProfilerModel.Events.LastSeenObjectId, this._lastSeenOb jectId, this); 1109 SDK.HeapProfilerModel.Events.LastSeenObjectId, this._lastSeenObjectId, t his);
1110 } 1110 }
1111 1111
1112 /** 1112 /**
1113 * @override 1113 * @override
1114 * @param {!WebInspector.Target} target 1114 * @param {!SDK.Target} target
1115 */ 1115 */
1116 targetRemoved(target) { 1116 targetRemoved(target) {
1117 super.targetRemoved(target); 1117 super.targetRemoved(target);
1118 target.heapProfilerModel.removeEventListener( 1118 target.heapProfilerModel.removeEventListener(
1119 WebInspector.HeapProfilerModel.Events.HeapStatsUpdate, this._heapStatsUp date, this); 1119 SDK.HeapProfilerModel.Events.HeapStatsUpdate, this._heapStatsUpdate, thi s);
1120 target.heapProfilerModel.removeEventListener( 1120 target.heapProfilerModel.removeEventListener(
1121 WebInspector.HeapProfilerModel.Events.LastSeenObjectId, this._lastSeenOb jectId, this); 1121 SDK.HeapProfilerModel.Events.LastSeenObjectId, this._lastSeenObjectId, t his);
1122 } 1122 }
1123 1123
1124 /** 1124 /**
1125 * @param {!WebInspector.Event} event 1125 * @param {!Common.Event} event
1126 */ 1126 */
1127 _heapStatsUpdate(event) { 1127 _heapStatsUpdate(event) {
1128 if (!this._profileSamples) 1128 if (!this._profileSamples)
1129 return; 1129 return;
1130 var samples = /** @type {!Array.<number>} */ (event.data); 1130 var samples = /** @type {!Array.<number>} */ (event.data);
1131 var index; 1131 var index;
1132 for (var i = 0; i < samples.length; i += 3) { 1132 for (var i = 0; i < samples.length; i += 3) {
1133 index = samples[i]; 1133 index = samples[i];
1134 var size = samples[i + 2]; 1134 var size = samples[i + 2];
1135 this._profileSamples.sizes[index] = size; 1135 this._profileSamples.sizes[index] = size;
1136 if (!this._profileSamples.max[index]) 1136 if (!this._profileSamples.max[index])
1137 this._profileSamples.max[index] = size; 1137 this._profileSamples.max[index] = size;
1138 } 1138 }
1139 } 1139 }
1140 1140
1141 /** 1141 /**
1142 * @param {!WebInspector.Event} event 1142 * @param {!Common.Event} event
1143 */ 1143 */
1144 _lastSeenObjectId(event) { 1144 _lastSeenObjectId(event) {
1145 var profileSamples = this._profileSamples; 1145 var profileSamples = this._profileSamples;
1146 if (!profileSamples) 1146 if (!profileSamples)
1147 return; 1147 return;
1148 var data = /** @type {{lastSeenObjectId: number, timestamp: number}} */ (eve nt.data); 1148 var data = /** @type {{lastSeenObjectId: number, timestamp: number}} */ (eve nt.data);
1149 var currentIndex = Math.max(profileSamples.ids.length, profileSamples.max.le ngth - 1); 1149 var currentIndex = Math.max(profileSamples.ids.length, profileSamples.max.le ngth - 1);
1150 profileSamples.ids[currentIndex] = data.lastSeenObjectId; 1150 profileSamples.ids[currentIndex] = data.lastSeenObjectId;
1151 if (!profileSamples.max[currentIndex]) { 1151 if (!profileSamples.max[currentIndex]) {
1152 profileSamples.max[currentIndex] = 0; 1152 profileSamples.max[currentIndex] = 0;
1153 profileSamples.sizes[currentIndex] = 0; 1153 profileSamples.sizes[currentIndex] = 0;
1154 } 1154 }
1155 profileSamples.timestamps[currentIndex] = data.timestamp; 1155 profileSamples.timestamps[currentIndex] = data.timestamp;
1156 if (profileSamples.totalTime < data.timestamp - profileSamples.timestamps[0] ) 1156 if (profileSamples.totalTime < data.timestamp - profileSamples.timestamps[0] )
1157 profileSamples.totalTime *= 2; 1157 profileSamples.totalTime *= 2;
1158 this.dispatchEventToListeners(WebInspector.TrackingHeapSnapshotProfileType.H eapStatsUpdate, this._profileSamples); 1158 this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.HeapS tatsUpdate, this._profileSamples);
1159 this._profileBeingRecorded.updateStatus(null, true); 1159 this._profileBeingRecorded.updateStatus(null, true);
1160 } 1160 }
1161 1161
1162 /** 1162 /**
1163 * @override 1163 * @override
1164 * @return {boolean} 1164 * @return {boolean}
1165 */ 1165 */
1166 hasTemporaryView() { 1166 hasTemporaryView() {
1167 return true; 1167 return true;
1168 } 1168 }
1169 1169
1170 get buttonTooltip() { 1170 get buttonTooltip() {
1171 return this._recording ? WebInspector.UIString('Stop recording heap profile' ) : 1171 return this._recording ? Common.UIString('Stop recording heap profile') :
1172 WebInspector.UIString('Start recording heap profile '); 1172 Common.UIString('Start recording heap profile');
1173 } 1173 }
1174 1174
1175 /** 1175 /**
1176 * @override 1176 * @override
1177 * @return {boolean} 1177 * @return {boolean}
1178 */ 1178 */
1179 isInstantProfile() { 1179 isInstantProfile() {
1180 return false; 1180 return false;
1181 } 1181 }
1182 1182
1183 /** 1183 /**
1184 * @override 1184 * @override
1185 * @return {boolean} 1185 * @return {boolean}
1186 */ 1186 */
1187 buttonClicked() { 1187 buttonClicked() {
1188 return this._toggleRecording(); 1188 return this._toggleRecording();
1189 } 1189 }
1190 1190
1191 _startRecordingProfile() { 1191 _startRecordingProfile() {
1192 if (this.profileBeingRecorded()) 1192 if (this.profileBeingRecorded())
1193 return; 1193 return;
1194 this._addNewProfile(); 1194 this._addNewProfile();
1195 var recordAllocationStacks = WebInspector.moduleSetting('recordAllocationSta cks').get(); 1195 var recordAllocationStacks = Common.moduleSetting('recordAllocationStacks'). get();
1196 this.profileBeingRecorded().target().heapProfilerAgent().startTrackingHeapOb jects(recordAllocationStacks); 1196 this.profileBeingRecorded().target().heapProfilerAgent().startTrackingHeapOb jects(recordAllocationStacks);
1197 } 1197 }
1198 1198
1199 _addNewProfile() { 1199 _addNewProfile() {
1200 var target = WebInspector.context.flavor(WebInspector.Target); 1200 var target = UI.context.flavor(SDK.Target);
1201 this.setProfileBeingRecorded(new WebInspector.HeapProfileHeader(target, this , undefined)); 1201 this.setProfileBeingRecorded(new Profiler.HeapProfileHeader(target, this, un defined));
1202 this._profileSamples = new WebInspector.TrackingHeapSnapshotProfileType.Samp les(); 1202 this._profileSamples = new Profiler.TrackingHeapSnapshotProfileType.Samples( );
1203 this._profileBeingRecorded._profileSamples = this._profileSamples; 1203 this._profileBeingRecorded._profileSamples = this._profileSamples;
1204 this._recording = true; 1204 this._recording = true;
1205 this.addProfile(this._profileBeingRecorded); 1205 this.addProfile(this._profileBeingRecorded);
1206 this._profileBeingRecorded.updateStatus(WebInspector.UIString('Recording\u20 26')); 1206 this._profileBeingRecorded.updateStatus(Common.UIString('Recording\u2026'));
1207 this.dispatchEventToListeners(WebInspector.TrackingHeapSnapshotProfileType.T rackingStarted); 1207 this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.Track ingStarted);
1208 } 1208 }
1209 1209
1210 _stopRecordingProfile() { 1210 _stopRecordingProfile() {
1211 this._profileBeingRecorded.updateStatus(WebInspector.UIString('Snapshotting\ u2026')); 1211 this._profileBeingRecorded.updateStatus(Common.UIString('Snapshotting\u2026' ));
1212 /** 1212 /**
1213 * @param {?string} error 1213 * @param {?string} error
1214 * @this {WebInspector.HeapSnapshotProfileType} 1214 * @this {Profiler.HeapSnapshotProfileType}
1215 */ 1215 */
1216 function didTakeHeapSnapshot(error) { 1216 function didTakeHeapSnapshot(error) {
1217 var profile = this.profileBeingRecorded(); 1217 var profile = this.profileBeingRecorded();
1218 if (!profile) 1218 if (!profile)
1219 return; 1219 return;
1220 profile._finishLoad(); 1220 profile._finishLoad();
1221 this._profileSamples = null; 1221 this._profileSamples = null;
1222 this.setProfileBeingRecorded(null); 1222 this.setProfileBeingRecorded(null);
1223 this.dispatchEventToListeners(WebInspector.ProfileType.Events.ProfileCompl ete, profile); 1223 this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete, profile);
1224 } 1224 }
1225 1225
1226 this._profileBeingRecorded.target().heapProfilerAgent().stopTrackingHeapObje cts( 1226 this._profileBeingRecorded.target().heapProfilerAgent().stopTrackingHeapObje cts(
1227 true, didTakeHeapSnapshot.bind(this)); 1227 true, didTakeHeapSnapshot.bind(this));
1228 this._recording = false; 1228 this._recording = false;
1229 this.dispatchEventToListeners(WebInspector.TrackingHeapSnapshotProfileType.T rackingStopped); 1229 this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.Track ingStopped);
1230 } 1230 }
1231 1231
1232 _toggleRecording() { 1232 _toggleRecording() {
1233 if (this._recording) 1233 if (this._recording)
1234 this._stopRecordingProfile(); 1234 this._stopRecordingProfile();
1235 else 1235 else
1236 this._startRecordingProfile(); 1236 this._startRecordingProfile();
1237 return this._recording; 1237 return this._recording;
1238 } 1238 }
1239 1239
1240 /** 1240 /**
1241 * @override 1241 * @override
1242 * @return {string} 1242 * @return {string}
1243 */ 1243 */
1244 fileExtension() { 1244 fileExtension() {
1245 return '.heaptimeline'; 1245 return '.heaptimeline';
1246 } 1246 }
1247 1247
1248 get treeItemTitle() { 1248 get treeItemTitle() {
1249 return WebInspector.UIString('ALLOCATION TIMELINES'); 1249 return Common.UIString('ALLOCATION TIMELINES');
1250 } 1250 }
1251 1251
1252 get description() { 1252 get description() {
1253 return WebInspector.UIString( 1253 return Common.UIString(
1254 'Allocation timelines show memory allocations from your heap over time. Use this profile type to isolate memory leaks.'); 1254 'Allocation timelines show memory allocations from your heap over time. Use this profile type to isolate memory leaks.');
1255 } 1255 }
1256 1256
1257 /** 1257 /**
1258 * @override 1258 * @override
1259 */ 1259 */
1260 _resetProfiles() { 1260 _resetProfiles() {
1261 var wasRecording = this._recording; 1261 var wasRecording = this._recording;
1262 // Clear current profile to avoid stopping backend. 1262 // Clear current profile to avoid stopping backend.
1263 this.setProfileBeingRecorded(null); 1263 this.setProfileBeingRecorded(null);
1264 super._resetProfiles(); 1264 super._resetProfiles();
1265 this._profileSamples = null; 1265 this._profileSamples = null;
1266 if (wasRecording) 1266 if (wasRecording)
1267 this._addNewProfile(); 1267 this._addNewProfile();
1268 } 1268 }
1269 1269
1270 /** 1270 /**
1271 * @override 1271 * @override
1272 */ 1272 */
1273 profileBeingRecordedRemoved() { 1273 profileBeingRecordedRemoved() {
1274 this._stopRecordingProfile(); 1274 this._stopRecordingProfile();
1275 this._profileSamples = null; 1275 this._profileSamples = null;
1276 } 1276 }
1277 }; 1277 };
1278 1278
1279 WebInspector.TrackingHeapSnapshotProfileType.TypeId = 'HEAP-RECORD'; 1279 Profiler.TrackingHeapSnapshotProfileType.TypeId = 'HEAP-RECORD';
1280 1280
1281 WebInspector.TrackingHeapSnapshotProfileType.HeapStatsUpdate = 'HeapStatsUpdate' ; 1281 Profiler.TrackingHeapSnapshotProfileType.HeapStatsUpdate = 'HeapStatsUpdate';
1282 WebInspector.TrackingHeapSnapshotProfileType.TrackingStarted = 'TrackingStarted' ; 1282 Profiler.TrackingHeapSnapshotProfileType.TrackingStarted = 'TrackingStarted';
1283 WebInspector.TrackingHeapSnapshotProfileType.TrackingStopped = 'TrackingStopped' ; 1283 Profiler.TrackingHeapSnapshotProfileType.TrackingStopped = 'TrackingStopped';
1284 1284
1285 /** 1285 /**
1286 * @unrestricted 1286 * @unrestricted
1287 */ 1287 */
1288 WebInspector.TrackingHeapSnapshotProfileType.Samples = class { 1288 Profiler.TrackingHeapSnapshotProfileType.Samples = class {
1289 constructor() { 1289 constructor() {
1290 /** @type {!Array.<number>} */ 1290 /** @type {!Array.<number>} */
1291 this.sizes = []; 1291 this.sizes = [];
1292 /** @type {!Array.<number>} */ 1292 /** @type {!Array.<number>} */
1293 this.ids = []; 1293 this.ids = [];
1294 /** @type {!Array.<number>} */ 1294 /** @type {!Array.<number>} */
1295 this.timestamps = []; 1295 this.timestamps = [];
1296 /** @type {!Array.<number>} */ 1296 /** @type {!Array.<number>} */
1297 this.max = []; 1297 this.max = [];
1298 /** @type {number} */ 1298 /** @type {number} */
1299 this.totalTime = 30000; 1299 this.totalTime = 30000;
1300 } 1300 }
1301 }; 1301 };
1302 1302
1303 /** 1303 /**
1304 * @unrestricted 1304 * @unrestricted
1305 */ 1305 */
1306 WebInspector.HeapProfileHeader = class extends WebInspector.ProfileHeader { 1306 Profiler.HeapProfileHeader = class extends Profiler.ProfileHeader {
1307 /** 1307 /**
1308 * @param {?WebInspector.Target} target 1308 * @param {?SDK.Target} target
1309 * @param {!WebInspector.HeapSnapshotProfileType} type 1309 * @param {!Profiler.HeapSnapshotProfileType} type
1310 * @param {string=} title 1310 * @param {string=} title
1311 */ 1311 */
1312 constructor(target, type, title) { 1312 constructor(target, type, title) {
1313 super(target, type, title || WebInspector.UIString('Snapshot %d', type.nextP rofileUid())); 1313 super(target, type, title || Common.UIString('Snapshot %d', type.nextProfile Uid()));
1314 this.maxJSObjectId = -1; 1314 this.maxJSObjectId = -1;
1315 /** 1315 /**
1316 * @type {?WebInspector.HeapSnapshotWorkerProxy} 1316 * @type {?Profiler.HeapSnapshotWorkerProxy}
1317 */ 1317 */
1318 this._workerProxy = null; 1318 this._workerProxy = null;
1319 /** 1319 /**
1320 * @type {?WebInspector.OutputStream} 1320 * @type {?Common.OutputStream}
1321 */ 1321 */
1322 this._receiver = null; 1322 this._receiver = null;
1323 /** 1323 /**
1324 * @type {?WebInspector.HeapSnapshotProxy} 1324 * @type {?Profiler.HeapSnapshotProxy}
1325 */ 1325 */
1326 this._snapshotProxy = null; 1326 this._snapshotProxy = null;
1327 /** 1327 /**
1328 * @type {!Promise.<!WebInspector.HeapSnapshotProxy>} 1328 * @type {!Promise.<!Profiler.HeapSnapshotProxy>}
1329 */ 1329 */
1330 this._loadPromise = new Promise(loadResolver.bind(this)); 1330 this._loadPromise = new Promise(loadResolver.bind(this));
1331 this._totalNumberOfChunks = 0; 1331 this._totalNumberOfChunks = 0;
1332 this._bufferedWriter = null; 1332 this._bufferedWriter = null;
1333 1333
1334 /** 1334 /**
1335 * @param {function(!WebInspector.HeapSnapshotProxy)} fulfill 1335 * @param {function(!Profiler.HeapSnapshotProxy)} fulfill
1336 * @this {WebInspector.HeapProfileHeader} 1336 * @this {Profiler.HeapProfileHeader}
1337 */ 1337 */
1338 function loadResolver(fulfill) { 1338 function loadResolver(fulfill) {
1339 this._fulfillLoad = fulfill; 1339 this._fulfillLoad = fulfill;
1340 } 1340 }
1341 } 1341 }
1342 1342
1343 /** 1343 /**
1344 * @override 1344 * @override
1345 * @param {!WebInspector.ProfileType.DataDisplayDelegate} dataDisplayDelegate 1345 * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate
1346 * @return {!WebInspector.ProfileSidebarTreeElement} 1346 * @return {!Profiler.ProfileSidebarTreeElement}
1347 */ 1347 */
1348 createSidebarTreeElement(dataDisplayDelegate) { 1348 createSidebarTreeElement(dataDisplayDelegate) {
1349 return new WebInspector.ProfileSidebarTreeElement(dataDisplayDelegate, this, 'heap-snapshot-sidebar-tree-item'); 1349 return new Profiler.ProfileSidebarTreeElement(dataDisplayDelegate, this, 'he ap-snapshot-sidebar-tree-item');
1350 } 1350 }
1351 1351
1352 /** 1352 /**
1353 * @override 1353 * @override
1354 * @param {!WebInspector.ProfileType.DataDisplayDelegate} dataDisplayDelegate 1354 * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate
1355 * @return {!WebInspector.HeapSnapshotView} 1355 * @return {!Profiler.HeapSnapshotView}
1356 */ 1356 */
1357 createView(dataDisplayDelegate) { 1357 createView(dataDisplayDelegate) {
1358 return new WebInspector.HeapSnapshotView(dataDisplayDelegate, this); 1358 return new Profiler.HeapSnapshotView(dataDisplayDelegate, this);
1359 } 1359 }
1360 1360
1361 _prepareToLoad() { 1361 _prepareToLoad() {
1362 console.assert(!this._receiver, 'Already loading'); 1362 console.assert(!this._receiver, 'Already loading');
1363 this._setupWorker(); 1363 this._setupWorker();
1364 this.updateStatus(WebInspector.UIString('Loading\u2026'), true); 1364 this.updateStatus(Common.UIString('Loading\u2026'), true);
1365 } 1365 }
1366 1366
1367 _finishLoad() { 1367 _finishLoad() {
1368 if (!this._wasDisposed) 1368 if (!this._wasDisposed)
1369 this._receiver.close(); 1369 this._receiver.close();
1370 if (this._bufferedWriter) { 1370 if (this._bufferedWriter) {
1371 this._bufferedWriter.finishWriting(this._didWriteToTempFile.bind(this)); 1371 this._bufferedWriter.finishWriting(this._didWriteToTempFile.bind(this));
1372 this._bufferedWriter = null; 1372 this._bufferedWriter = null;
1373 } 1373 }
1374 } 1374 }
1375 1375
1376 _didWriteToTempFile(tempFile) { 1376 _didWriteToTempFile(tempFile) {
1377 if (this._wasDisposed) { 1377 if (this._wasDisposed) {
1378 if (tempFile) 1378 if (tempFile)
1379 tempFile.remove(); 1379 tempFile.remove();
1380 return; 1380 return;
1381 } 1381 }
1382 this._tempFile = tempFile; 1382 this._tempFile = tempFile;
1383 if (!tempFile) 1383 if (!tempFile)
1384 this._failedToCreateTempFile = true; 1384 this._failedToCreateTempFile = true;
1385 if (this._onTempFileReady) { 1385 if (this._onTempFileReady) {
1386 this._onTempFileReady(); 1386 this._onTempFileReady();
1387 this._onTempFileReady = null; 1387 this._onTempFileReady = null;
1388 } 1388 }
1389 } 1389 }
1390 1390
1391 _setupWorker() { 1391 _setupWorker() {
1392 /** 1392 /**
1393 * @this {WebInspector.HeapProfileHeader} 1393 * @this {Profiler.HeapProfileHeader}
1394 */ 1394 */
1395 function setProfileWait(event) { 1395 function setProfileWait(event) {
1396 this.updateStatus(null, event.data); 1396 this.updateStatus(null, event.data);
1397 } 1397 }
1398 console.assert(!this._workerProxy, 'HeapSnapshotWorkerProxy already exists') ; 1398 console.assert(!this._workerProxy, 'HeapSnapshotWorkerProxy already exists') ;
1399 this._workerProxy = new WebInspector.HeapSnapshotWorkerProxy(this._handleWor kerEvent.bind(this)); 1399 this._workerProxy = new Profiler.HeapSnapshotWorkerProxy(this._handleWorkerE vent.bind(this));
1400 this._workerProxy.addEventListener('wait', setProfileWait, this); 1400 this._workerProxy.addEventListener('wait', setProfileWait, this);
1401 this._receiver = this._workerProxy.createLoader(this.uid, this._snapshotRece ived.bind(this)); 1401 this._receiver = this._workerProxy.createLoader(this.uid, this._snapshotRece ived.bind(this));
1402 } 1402 }
1403 1403
1404 /** 1404 /**
1405 * @param {string} eventName 1405 * @param {string} eventName
1406 * @param {*} data 1406 * @param {*} data
1407 */ 1407 */
1408 _handleWorkerEvent(eventName, data) { 1408 _handleWorkerEvent(eventName, data) {
1409 if (WebInspector.HeapSnapshotProgressEvent.BrokenSnapshot === eventName) { 1409 if (Profiler.HeapSnapshotProgressEvent.BrokenSnapshot === eventName) {
1410 var error = /** @type {string} */ (data); 1410 var error = /** @type {string} */ (data);
1411 WebInspector.console.error(error); 1411 Common.console.error(error);
1412 return; 1412 return;
1413 } 1413 }
1414 1414
1415 if (WebInspector.HeapSnapshotProgressEvent.Update !== eventName) 1415 if (Profiler.HeapSnapshotProgressEvent.Update !== eventName)
1416 return; 1416 return;
1417 var subtitle = /** @type {string} */ (data); 1417 var subtitle = /** @type {string} */ (data);
1418 this.updateStatus(subtitle); 1418 this.updateStatus(subtitle);
1419 } 1419 }
1420 1420
1421 /** 1421 /**
1422 * @override 1422 * @override
1423 */ 1423 */
1424 dispose() { 1424 dispose() {
1425 if (this._workerProxy) 1425 if (this._workerProxy)
1426 this._workerProxy.dispose(); 1426 this._workerProxy.dispose();
1427 this.removeTempFile(); 1427 this.removeTempFile();
1428 this._wasDisposed = true; 1428 this._wasDisposed = true;
1429 } 1429 }
1430 1430
1431 _didCompleteSnapshotTransfer() { 1431 _didCompleteSnapshotTransfer() {
1432 if (!this._snapshotProxy) 1432 if (!this._snapshotProxy)
1433 return; 1433 return;
1434 this.updateStatus(Number.bytesToString(this._snapshotProxy.totalSize), false ); 1434 this.updateStatus(Number.bytesToString(this._snapshotProxy.totalSize), false );
1435 } 1435 }
1436 1436
1437 /** 1437 /**
1438 * @param {string} chunk 1438 * @param {string} chunk
1439 */ 1439 */
1440 transferChunk(chunk) { 1440 transferChunk(chunk) {
1441 if (!this._bufferedWriter) 1441 if (!this._bufferedWriter)
1442 this._bufferedWriter = new WebInspector.DeferredTempFile('heap-profiler', String(this.uid)); 1442 this._bufferedWriter = new Bindings.DeferredTempFile('heap-profiler', Stri ng(this.uid));
1443 this._bufferedWriter.write([chunk]); 1443 this._bufferedWriter.write([chunk]);
1444 1444
1445 ++this._totalNumberOfChunks; 1445 ++this._totalNumberOfChunks;
1446 this._receiver.write(chunk); 1446 this._receiver.write(chunk);
1447 } 1447 }
1448 1448
1449 _snapshotReceived(snapshotProxy) { 1449 _snapshotReceived(snapshotProxy) {
1450 if (this._wasDisposed) 1450 if (this._wasDisposed)
1451 return; 1451 return;
1452 this._receiver = null; 1452 this._receiver = null;
1453 this._snapshotProxy = snapshotProxy; 1453 this._snapshotProxy = snapshotProxy;
1454 this.maxJSObjectId = snapshotProxy.maxJSObjectId(); 1454 this.maxJSObjectId = snapshotProxy.maxJSObjectId();
1455 this._didCompleteSnapshotTransfer(); 1455 this._didCompleteSnapshotTransfer();
1456 this._workerProxy.startCheckingForLongRunningCalls(); 1456 this._workerProxy.startCheckingForLongRunningCalls();
1457 this.notifySnapshotReceived(); 1457 this.notifySnapshotReceived();
1458 } 1458 }
1459 1459
1460 notifySnapshotReceived() { 1460 notifySnapshotReceived() {
1461 this._fulfillLoad(this._snapshotProxy); 1461 this._fulfillLoad(this._snapshotProxy);
1462 this._profileType._snapshotReceived(this); 1462 this._profileType._snapshotReceived(this);
1463 if (this.canSaveToFile()) 1463 if (this.canSaveToFile())
1464 this.dispatchEventToListeners(WebInspector.ProfileHeader.Events.ProfileRec eived); 1464 this.dispatchEventToListeners(Profiler.ProfileHeader.Events.ProfileReceive d);
1465 } 1465 }
1466 1466
1467 // Hook point for tests. 1467 // Hook point for tests.
1468 _wasShown() { 1468 _wasShown() {
1469 } 1469 }
1470 1470
1471 /** 1471 /**
1472 * @override 1472 * @override
1473 * @return {boolean} 1473 * @return {boolean}
1474 */ 1474 */
1475 canSaveToFile() { 1475 canSaveToFile() {
1476 return !this.fromFile() && !!this._snapshotProxy; 1476 return !this.fromFile() && !!this._snapshotProxy;
1477 } 1477 }
1478 1478
1479 /** 1479 /**
1480 * @override 1480 * @override
1481 */ 1481 */
1482 saveToFile() { 1482 saveToFile() {
1483 var fileOutputStream = new WebInspector.FileOutputStream(); 1483 var fileOutputStream = new Bindings.FileOutputStream();
1484 1484
1485 /** 1485 /**
1486 * @param {boolean} accepted 1486 * @param {boolean} accepted
1487 * @this {WebInspector.HeapProfileHeader} 1487 * @this {Profiler.HeapProfileHeader}
1488 */ 1488 */
1489 function onOpen(accepted) { 1489 function onOpen(accepted) {
1490 if (!accepted) 1490 if (!accepted)
1491 return; 1491 return;
1492 if (this._failedToCreateTempFile) { 1492 if (this._failedToCreateTempFile) {
1493 WebInspector.console.error('Failed to open temp file with heap snapshot' ); 1493 Common.console.error('Failed to open temp file with heap snapshot');
1494 fileOutputStream.close(); 1494 fileOutputStream.close();
1495 } else if (this._tempFile) { 1495 } else if (this._tempFile) {
1496 var delegate = new WebInspector.SaveSnapshotOutputStreamDelegate(this); 1496 var delegate = new Profiler.SaveSnapshotOutputStreamDelegate(this);
1497 this._tempFile.copyToOutputStream(fileOutputStream, delegate); 1497 this._tempFile.copyToOutputStream(fileOutputStream, delegate);
1498 } else { 1498 } else {
1499 this._onTempFileReady = onOpen.bind(this, accepted); 1499 this._onTempFileReady = onOpen.bind(this, accepted);
1500 this._updateSaveProgress(0, 1); 1500 this._updateSaveProgress(0, 1);
1501 } 1501 }
1502 } 1502 }
1503 this._fileName = this._fileName || 'Heap-' + new Date().toISO8601Compact() + this._profileType.fileExtension(); 1503 this._fileName = this._fileName || 'Heap-' + new Date().toISO8601Compact() + this._profileType.fileExtension();
1504 fileOutputStream.open(this._fileName, onOpen.bind(this)); 1504 fileOutputStream.open(this._fileName, onOpen.bind(this));
1505 } 1505 }
1506 1506
1507 _updateSaveProgress(value, total) { 1507 _updateSaveProgress(value, total) {
1508 var percentValue = ((total ? (value / total) : 0) * 100).toFixed(0); 1508 var percentValue = ((total ? (value / total) : 0) * 100).toFixed(0);
1509 this.updateStatus(WebInspector.UIString('Saving\u2026 %d%%', percentValue)); 1509 this.updateStatus(Common.UIString('Saving\u2026 %d%%', percentValue));
1510 } 1510 }
1511 1511
1512 /** 1512 /**
1513 * @override 1513 * @override
1514 * @param {!File} file 1514 * @param {!File} file
1515 */ 1515 */
1516 loadFromFile(file) { 1516 loadFromFile(file) {
1517 this.updateStatus(WebInspector.UIString('Loading\u2026'), true); 1517 this.updateStatus(Common.UIString('Loading\u2026'), true);
1518 this._setupWorker(); 1518 this._setupWorker();
1519 var delegate = new WebInspector.HeapSnapshotLoadFromFileDelegate(this); 1519 var delegate = new Profiler.HeapSnapshotLoadFromFileDelegate(this);
1520 var fileReader = this._createFileReader(file, delegate); 1520 var fileReader = this._createFileReader(file, delegate);
1521 fileReader.start(this._receiver); 1521 fileReader.start(this._receiver);
1522 } 1522 }
1523 1523
1524 _createFileReader(file, delegate) { 1524 _createFileReader(file, delegate) {
1525 return new WebInspector.ChunkedFileReader(file, 10000000, delegate); 1525 return new Bindings.ChunkedFileReader(file, 10000000, delegate);
1526 } 1526 }
1527 }; 1527 };
1528 1528
1529 /** 1529 /**
1530 * @implements {WebInspector.OutputStreamDelegate} 1530 * @implements {Bindings.OutputStreamDelegate}
1531 * @unrestricted 1531 * @unrestricted
1532 */ 1532 */
1533 WebInspector.HeapSnapshotLoadFromFileDelegate = class { 1533 Profiler.HeapSnapshotLoadFromFileDelegate = class {
1534 constructor(snapshotHeader) { 1534 constructor(snapshotHeader) {
1535 this._snapshotHeader = snapshotHeader; 1535 this._snapshotHeader = snapshotHeader;
1536 } 1536 }
1537 1537
1538 /** 1538 /**
1539 * @override 1539 * @override
1540 */ 1540 */
1541 onTransferStarted() { 1541 onTransferStarted() {
1542 } 1542 }
1543 1543
1544 /** 1544 /**
1545 * @override 1545 * @override
1546 * @param {!WebInspector.ChunkedReader} reader 1546 * @param {!Bindings.ChunkedReader} reader
1547 */ 1547 */
1548 onChunkTransferred(reader) { 1548 onChunkTransferred(reader) {
1549 } 1549 }
1550 1550
1551 /** 1551 /**
1552 * @override 1552 * @override
1553 */ 1553 */
1554 onTransferFinished() { 1554 onTransferFinished() {
1555 } 1555 }
1556 1556
1557 /** 1557 /**
1558 * @override 1558 * @override
1559 * @param {!WebInspector.ChunkedReader} reader 1559 * @param {!Bindings.ChunkedReader} reader
1560 * @param {!Event} e 1560 * @param {!Event} e
1561 */ 1561 */
1562 onError(reader, e) { 1562 onError(reader, e) {
1563 var subtitle; 1563 var subtitle;
1564 switch (e.target.error.code) { 1564 switch (e.target.error.code) {
1565 case e.target.error.NOT_FOUND_ERR: 1565 case e.target.error.NOT_FOUND_ERR:
1566 subtitle = WebInspector.UIString('\'%s\' not found.', reader.fileName()) ; 1566 subtitle = Common.UIString('\'%s\' not found.', reader.fileName());
1567 break; 1567 break;
1568 case e.target.error.NOT_READABLE_ERR: 1568 case e.target.error.NOT_READABLE_ERR:
1569 subtitle = WebInspector.UIString('\'%s\' is not readable', reader.fileNa me()); 1569 subtitle = Common.UIString('\'%s\' is not readable', reader.fileName());
1570 break; 1570 break;
1571 case e.target.error.ABORT_ERR: 1571 case e.target.error.ABORT_ERR:
1572 return; 1572 return;
1573 default: 1573 default:
1574 subtitle = WebInspector.UIString('\'%s\' error %d', reader.fileName(), e .target.error.code); 1574 subtitle = Common.UIString('\'%s\' error %d', reader.fileName(), e.targe t.error.code);
1575 } 1575 }
1576 this._snapshotHeader.updateStatus(subtitle); 1576 this._snapshotHeader.updateStatus(subtitle);
1577 } 1577 }
1578 }; 1578 };
1579 1579
1580 /** 1580 /**
1581 * @implements {WebInspector.OutputStreamDelegate} 1581 * @implements {Bindings.OutputStreamDelegate}
1582 * @unrestricted 1582 * @unrestricted
1583 */ 1583 */
1584 WebInspector.SaveSnapshotOutputStreamDelegate = class { 1584 Profiler.SaveSnapshotOutputStreamDelegate = class {
1585 /** 1585 /**
1586 * @param {!WebInspector.HeapProfileHeader} profileHeader 1586 * @param {!Profiler.HeapProfileHeader} profileHeader
1587 */ 1587 */
1588 constructor(profileHeader) { 1588 constructor(profileHeader) {
1589 this._profileHeader = profileHeader; 1589 this._profileHeader = profileHeader;
1590 } 1590 }
1591 1591
1592 /** 1592 /**
1593 * @override 1593 * @override
1594 */ 1594 */
1595 onTransferStarted() { 1595 onTransferStarted() {
1596 this._profileHeader._updateSaveProgress(0, 1); 1596 this._profileHeader._updateSaveProgress(0, 1);
1597 } 1597 }
1598 1598
1599 /** 1599 /**
1600 * @override 1600 * @override
1601 */ 1601 */
1602 onTransferFinished() { 1602 onTransferFinished() {
1603 this._profileHeader._didCompleteSnapshotTransfer(); 1603 this._profileHeader._didCompleteSnapshotTransfer();
1604 } 1604 }
1605 1605
1606 /** 1606 /**
1607 * @override 1607 * @override
1608 * @param {!WebInspector.ChunkedReader} reader 1608 * @param {!Bindings.ChunkedReader} reader
1609 */ 1609 */
1610 onChunkTransferred(reader) { 1610 onChunkTransferred(reader) {
1611 this._profileHeader._updateSaveProgress(reader.loadedSize(), reader.fileSize ()); 1611 this._profileHeader._updateSaveProgress(reader.loadedSize(), reader.fileSize ());
1612 } 1612 }
1613 1613
1614 /** 1614 /**
1615 * @override 1615 * @override
1616 * @param {!WebInspector.ChunkedReader} reader 1616 * @param {!Bindings.ChunkedReader} reader
1617 * @param {!Event} event 1617 * @param {!Event} event
1618 */ 1618 */
1619 onError(reader, event) { 1619 onError(reader, event) {
1620 WebInspector.console.error( 1620 Common.console.error(
1621 'Failed to read heap snapshot from temp file: ' + /** @type {!ErrorEvent } */ (event).message); 1621 'Failed to read heap snapshot from temp file: ' + /** @type {!ErrorEvent } */ (event).message);
1622 this.onTransferFinished(); 1622 this.onTransferFinished();
1623 } 1623 }
1624 }; 1624 };
1625 1625
1626 /** 1626 /**
1627 * @unrestricted 1627 * @unrestricted
1628 */ 1628 */
1629 WebInspector.HeapTrackingOverviewGrid = class extends WebInspector.VBox { 1629 Profiler.HeapTrackingOverviewGrid = class extends UI.VBox {
1630 /** 1630 /**
1631 * @param {!WebInspector.HeapProfileHeader} heapProfileHeader 1631 * @param {!Profiler.HeapProfileHeader} heapProfileHeader
1632 */ 1632 */
1633 constructor(heapProfileHeader) { 1633 constructor(heapProfileHeader) {
1634 super(); 1634 super();
1635 this.element.id = 'heap-recording-view'; 1635 this.element.id = 'heap-recording-view';
1636 this.element.classList.add('heap-tracking-overview'); 1636 this.element.classList.add('heap-tracking-overview');
1637 1637
1638 this._overviewContainer = this.element.createChild('div', 'heap-overview-con tainer'); 1638 this._overviewContainer = this.element.createChild('div', 'heap-overview-con tainer');
1639 this._overviewGrid = new WebInspector.OverviewGrid('heap-recording'); 1639 this._overviewGrid = new UI.OverviewGrid('heap-recording');
1640 this._overviewGrid.element.classList.add('fill'); 1640 this._overviewGrid.element.classList.add('fill');
1641 1641
1642 this._overviewCanvas = this._overviewContainer.createChild('canvas', 'heap-r ecording-overview-canvas'); 1642 this._overviewCanvas = this._overviewContainer.createChild('canvas', 'heap-r ecording-overview-canvas');
1643 this._overviewContainer.appendChild(this._overviewGrid.element); 1643 this._overviewContainer.appendChild(this._overviewGrid.element);
1644 this._overviewCalculator = new WebInspector.HeapTrackingOverviewGrid.Overvie wCalculator(); 1644 this._overviewCalculator = new Profiler.HeapTrackingOverviewGrid.OverviewCal culator();
1645 this._overviewGrid.addEventListener(WebInspector.OverviewGrid.Events.WindowC hanged, this._onWindowChanged, this); 1645 this._overviewGrid.addEventListener(UI.OverviewGrid.Events.WindowChanged, th is._onWindowChanged, this);
1646 1646
1647 this._profileSamples = heapProfileHeader.fromFile() ? new WebInspector.Track ingHeapSnapshotProfileType.Samples() : 1647 this._profileSamples = heapProfileHeader.fromFile() ? new Profiler.TrackingH eapSnapshotProfileType.Samples() :
1648 heapProfileHeader._pro fileSamples; 1648 heapProfileHeader._pro fileSamples;
1649 this._profileType = heapProfileHeader.profileType(); 1649 this._profileType = heapProfileHeader.profileType();
1650 if (!heapProfileHeader.fromFile() && heapProfileHeader.profileType().profile BeingRecorded() === heapProfileHeader) { 1650 if (!heapProfileHeader.fromFile() && heapProfileHeader.profileType().profile BeingRecorded() === heapProfileHeader) {
1651 this._profileType.addEventListener( 1651 this._profileType.addEventListener(
1652 WebInspector.TrackingHeapSnapshotProfileType.HeapStatsUpdate, this._on HeapStatsUpdate, this); 1652 Profiler.TrackingHeapSnapshotProfileType.HeapStatsUpdate, this._onHeap StatsUpdate, this);
1653 this._profileType.addEventListener( 1653 this._profileType.addEventListener(
1654 WebInspector.TrackingHeapSnapshotProfileType.TrackingStopped, this._on StopTracking, this); 1654 Profiler.TrackingHeapSnapshotProfileType.TrackingStopped, this._onStop Tracking, this);
1655 } 1655 }
1656 this._windowLeft = 0.0; 1656 this._windowLeft = 0.0;
1657 this._windowRight = 1.0; 1657 this._windowRight = 1.0;
1658 this._overviewGrid.setWindow(this._windowLeft, this._windowRight); 1658 this._overviewGrid.setWindow(this._windowLeft, this._windowRight);
1659 this._yScale = new WebInspector.HeapTrackingOverviewGrid.SmoothScale(); 1659 this._yScale = new Profiler.HeapTrackingOverviewGrid.SmoothScale();
1660 this._xScale = new WebInspector.HeapTrackingOverviewGrid.SmoothScale(); 1660 this._xScale = new Profiler.HeapTrackingOverviewGrid.SmoothScale();
1661 } 1661 }
1662 1662
1663 dispose() { 1663 dispose() {
1664 this._onStopTracking(); 1664 this._onStopTracking();
1665 } 1665 }
1666 1666
1667 _onStopTracking() { 1667 _onStopTracking() {
1668 this._profileType.removeEventListener( 1668 this._profileType.removeEventListener(
1669 WebInspector.TrackingHeapSnapshotProfileType.HeapStatsUpdate, this._onHe apStatsUpdate, this); 1669 Profiler.TrackingHeapSnapshotProfileType.HeapStatsUpdate, this._onHeapSt atsUpdate, this);
1670 this._profileType.removeEventListener( 1670 this._profileType.removeEventListener(
1671 WebInspector.TrackingHeapSnapshotProfileType.TrackingStopped, this._onSt opTracking, this); 1671 Profiler.TrackingHeapSnapshotProfileType.TrackingStopped, this._onStopTr acking, this);
1672 } 1672 }
1673 1673
1674 _onHeapStatsUpdate(event) { 1674 _onHeapStatsUpdate(event) {
1675 this._profileSamples = event.data; 1675 this._profileSamples = event.data;
1676 this._scheduleUpdate(); 1676 this._scheduleUpdate();
1677 } 1677 }
1678 1678
1679 /** 1679 /**
1680 * @param {?WebInspector.HeapSnapshotCommon.Samples} samples 1680 * @param {?Profiler.HeapSnapshotCommon.Samples} samples
1681 */ 1681 */
1682 _setSamples(samples) { 1682 _setSamples(samples) {
1683 if (!samples) 1683 if (!samples)
1684 return; 1684 return;
1685 console.assert(!this._profileSamples.timestamps.length, 'Should only call th is method when loading from file.'); 1685 console.assert(!this._profileSamples.timestamps.length, 'Should only call th is method when loading from file.');
1686 console.assert(samples.timestamps.length); 1686 console.assert(samples.timestamps.length);
1687 this._profileSamples = new WebInspector.TrackingHeapSnapshotProfileType.Samp les(); 1687 this._profileSamples = new Profiler.TrackingHeapSnapshotProfileType.Samples( );
1688 this._profileSamples.sizes = samples.sizes; 1688 this._profileSamples.sizes = samples.sizes;
1689 this._profileSamples.ids = samples.lastAssignedIds; 1689 this._profileSamples.ids = samples.lastAssignedIds;
1690 this._profileSamples.timestamps = samples.timestamps; 1690 this._profileSamples.timestamps = samples.timestamps;
1691 this._profileSamples.max = samples.sizes; 1691 this._profileSamples.max = samples.sizes;
1692 this._profileSamples.totalTime = /** @type{number} */ (samples.timestamps.pe ekLast()); 1692 this._profileSamples.totalTime = /** @type{number} */ (samples.timestamps.pe ekLast());
1693 this.update(); 1693 this.update();
1694 } 1694 }
1695 1695
1696 /** 1696 /**
1697 * @param {number} width 1697 * @param {number} width
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 break; 1876 break;
1877 maxId = ids[i]; 1877 maxId = ids[i];
1878 if (timestamps[i] < timeLeft) { 1878 if (timestamps[i] < timeLeft) {
1879 minId = ids[i]; 1879 minId = ids[i];
1880 continue; 1880 continue;
1881 } 1881 }
1882 size += sizes[i]; 1882 size += sizes[i];
1883 } 1883 }
1884 1884
1885 this.dispatchEventToListeners( 1885 this.dispatchEventToListeners(
1886 WebInspector.HeapTrackingOverviewGrid.IdsRangeChanged, {minId: minId, ma xId: maxId, size: size}); 1886 Profiler.HeapTrackingOverviewGrid.IdsRangeChanged, {minId: minId, maxId: maxId, size: size});
1887 } 1887 }
1888 }; 1888 };
1889 1889
1890 WebInspector.HeapTrackingOverviewGrid.IdsRangeChanged = 'IdsRangeChanged'; 1890 Profiler.HeapTrackingOverviewGrid.IdsRangeChanged = 'IdsRangeChanged';
1891 1891
1892 /** 1892 /**
1893 * @unrestricted 1893 * @unrestricted
1894 */ 1894 */
1895 WebInspector.HeapTrackingOverviewGrid.SmoothScale = class { 1895 Profiler.HeapTrackingOverviewGrid.SmoothScale = class {
1896 constructor() { 1896 constructor() {
1897 this._lastUpdate = 0; 1897 this._lastUpdate = 0;
1898 this._currentScale = 0.0; 1898 this._currentScale = 0.0;
1899 } 1899 }
1900 1900
1901 /** 1901 /**
1902 * @param {number} target 1902 * @param {number} target
1903 * @return {number} 1903 * @return {number}
1904 */ 1904 */
1905 nextScale(target) { 1905 nextScale(target) {
1906 target = target || this._currentScale; 1906 target = target || this._currentScale;
1907 if (this._currentScale) { 1907 if (this._currentScale) {
1908 var now = Date.now(); 1908 var now = Date.now();
1909 var timeDeltaMs = now - this._lastUpdate; 1909 var timeDeltaMs = now - this._lastUpdate;
1910 this._lastUpdate = now; 1910 this._lastUpdate = now;
1911 var maxChangePerSec = 20; 1911 var maxChangePerSec = 20;
1912 var maxChangePerDelta = Math.pow(maxChangePerSec, timeDeltaMs / 1000); 1912 var maxChangePerDelta = Math.pow(maxChangePerSec, timeDeltaMs / 1000);
1913 var scaleChange = target / this._currentScale; 1913 var scaleChange = target / this._currentScale;
1914 this._currentScale *= Number.constrain(scaleChange, 1 / maxChangePerDelta, maxChangePerDelta); 1914 this._currentScale *= Number.constrain(scaleChange, 1 / maxChangePerDelta, maxChangePerDelta);
1915 } else { 1915 } else {
1916 this._currentScale = target; 1916 this._currentScale = target;
1917 } 1917 }
1918 return this._currentScale; 1918 return this._currentScale;
1919 } 1919 }
1920 }; 1920 };
1921 1921
1922 /** 1922 /**
1923 * @implements {WebInspector.TimelineGrid.Calculator} 1923 * @implements {UI.TimelineGrid.Calculator}
1924 * @unrestricted 1924 * @unrestricted
1925 */ 1925 */
1926 WebInspector.HeapTrackingOverviewGrid.OverviewCalculator = class { 1926 Profiler.HeapTrackingOverviewGrid.OverviewCalculator = class {
1927 /** 1927 /**
1928 * @override 1928 * @override
1929 * @return {number} 1929 * @return {number}
1930 */ 1930 */
1931 paddingLeft() { 1931 paddingLeft() {
1932 return 0; 1932 return 0;
1933 } 1933 }
1934 1934
1935 /** 1935 /**
1936 * @param {!WebInspector.HeapTrackingOverviewGrid} chart 1936 * @param {!Profiler.HeapTrackingOverviewGrid} chart
1937 */ 1937 */
1938 _updateBoundaries(chart) { 1938 _updateBoundaries(chart) {
1939 this._minimumBoundaries = 0; 1939 this._minimumBoundaries = 0;
1940 this._maximumBoundaries = chart._profileSamples.totalTime; 1940 this._maximumBoundaries = chart._profileSamples.totalTime;
1941 this._xScaleFactor = chart._overviewContainer.clientWidth / this._maximumBou ndaries; 1941 this._xScaleFactor = chart._overviewContainer.clientWidth / this._maximumBou ndaries;
1942 } 1942 }
1943 1943
1944 /** 1944 /**
1945 * @override 1945 * @override
1946 * @param {number} time 1946 * @param {number} time
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 * @return {number} 1989 * @return {number}
1990 */ 1990 */
1991 boundarySpan() { 1991 boundarySpan() {
1992 return this._maximumBoundaries - this._minimumBoundaries; 1992 return this._maximumBoundaries - this._minimumBoundaries;
1993 } 1993 }
1994 }; 1994 };
1995 1995
1996 /** 1996 /**
1997 * @unrestricted 1997 * @unrestricted
1998 */ 1998 */
1999 WebInspector.HeapSnapshotStatisticsView = class extends WebInspector.VBox { 1999 Profiler.HeapSnapshotStatisticsView = class extends UI.VBox {
2000 constructor() { 2000 constructor() {
2001 super(); 2001 super();
2002 this.setMinimumSize(50, 25); 2002 this.setMinimumSize(50, 25);
2003 this._pieChart = new WebInspector.PieChart(150, WebInspector.HeapSnapshotSta tisticsView._valueFormatter, true); 2003 this._pieChart = new UI.PieChart(150, Profiler.HeapSnapshotStatisticsView._v alueFormatter, true);
2004 this._pieChart.element.classList.add('heap-snapshot-stats-pie-chart'); 2004 this._pieChart.element.classList.add('heap-snapshot-stats-pie-chart');
2005 this.element.appendChild(this._pieChart.element); 2005 this.element.appendChild(this._pieChart.element);
2006 this._labels = this.element.createChild('div', 'heap-snapshot-stats-legend') ; 2006 this._labels = this.element.createChild('div', 'heap-snapshot-stats-legend') ;
2007 } 2007 }
2008 2008
2009 /** 2009 /**
2010 * @param {number} value 2010 * @param {number} value
2011 * @return {string} 2011 * @return {string}
2012 */ 2012 */
2013 static _valueFormatter(value) { 2013 static _valueFormatter(value) {
2014 return WebInspector.UIString('%s KB', Number.withThousandsSeparator(Math.rou nd(value / 1024))); 2014 return Common.UIString('%s KB', Number.withThousandsSeparator(Math.round(val ue / 1024)));
2015 } 2015 }
2016 2016
2017 /** 2017 /**
2018 * @param {number} value 2018 * @param {number} value
2019 */ 2019 */
2020 setTotal(value) { 2020 setTotal(value) {
2021 this._pieChart.setTotal(value); 2021 this._pieChart.setTotal(value);
2022 } 2022 }
2023 2023
2024 /** 2024 /**
2025 * @param {number} value 2025 * @param {number} value
2026 * @param {string} name 2026 * @param {string} name
2027 * @param {string=} color 2027 * @param {string=} color
2028 */ 2028 */
2029 addRecord(value, name, color) { 2029 addRecord(value, name, color) {
2030 if (color) 2030 if (color)
2031 this._pieChart.addSlice(value, color); 2031 this._pieChart.addSlice(value, color);
2032 2032
2033 var node = this._labels.createChild('div'); 2033 var node = this._labels.createChild('div');
2034 var swatchDiv = node.createChild('div', 'heap-snapshot-stats-swatch'); 2034 var swatchDiv = node.createChild('div', 'heap-snapshot-stats-swatch');
2035 var nameDiv = node.createChild('div', 'heap-snapshot-stats-name'); 2035 var nameDiv = node.createChild('div', 'heap-snapshot-stats-name');
2036 var sizeDiv = node.createChild('div', 'heap-snapshot-stats-size'); 2036 var sizeDiv = node.createChild('div', 'heap-snapshot-stats-size');
2037 if (color) 2037 if (color)
2038 swatchDiv.style.backgroundColor = color; 2038 swatchDiv.style.backgroundColor = color;
2039 else 2039 else
2040 swatchDiv.classList.add('heap-snapshot-stats-empty-swatch'); 2040 swatchDiv.classList.add('heap-snapshot-stats-empty-swatch');
2041 nameDiv.textContent = name; 2041 nameDiv.textContent = name;
2042 sizeDiv.textContent = WebInspector.HeapSnapshotStatisticsView._valueFormatte r(value); 2042 sizeDiv.textContent = Profiler.HeapSnapshotStatisticsView._valueFormatter(va lue);
2043 } 2043 }
2044 }; 2044 };
2045 2045
2046 2046
2047 /** 2047 /**
2048 * @unrestricted 2048 * @unrestricted
2049 */ 2049 */
2050 WebInspector.HeapAllocationStackView = class extends WebInspector.Widget { 2050 Profiler.HeapAllocationStackView = class extends UI.Widget {
2051 /** 2051 /**
2052 * @param {?WebInspector.Target} target 2052 * @param {?SDK.Target} target
2053 */ 2053 */
2054 constructor(target) { 2054 constructor(target) {
2055 super(); 2055 super();
2056 this._target = target; 2056 this._target = target;
2057 this._linkifier = new WebInspector.Linkifier(); 2057 this._linkifier = new Components.Linkifier();
2058 } 2058 }
2059 2059
2060 /** 2060 /**
2061 * @param {!WebInspector.HeapSnapshotProxy} snapshot 2061 * @param {!Profiler.HeapSnapshotProxy} snapshot
2062 * @param {number} snapshotNodeIndex 2062 * @param {number} snapshotNodeIndex
2063 */ 2063 */
2064 setAllocatedObject(snapshot, snapshotNodeIndex) { 2064 setAllocatedObject(snapshot, snapshotNodeIndex) {
2065 this.clear(); 2065 this.clear();
2066 snapshot.allocationStack(snapshotNodeIndex, this._didReceiveAllocationStack. bind(this)); 2066 snapshot.allocationStack(snapshotNodeIndex, this._didReceiveAllocationStack. bind(this));
2067 } 2067 }
2068 2068
2069 clear() { 2069 clear() {
2070 this.element.removeChildren(); 2070 this.element.removeChildren();
2071 this._linkifier.reset(); 2071 this._linkifier.reset();
2072 } 2072 }
2073 2073
2074 /** 2074 /**
2075 * @param {?Array.<!WebInspector.HeapSnapshotCommon.AllocationStackFrame>} fra mes 2075 * @param {?Array.<!Profiler.HeapSnapshotCommon.AllocationStackFrame>} frames
2076 */ 2076 */
2077 _didReceiveAllocationStack(frames) { 2077 _didReceiveAllocationStack(frames) {
2078 if (!frames) { 2078 if (!frames) {
2079 var stackDiv = this.element.createChild('div', 'no-heap-allocation-stack') ; 2079 var stackDiv = this.element.createChild('div', 'no-heap-allocation-stack') ;
2080 stackDiv.createTextChild(WebInspector.UIString( 2080 stackDiv.createTextChild(Common.UIString(
2081 'Stack was not recorded for this object because it had been allocated before this profile recording started.')); 2081 'Stack was not recorded for this object because it had been allocated before this profile recording started.'));
2082 return; 2082 return;
2083 } 2083 }
2084 2084
2085 var stackDiv = this.element.createChild('div', 'heap-allocation-stack'); 2085 var stackDiv = this.element.createChild('div', 'heap-allocation-stack');
2086 for (var i = 0; i < frames.length; i++) { 2086 for (var i = 0; i < frames.length; i++) {
2087 var frame = frames[i]; 2087 var frame = frames[i];
2088 var frameDiv = stackDiv.createChild('div', 'stack-frame'); 2088 var frameDiv = stackDiv.createChild('div', 'stack-frame');
2089 var name = frameDiv.createChild('div'); 2089 var name = frameDiv.createChild('div');
2090 name.textContent = WebInspector.beautifyFunctionName(frame.functionName); 2090 name.textContent = UI.beautifyFunctionName(frame.functionName);
2091 if (frame.scriptId) { 2091 if (frame.scriptId) {
2092 var urlElement = this._linkifier.linkifyScriptLocation( 2092 var urlElement = this._linkifier.linkifyScriptLocation(
2093 this._target, String(frame.scriptId), frame.scriptName, frame.line - 1, frame.column - 1); 2093 this._target, String(frame.scriptId), frame.scriptName, frame.line - 1, frame.column - 1);
2094 frameDiv.appendChild(urlElement); 2094 frameDiv.appendChild(urlElement);
2095 } 2095 }
2096 } 2096 }
2097 } 2097 }
2098 }; 2098 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698