OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @implements {WebInspector.Searchable} | 7 * @implements {WebInspector.Searchable} |
8 * @extends {WebInspector.ProfileView} | 8 * @extends {WebInspector.ProfileView} |
9 * @param {!WebInspector.SamplingHeapProfileHeader} profileHeader | 9 * @param {!WebInspector.SamplingHeapProfileHeader} profileHeader |
10 */ | 10 */ |
11 WebInspector.HeapProfileView = function(profileHeader) | 11 WebInspector.HeapProfileView = function(profileHeader) |
12 { | 12 { |
13 this._profileHeader = profileHeader; | 13 this._profileHeader = profileHeader; |
14 this.profile = new WebInspector.SamplingHeapProfileModel(profileHeader._prof
ile || profileHeader.protocolProfile()); | 14 this.profile = new WebInspector.SamplingHeapProfileModel(profileHeader._prof
ile || profileHeader.protocolProfile()); |
15 this.adjustedTotal = this.profile.total; | 15 this.adjustedTotal = this.profile.total; |
16 var views = [ | 16 var views = [ |
17 WebInspector.ProfileView.ViewTypes.Flame, | 17 WebInspector.ProfileView.ViewTypes.Flame, |
18 WebInspector.ProfileView.ViewTypes.Heavy, | 18 WebInspector.ProfileView.ViewTypes.Heavy, |
19 WebInspector.ProfileView.ViewTypes.Tree | 19 WebInspector.ProfileView.ViewTypes.Tree |
20 ]; | 20 ]; |
21 WebInspector.ProfileView.call(this, new WebInspector.HeapProfileView.NodeFor
matter(this), views); | 21 WebInspector.ProfileView.call(this, new WebInspector.HeapProfileView.NodeFor
matter(this), views); |
22 } | 22 }; |
23 | 23 |
24 WebInspector.HeapProfileView.prototype = { | 24 WebInspector.HeapProfileView.prototype = { |
25 /** | 25 /** |
26 * @override | 26 * @override |
27 * @param {string} columnId | 27 * @param {string} columnId |
28 * @return {string} | 28 * @return {string} |
29 */ | 29 */ |
30 columnHeader: function(columnId) | 30 columnHeader: function(columnId) |
31 { | 31 { |
32 switch (columnId) { | 32 switch (columnId) { |
33 case "self": return WebInspector.UIString("Self Size (bytes)"); | 33 case "self": return WebInspector.UIString("Self Size (bytes)"); |
34 case "total": return WebInspector.UIString("Total Size (bytes)"); | 34 case "total": return WebInspector.UIString("Total Size (bytes)"); |
35 } | 35 } |
36 return ""; | 36 return ""; |
37 }, | 37 }, |
38 | 38 |
39 /** | 39 /** |
40 * @override | 40 * @override |
41 * @return {!WebInspector.FlameChartDataProvider} | 41 * @return {!WebInspector.FlameChartDataProvider} |
42 */ | 42 */ |
43 createFlameChartDataProvider: function() | 43 createFlameChartDataProvider: function() |
44 { | 44 { |
45 return new WebInspector.HeapFlameChartDataProvider(this.profile, this._p
rofileHeader.target()); | 45 return new WebInspector.HeapFlameChartDataProvider(this.profile, this._p
rofileHeader.target()); |
46 }, | 46 }, |
47 | 47 |
48 __proto__: WebInspector.ProfileView.prototype | 48 __proto__: WebInspector.ProfileView.prototype |
49 } | 49 }; |
50 | 50 |
51 /** | 51 /** |
52 * @constructor | 52 * @constructor |
53 * @extends {WebInspector.ProfileType} | 53 * @extends {WebInspector.ProfileType} |
54 */ | 54 */ |
55 WebInspector.SamplingHeapProfileType = function() | 55 WebInspector.SamplingHeapProfileType = function() |
56 { | 56 { |
57 WebInspector.ProfileType.call(this, WebInspector.SamplingHeapProfileType.Typ
eId, WebInspector.UIString("Record Allocation Profile")); | 57 WebInspector.ProfileType.call(this, WebInspector.SamplingHeapProfileType.Typ
eId, WebInspector.UIString("Record Allocation Profile")); |
58 this._recording = false; | 58 this._recording = false; |
59 WebInspector.SamplingHeapProfileType.instance = this; | 59 WebInspector.SamplingHeapProfileType.instance = this; |
60 } | 60 }; |
61 | 61 |
62 WebInspector.SamplingHeapProfileType.TypeId = "SamplingHeap"; | 62 WebInspector.SamplingHeapProfileType.TypeId = "SamplingHeap"; |
63 | 63 |
64 WebInspector.SamplingHeapProfileType.prototype = { | 64 WebInspector.SamplingHeapProfileType.prototype = { |
65 /** | 65 /** |
66 * @override | 66 * @override |
67 * @return {string} | 67 * @return {string} |
68 */ | 68 */ |
69 typeName: function() | 69 typeName: function() |
70 { | 70 { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 | 172 |
173 /** | 173 /** |
174 * @override | 174 * @override |
175 */ | 175 */ |
176 profileBeingRecordedRemoved: function() | 176 profileBeingRecordedRemoved: function() |
177 { | 177 { |
178 this.stopRecordingProfile(); | 178 this.stopRecordingProfile(); |
179 }, | 179 }, |
180 | 180 |
181 __proto__: WebInspector.ProfileType.prototype | 181 __proto__: WebInspector.ProfileType.prototype |
182 } | 182 }; |
183 | 183 |
184 /** | 184 /** |
185 * @constructor | 185 * @constructor |
186 * @extends {WebInspector.WritableProfileHeader} | 186 * @extends {WebInspector.WritableProfileHeader} |
187 * @param {?WebInspector.Target} target | 187 * @param {?WebInspector.Target} target |
188 * @param {!WebInspector.SamplingHeapProfileType} type | 188 * @param {!WebInspector.SamplingHeapProfileType} type |
189 * @param {string=} title | 189 * @param {string=} title |
190 */ | 190 */ |
191 WebInspector.SamplingHeapProfileHeader = function(target, type, title) | 191 WebInspector.SamplingHeapProfileHeader = function(target, type, title) |
192 { | 192 { |
193 WebInspector.WritableProfileHeader.call(this, target, type, title || WebInsp
ector.UIString("Profile %d", type.nextProfileUid())); | 193 WebInspector.WritableProfileHeader.call(this, target, type, title || WebInsp
ector.UIString("Profile %d", type.nextProfileUid())); |
194 } | 194 }; |
195 | 195 |
196 WebInspector.SamplingHeapProfileHeader.prototype = { | 196 WebInspector.SamplingHeapProfileHeader.prototype = { |
197 /** | 197 /** |
198 * @override | 198 * @override |
199 * @return {!WebInspector.ProfileView} | 199 * @return {!WebInspector.ProfileView} |
200 */ | 200 */ |
201 createView: function() | 201 createView: function() |
202 { | 202 { |
203 return new WebInspector.HeapProfileView(this); | 203 return new WebInspector.HeapProfileView(this); |
204 }, | 204 }, |
205 | 205 |
206 /** | 206 /** |
207 * @return {!HeapProfilerAgent.SamplingHeapProfile} | 207 * @return {!HeapProfilerAgent.SamplingHeapProfile} |
208 */ | 208 */ |
209 protocolProfile: function() | 209 protocolProfile: function() |
210 { | 210 { |
211 return this._protocolProfile; | 211 return this._protocolProfile; |
212 }, | 212 }, |
213 | 213 |
214 __proto__: WebInspector.WritableProfileHeader.prototype | 214 __proto__: WebInspector.WritableProfileHeader.prototype |
215 } | 215 }; |
216 | 216 |
217 /** | 217 /** |
218 * @constructor | 218 * @constructor |
219 * @extends {WebInspector.ProfileNode} | 219 * @extends {WebInspector.ProfileNode} |
220 * @param {!HeapProfilerAgent.SamplingHeapProfileNode} node | 220 * @param {!HeapProfilerAgent.SamplingHeapProfileNode} node |
221 */ | 221 */ |
222 WebInspector.SamplingHeapProfileNode = function(node) | 222 WebInspector.SamplingHeapProfileNode = function(node) |
223 { | 223 { |
224 var callFrame = node.callFrame || /** @type {!RuntimeAgent.CallFrame} */ ({ | 224 var callFrame = node.callFrame || /** @type {!RuntimeAgent.CallFrame} */ ({ |
225 // Backward compatibility for old CpuProfileNode format. | 225 // Backward compatibility for old CpuProfileNode format. |
226 functionName: node["functionName"], | 226 functionName: node["functionName"], |
227 scriptId: node["scriptId"], | 227 scriptId: node["scriptId"], |
228 url: node["url"], | 228 url: node["url"], |
229 lineNumber: node["lineNumber"] - 1, | 229 lineNumber: node["lineNumber"] - 1, |
230 columnNumber: node["columnNumber"] - 1 | 230 columnNumber: node["columnNumber"] - 1 |
231 }); | 231 }); |
232 WebInspector.ProfileNode.call(this, callFrame); | 232 WebInspector.ProfileNode.call(this, callFrame); |
233 this.self = node.selfSize; | 233 this.self = node.selfSize; |
234 } | 234 }; |
235 | 235 |
236 WebInspector.SamplingHeapProfileNode.prototype = { | 236 WebInspector.SamplingHeapProfileNode.prototype = { |
237 __proto__: WebInspector.ProfileNode.prototype | 237 __proto__: WebInspector.ProfileNode.prototype |
238 } | 238 }; |
239 | 239 |
240 /** | 240 /** |
241 * @constructor | 241 * @constructor |
242 * @extends {WebInspector.ProfileTreeModel} | 242 * @extends {WebInspector.ProfileTreeModel} |
243 * @param {!HeapProfilerAgent.SamplingHeapProfile} profile | 243 * @param {!HeapProfilerAgent.SamplingHeapProfile} profile |
244 */ | 244 */ |
245 WebInspector.SamplingHeapProfileModel = function(profile) | 245 WebInspector.SamplingHeapProfileModel = function(profile) |
246 { | 246 { |
247 WebInspector.ProfileTreeModel.call(this, this._translateProfileTree(profile.
head)); | 247 WebInspector.ProfileTreeModel.call(this, this._translateProfileTree(profile.
head)); |
248 } | 248 }; |
249 | 249 |
250 WebInspector.SamplingHeapProfileModel.prototype = { | 250 WebInspector.SamplingHeapProfileModel.prototype = { |
251 /** | 251 /** |
252 * @param {!HeapProfilerAgent.SamplingHeapProfileNode} root | 252 * @param {!HeapProfilerAgent.SamplingHeapProfileNode} root |
253 * @return {!WebInspector.SamplingHeapProfileNode} | 253 * @return {!WebInspector.SamplingHeapProfileNode} |
254 */ | 254 */ |
255 _translateProfileTree: function(root) | 255 _translateProfileTree: function(root) |
256 { | 256 { |
257 var resultRoot = new WebInspector.SamplingHeapProfileNode(root); | 257 var resultRoot = new WebInspector.SamplingHeapProfileNode(root); |
258 var targetNodeStack = [resultRoot]; | 258 var targetNodeStack = [resultRoot]; |
259 var sourceNodeStack = [root]; | 259 var sourceNodeStack = [root]; |
260 while (sourceNodeStack.length) { | 260 while (sourceNodeStack.length) { |
261 var sourceNode = sourceNodeStack.pop(); | 261 var sourceNode = sourceNodeStack.pop(); |
262 var parentNode = targetNodeStack.pop(); | 262 var parentNode = targetNodeStack.pop(); |
263 parentNode.children = sourceNode.children.map(child => new WebInspec
tor.SamplingHeapProfileNode(child)); | 263 parentNode.children = sourceNode.children.map(child => new WebInspec
tor.SamplingHeapProfileNode(child)); |
264 sourceNodeStack.push.apply(sourceNodeStack, sourceNode.children); | 264 sourceNodeStack.push.apply(sourceNodeStack, sourceNode.children); |
265 targetNodeStack.push.apply(targetNodeStack, parentNode.children); | 265 targetNodeStack.push.apply(targetNodeStack, parentNode.children); |
266 } | 266 } |
267 return resultRoot; | 267 return resultRoot; |
268 }, | 268 }, |
269 | 269 |
270 __proto__: WebInspector.ProfileTreeModel.prototype | 270 __proto__: WebInspector.ProfileTreeModel.prototype |
271 } | 271 }; |
272 | 272 |
273 /** | 273 /** |
274 * @constructor | 274 * @constructor |
275 * @implements {WebInspector.ProfileDataGridNode.Formatter} | 275 * @implements {WebInspector.ProfileDataGridNode.Formatter} |
276 * @param {!WebInspector.ProfileView} profileView | 276 * @param {!WebInspector.ProfileView} profileView |
277 */ | 277 */ |
278 WebInspector.HeapProfileView.NodeFormatter = function(profileView) | 278 WebInspector.HeapProfileView.NodeFormatter = function(profileView) |
279 { | 279 { |
280 this._profileView = profileView; | 280 this._profileView = profileView; |
281 } | 281 }; |
282 | 282 |
283 WebInspector.HeapProfileView.NodeFormatter.prototype = { | 283 WebInspector.HeapProfileView.NodeFormatter.prototype = { |
284 /** | 284 /** |
285 * @override | 285 * @override |
286 * @param {number} value | 286 * @param {number} value |
287 * @return {string} | 287 * @return {string} |
288 */ | 288 */ |
289 formatValue: function(value) | 289 formatValue: function(value) |
290 { | 290 { |
291 return Number.withThousandsSeparator(value); | 291 return Number.withThousandsSeparator(value); |
(...skipping 12 matching lines...) Expand all Loading... |
304 | 304 |
305 /** | 305 /** |
306 * @override | 306 * @override |
307 * @param {!WebInspector.ProfileDataGridNode} node | 307 * @param {!WebInspector.ProfileDataGridNode} node |
308 * @return {?Element} | 308 * @return {?Element} |
309 */ | 309 */ |
310 linkifyNode: function(node) | 310 linkifyNode: function(node) |
311 { | 311 { |
312 return this._profileView.linkifier().maybeLinkifyConsoleCallFrame(this._
profileView.target(), node.profileNode.callFrame, "profile-node-file"); | 312 return this._profileView.linkifier().maybeLinkifyConsoleCallFrame(this._
profileView.target(), node.profileNode.callFrame, "profile-node-file"); |
313 } | 313 } |
314 } | 314 }; |
315 | 315 |
316 /** | 316 /** |
317 * @constructor | 317 * @constructor |
318 * @extends {WebInspector.ProfileFlameChartDataProvider} | 318 * @extends {WebInspector.ProfileFlameChartDataProvider} |
319 * @param {!WebInspector.ProfileTreeModel} profile | 319 * @param {!WebInspector.ProfileTreeModel} profile |
320 * @param {?WebInspector.Target} target | 320 * @param {?WebInspector.Target} target |
321 */ | 321 */ |
322 WebInspector.HeapFlameChartDataProvider = function(profile, target) | 322 WebInspector.HeapFlameChartDataProvider = function(profile, target) |
323 { | 323 { |
324 WebInspector.ProfileFlameChartDataProvider.call(this, target); | 324 WebInspector.ProfileFlameChartDataProvider.call(this, target); |
325 this._profile = profile; | 325 this._profile = profile; |
326 } | 326 }; |
327 | 327 |
328 WebInspector.HeapFlameChartDataProvider.prototype = { | 328 WebInspector.HeapFlameChartDataProvider.prototype = { |
329 /** | 329 /** |
330 * @override | 330 * @override |
331 * @return {number} | 331 * @return {number} |
332 */ | 332 */ |
333 minimumBoundary: function() | 333 minimumBoundary: function() |
334 { | 334 { |
335 return 0; | 335 return 0; |
336 }, | 336 }, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 pushEntryInfoRow(WebInspector.UIString("Total size"), Number.bytesToStri
ng(node.total)); | 430 pushEntryInfoRow(WebInspector.UIString("Total size"), Number.bytesToStri
ng(node.total)); |
431 var linkifier = new WebInspector.Linkifier(); | 431 var linkifier = new WebInspector.Linkifier(); |
432 var link = linkifier.maybeLinkifyConsoleCallFrame(this._target, node.cal
lFrame); | 432 var link = linkifier.maybeLinkifyConsoleCallFrame(this._target, node.cal
lFrame); |
433 if (link) | 433 if (link) |
434 pushEntryInfoRow(WebInspector.UIString("URL"), link.textContent); | 434 pushEntryInfoRow(WebInspector.UIString("URL"), link.textContent); |
435 linkifier.dispose(); | 435 linkifier.dispose(); |
436 return WebInspector.ProfileView.buildPopoverTable(entryInfo); | 436 return WebInspector.ProfileView.buildPopoverTable(entryInfo); |
437 }, | 437 }, |
438 | 438 |
439 __proto__: WebInspector.ProfileFlameChartDataProvider.prototype | 439 __proto__: WebInspector.ProfileFlameChartDataProvider.prototype |
440 } | 440 }; |
OLD | NEW |