| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** | 4 /** |
| 5 * @implements {WebInspector.Searchable} | 5 * @implements {UI.Searchable} |
| 6 * @unrestricted | 6 * @unrestricted |
| 7 */ | 7 */ |
| 8 WebInspector.HeapProfileView = class extends WebInspector.ProfileView { | 8 Profiler.HeapProfileView = class extends Profiler.ProfileView { |
| 9 /** | 9 /** |
| 10 * @param {!WebInspector.SamplingHeapProfileHeader} profileHeader | 10 * @param {!Profiler.SamplingHeapProfileHeader} profileHeader |
| 11 */ | 11 */ |
| 12 constructor(profileHeader) { | 12 constructor(profileHeader) { |
| 13 super(); | 13 super(); |
| 14 this._profileHeader = profileHeader; | 14 this._profileHeader = profileHeader; |
| 15 this.profile = new WebInspector.SamplingHeapProfileModel(profileHeader._prof
ile || profileHeader.protocolProfile()); | 15 this.profile = new Profiler.SamplingHeapProfileModel(profileHeader._profile
|| profileHeader.protocolProfile()); |
| 16 this.adjustedTotal = this.profile.total; | 16 this.adjustedTotal = this.profile.total; |
| 17 var views = [ | 17 var views = [ |
| 18 WebInspector.ProfileView.ViewTypes.Flame, WebInspector.ProfileView.ViewTyp
es.Heavy, | 18 Profiler.ProfileView.ViewTypes.Flame, Profiler.ProfileView.ViewTypes.Heavy
, |
| 19 WebInspector.ProfileView.ViewTypes.Tree | 19 Profiler.ProfileView.ViewTypes.Tree |
| 20 ]; | 20 ]; |
| 21 this.initialize(new WebInspector.HeapProfileView.NodeFormatter(this), views)
; | 21 this.initialize(new Profiler.HeapProfileView.NodeFormatter(this), views); |
| 22 } | 22 } |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * @override | 25 * @override |
| 26 * @param {string} columnId | 26 * @param {string} columnId |
| 27 * @return {string} | 27 * @return {string} |
| 28 */ | 28 */ |
| 29 columnHeader(columnId) { | 29 columnHeader(columnId) { |
| 30 switch (columnId) { | 30 switch (columnId) { |
| 31 case 'self': | 31 case 'self': |
| 32 return WebInspector.UIString('Self Size (bytes)'); | 32 return Common.UIString('Self Size (bytes)'); |
| 33 case 'total': | 33 case 'total': |
| 34 return WebInspector.UIString('Total Size (bytes)'); | 34 return Common.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 {!UI.FlameChartDataProvider} |
| 42 */ | 42 */ |
| 43 createFlameChartDataProvider() { | 43 createFlameChartDataProvider() { |
| 44 return new WebInspector.HeapFlameChartDataProvider(this.profile, this._profi
leHeader.target()); | 44 return new Profiler.HeapFlameChartDataProvider(this.profile, this._profileHe
ader.target()); |
| 45 } | 45 } |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 /** | 48 /** |
| 49 * @unrestricted | 49 * @unrestricted |
| 50 */ | 50 */ |
| 51 WebInspector.SamplingHeapProfileType = class extends WebInspector.ProfileType { | 51 Profiler.SamplingHeapProfileType = class extends Profiler.ProfileType { |
| 52 constructor() { | 52 constructor() { |
| 53 super(WebInspector.SamplingHeapProfileType.TypeId, WebInspector.UIString('Re
cord Allocation Profile')); | 53 super(Profiler.SamplingHeapProfileType.TypeId, Common.UIString('Record Alloc
ation Profile')); |
| 54 this._recording = false; | 54 this._recording = false; |
| 55 WebInspector.SamplingHeapProfileType.instance = this; | 55 Profiler.SamplingHeapProfileType.instance = this; |
| 56 } | 56 } |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * @override | 59 * @override |
| 60 * @return {string} | 60 * @return {string} |
| 61 */ | 61 */ |
| 62 typeName() { | 62 typeName() { |
| 63 return 'Heap'; | 63 return 'Heap'; |
| 64 } | 64 } |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * @override | 67 * @override |
| 68 * @return {string} | 68 * @return {string} |
| 69 */ | 69 */ |
| 70 fileExtension() { | 70 fileExtension() { |
| 71 return '.heapprofile'; | 71 return '.heapprofile'; |
| 72 } | 72 } |
| 73 | 73 |
| 74 get buttonTooltip() { | 74 get buttonTooltip() { |
| 75 return this._recording ? WebInspector.UIString('Stop heap profiling') : | 75 return this._recording ? Common.UIString('Stop heap profiling') : |
| 76 WebInspector.UIString('Start heap profiling'); | 76 Common.UIString('Start heap profiling'); |
| 77 } | 77 } |
| 78 | 78 |
| 79 /** | 79 /** |
| 80 * @override | 80 * @override |
| 81 * @return {boolean} | 81 * @return {boolean} |
| 82 */ | 82 */ |
| 83 buttonClicked() { | 83 buttonClicked() { |
| 84 var wasRecording = this._recording; | 84 var wasRecording = this._recording; |
| 85 if (wasRecording) | 85 if (wasRecording) |
| 86 this.stopRecordingProfile(); | 86 this.stopRecordingProfile(); |
| 87 else | 87 else |
| 88 this.startRecordingProfile(); | 88 this.startRecordingProfile(); |
| 89 return !wasRecording; | 89 return !wasRecording; |
| 90 } | 90 } |
| 91 | 91 |
| 92 get treeItemTitle() { | 92 get treeItemTitle() { |
| 93 return WebInspector.UIString('ALLOCATION PROFILES'); | 93 return Common.UIString('ALLOCATION PROFILES'); |
| 94 } | 94 } |
| 95 | 95 |
| 96 get description() { | 96 get description() { |
| 97 return WebInspector.UIString('Allocation profiles show memory allocations fr
om your JavaScript functions.'); | 97 return Common.UIString('Allocation profiles show memory allocations from you
r JavaScript functions.'); |
| 98 } | 98 } |
| 99 | 99 |
| 100 startRecordingProfile() { | 100 startRecordingProfile() { |
| 101 var target = WebInspector.context.flavor(WebInspector.Target); | 101 var target = UI.context.flavor(SDK.Target); |
| 102 if (this._profileBeingRecorded || !target) | 102 if (this._profileBeingRecorded || !target) |
| 103 return; | 103 return; |
| 104 var profile = new WebInspector.SamplingHeapProfileHeader(target, this); | 104 var profile = new Profiler.SamplingHeapProfileHeader(target, this); |
| 105 this.setProfileBeingRecorded(profile); | 105 this.setProfileBeingRecorded(profile); |
| 106 WebInspector.targetManager.suspendAllTargets(); | 106 SDK.targetManager.suspendAllTargets(); |
| 107 this.addProfile(profile); | 107 this.addProfile(profile); |
| 108 profile.updateStatus(WebInspector.UIString('Recording\u2026')); | 108 profile.updateStatus(Common.UIString('Recording\u2026')); |
| 109 this._recording = true; | 109 this._recording = true; |
| 110 target.heapProfilerModel.startSampling(); | 110 target.heapProfilerModel.startSampling(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 stopRecordingProfile() { | 113 stopRecordingProfile() { |
| 114 this._recording = false; | 114 this._recording = false; |
| 115 if (!this._profileBeingRecorded || !this._profileBeingRecorded.target()) | 115 if (!this._profileBeingRecorded || !this._profileBeingRecorded.target()) |
| 116 return; | 116 return; |
| 117 | 117 |
| 118 var recordedProfile; | 118 var recordedProfile; |
| 119 | 119 |
| 120 /** | 120 /** |
| 121 * @param {?Protocol.HeapProfiler.SamplingHeapProfile} profile | 121 * @param {?Protocol.HeapProfiler.SamplingHeapProfile} profile |
| 122 * @this {WebInspector.SamplingHeapProfileType} | 122 * @this {Profiler.SamplingHeapProfileType} |
| 123 */ | 123 */ |
| 124 function didStopProfiling(profile) { | 124 function didStopProfiling(profile) { |
| 125 if (!this._profileBeingRecorded) | 125 if (!this._profileBeingRecorded) |
| 126 return; | 126 return; |
| 127 console.assert(profile); | 127 console.assert(profile); |
| 128 this._profileBeingRecorded.setProtocolProfile(profile); | 128 this._profileBeingRecorded.setProtocolProfile(profile); |
| 129 this._profileBeingRecorded.updateStatus(''); | 129 this._profileBeingRecorded.updateStatus(''); |
| 130 recordedProfile = this._profileBeingRecorded; | 130 recordedProfile = this._profileBeingRecorded; |
| 131 this.setProfileBeingRecorded(null); | 131 this.setProfileBeingRecorded(null); |
| 132 } | 132 } |
| 133 | 133 |
| 134 /** | 134 /** |
| 135 * @this {WebInspector.SamplingHeapProfileType} | 135 * @this {Profiler.SamplingHeapProfileType} |
| 136 */ | 136 */ |
| 137 function fireEvent() { | 137 function fireEvent() { |
| 138 this.dispatchEventToListeners(WebInspector.ProfileType.Events.ProfileCompl
ete, recordedProfile); | 138 this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete,
recordedProfile); |
| 139 } | 139 } |
| 140 | 140 |
| 141 this._profileBeingRecorded.target() | 141 this._profileBeingRecorded.target() |
| 142 .heapProfilerModel.stopSampling() | 142 .heapProfilerModel.stopSampling() |
| 143 .then(didStopProfiling.bind(this)) | 143 .then(didStopProfiling.bind(this)) |
| 144 .then(WebInspector.targetManager.resumeAllTargets.bind(WebInspector.targ
etManager)) | 144 .then(SDK.targetManager.resumeAllTargets.bind(SDK.targetManager)) |
| 145 .then(fireEvent.bind(this)); | 145 .then(fireEvent.bind(this)); |
| 146 } | 146 } |
| 147 | 147 |
| 148 /** | 148 /** |
| 149 * @override | 149 * @override |
| 150 * @param {string} title | 150 * @param {string} title |
| 151 * @return {!WebInspector.ProfileHeader} | 151 * @return {!Profiler.ProfileHeader} |
| 152 */ | 152 */ |
| 153 createProfileLoadedFromFile(title) { | 153 createProfileLoadedFromFile(title) { |
| 154 return new WebInspector.SamplingHeapProfileHeader(null, this, title); | 154 return new Profiler.SamplingHeapProfileHeader(null, this, title); |
| 155 } | 155 } |
| 156 | 156 |
| 157 /** | 157 /** |
| 158 * @override | 158 * @override |
| 159 */ | 159 */ |
| 160 profileBeingRecordedRemoved() { | 160 profileBeingRecordedRemoved() { |
| 161 this.stopRecordingProfile(); | 161 this.stopRecordingProfile(); |
| 162 } | 162 } |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 WebInspector.SamplingHeapProfileType.TypeId = 'SamplingHeap'; | 165 Profiler.SamplingHeapProfileType.TypeId = 'SamplingHeap'; |
| 166 | 166 |
| 167 /** | 167 /** |
| 168 * @unrestricted | 168 * @unrestricted |
| 169 */ | 169 */ |
| 170 WebInspector.SamplingHeapProfileHeader = class extends WebInspector.WritableProf
ileHeader { | 170 Profiler.SamplingHeapProfileHeader = class extends Profiler.WritableProfileHeade
r { |
| 171 /** | 171 /** |
| 172 * @param {?WebInspector.Target} target | 172 * @param {?SDK.Target} target |
| 173 * @param {!WebInspector.SamplingHeapProfileType} type | 173 * @param {!Profiler.SamplingHeapProfileType} type |
| 174 * @param {string=} title | 174 * @param {string=} title |
| 175 */ | 175 */ |
| 176 constructor(target, type, title) { | 176 constructor(target, type, title) { |
| 177 super(target, type, title || WebInspector.UIString('Profile %d', type.nextPr
ofileUid())); | 177 super(target, type, title || Common.UIString('Profile %d', type.nextProfileU
id())); |
| 178 } | 178 } |
| 179 | 179 |
| 180 /** | 180 /** |
| 181 * @override | 181 * @override |
| 182 * @return {!WebInspector.ProfileView} | 182 * @return {!Profiler.ProfileView} |
| 183 */ | 183 */ |
| 184 createView() { | 184 createView() { |
| 185 return new WebInspector.HeapProfileView(this); | 185 return new Profiler.HeapProfileView(this); |
| 186 } | 186 } |
| 187 | 187 |
| 188 /** | 188 /** |
| 189 * @return {!Protocol.HeapProfiler.SamplingHeapProfile} | 189 * @return {!Protocol.HeapProfiler.SamplingHeapProfile} |
| 190 */ | 190 */ |
| 191 protocolProfile() { | 191 protocolProfile() { |
| 192 return this._protocolProfile; | 192 return this._protocolProfile; |
| 193 } | 193 } |
| 194 }; | 194 }; |
| 195 | 195 |
| 196 /** | 196 /** |
| 197 * @unrestricted | 197 * @unrestricted |
| 198 */ | 198 */ |
| 199 WebInspector.SamplingHeapProfileNode = class extends WebInspector.ProfileNode { | 199 Profiler.SamplingHeapProfileNode = class extends SDK.ProfileNode { |
| 200 /** | 200 /** |
| 201 * @param {!Protocol.HeapProfiler.SamplingHeapProfileNode} node | 201 * @param {!Protocol.HeapProfiler.SamplingHeapProfileNode} node |
| 202 */ | 202 */ |
| 203 constructor(node) { | 203 constructor(node) { |
| 204 var callFrame = node.callFrame || /** @type {!Protocol.Runtime.CallFrame} */
({ | 204 var callFrame = node.callFrame || /** @type {!Protocol.Runtime.CallFrame} */
({ |
| 205 // Backward compatibility for old CpuProfileNode format. | 205 // Backward compatibility for old CpuProfileNode format. |
| 206 functionName: node['functionName'], | 206 functionName: node['functionName'], |
| 207 scriptId: node['scriptId'], | 207 scriptId: node['scriptId'], |
| 208 url: node['url'], | 208 url: node['url'], |
| 209 lineNumber: node['lineNumber'] - 1, | 209 lineNumber: node['lineNumber'] - 1, |
| 210 columnNumber: node['columnNumber'] - 1 | 210 columnNumber: node['columnNumber'] - 1 |
| 211 }); | 211 }); |
| 212 super(callFrame); | 212 super(callFrame); |
| 213 this.self = node.selfSize; | 213 this.self = node.selfSize; |
| 214 } | 214 } |
| 215 }; | 215 }; |
| 216 | 216 |
| 217 /** | 217 /** |
| 218 * @unrestricted | 218 * @unrestricted |
| 219 */ | 219 */ |
| 220 WebInspector.SamplingHeapProfileModel = class extends WebInspector.ProfileTreeMo
del { | 220 Profiler.SamplingHeapProfileModel = class extends SDK.ProfileTreeModel { |
| 221 /** | 221 /** |
| 222 * @param {!Protocol.HeapProfiler.SamplingHeapProfile} profile | 222 * @param {!Protocol.HeapProfiler.SamplingHeapProfile} profile |
| 223 */ | 223 */ |
| 224 constructor(profile) { | 224 constructor(profile) { |
| 225 super(); | 225 super(); |
| 226 this.initialize(translateProfileTree(profile.head)); | 226 this.initialize(translateProfileTree(profile.head)); |
| 227 | 227 |
| 228 /** | 228 /** |
| 229 * @param {!Protocol.HeapProfiler.SamplingHeapProfileNode} root | 229 * @param {!Protocol.HeapProfiler.SamplingHeapProfileNode} root |
| 230 * @return {!WebInspector.SamplingHeapProfileNode} | 230 * @return {!Profiler.SamplingHeapProfileNode} |
| 231 */ | 231 */ |
| 232 function translateProfileTree(root) { | 232 function translateProfileTree(root) { |
| 233 var resultRoot = new WebInspector.SamplingHeapProfileNode(root); | 233 var resultRoot = new Profiler.SamplingHeapProfileNode(root); |
| 234 var targetNodeStack = [resultRoot]; | 234 var targetNodeStack = [resultRoot]; |
| 235 var sourceNodeStack = [root]; | 235 var sourceNodeStack = [root]; |
| 236 while (sourceNodeStack.length) { | 236 while (sourceNodeStack.length) { |
| 237 var sourceNode = sourceNodeStack.pop(); | 237 var sourceNode = sourceNodeStack.pop(); |
| 238 var parentNode = targetNodeStack.pop(); | 238 var parentNode = targetNodeStack.pop(); |
| 239 parentNode.children = sourceNode.children.map(child => new WebInspector.
SamplingHeapProfileNode(child)); | 239 parentNode.children = sourceNode.children.map(child => new Profiler.Samp
lingHeapProfileNode(child)); |
| 240 sourceNodeStack.push.apply(sourceNodeStack, sourceNode.children); | 240 sourceNodeStack.push.apply(sourceNodeStack, sourceNode.children); |
| 241 targetNodeStack.push.apply(targetNodeStack, parentNode.children); | 241 targetNodeStack.push.apply(targetNodeStack, parentNode.children); |
| 242 } | 242 } |
| 243 return resultRoot; | 243 return resultRoot; |
| 244 } | 244 } |
| 245 } | 245 } |
| 246 }; | 246 }; |
| 247 | 247 |
| 248 /** | 248 /** |
| 249 * @implements {WebInspector.ProfileDataGridNode.Formatter} | 249 * @implements {Profiler.ProfileDataGridNode.Formatter} |
| 250 * @unrestricted | 250 * @unrestricted |
| 251 */ | 251 */ |
| 252 WebInspector.HeapProfileView.NodeFormatter = class { | 252 Profiler.HeapProfileView.NodeFormatter = class { |
| 253 /** | 253 /** |
| 254 * @param {!WebInspector.ProfileView} profileView | 254 * @param {!Profiler.ProfileView} profileView |
| 255 */ | 255 */ |
| 256 constructor(profileView) { | 256 constructor(profileView) { |
| 257 this._profileView = profileView; | 257 this._profileView = profileView; |
| 258 } | 258 } |
| 259 | 259 |
| 260 /** | 260 /** |
| 261 * @override | 261 * @override |
| 262 * @param {number} value | 262 * @param {number} value |
| 263 * @return {string} | 263 * @return {string} |
| 264 */ | 264 */ |
| 265 formatValue(value) { | 265 formatValue(value) { |
| 266 return Number.withThousandsSeparator(value); | 266 return Number.withThousandsSeparator(value); |
| 267 } | 267 } |
| 268 | 268 |
| 269 /** | 269 /** |
| 270 * @override | 270 * @override |
| 271 * @param {number} value | 271 * @param {number} value |
| 272 * @param {!WebInspector.ProfileDataGridNode} node | 272 * @param {!Profiler.ProfileDataGridNode} node |
| 273 * @return {string} | 273 * @return {string} |
| 274 */ | 274 */ |
| 275 formatPercent(value, node) { | 275 formatPercent(value, node) { |
| 276 return WebInspector.UIString('%.2f\u2009%%', value); | 276 return Common.UIString('%.2f\u2009%%', value); |
| 277 } | 277 } |
| 278 | 278 |
| 279 /** | 279 /** |
| 280 * @override | 280 * @override |
| 281 * @param {!WebInspector.ProfileDataGridNode} node | 281 * @param {!Profiler.ProfileDataGridNode} node |
| 282 * @return {?Element} | 282 * @return {?Element} |
| 283 */ | 283 */ |
| 284 linkifyNode(node) { | 284 linkifyNode(node) { |
| 285 return this._profileView.linkifier().maybeLinkifyConsoleCallFrame( | 285 return this._profileView.linkifier().maybeLinkifyConsoleCallFrame( |
| 286 this._profileView.target(), node.profileNode.callFrame, 'profile-node-fi
le'); | 286 this._profileView.target(), node.profileNode.callFrame, 'profile-node-fi
le'); |
| 287 } | 287 } |
| 288 }; | 288 }; |
| 289 | 289 |
| 290 /** | 290 /** |
| 291 * @unrestricted | 291 * @unrestricted |
| 292 */ | 292 */ |
| 293 WebInspector.HeapFlameChartDataProvider = class extends WebInspector.ProfileFlam
eChartDataProvider { | 293 Profiler.HeapFlameChartDataProvider = class extends Profiler.ProfileFlameChartDa
taProvider { |
| 294 /** | 294 /** |
| 295 * @param {!WebInspector.ProfileTreeModel} profile | 295 * @param {!SDK.ProfileTreeModel} profile |
| 296 * @param {?WebInspector.Target} target | 296 * @param {?SDK.Target} target |
| 297 */ | 297 */ |
| 298 constructor(profile, target) { | 298 constructor(profile, target) { |
| 299 super(target); | 299 super(target); |
| 300 this._profile = profile; | 300 this._profile = profile; |
| 301 } | 301 } |
| 302 | 302 |
| 303 /** | 303 /** |
| 304 * @override | 304 * @override |
| 305 * @return {number} | 305 * @return {number} |
| 306 */ | 306 */ |
| 307 minimumBoundary() { | 307 minimumBoundary() { |
| 308 return 0; | 308 return 0; |
| 309 } | 309 } |
| 310 | 310 |
| 311 /** | 311 /** |
| 312 * @override | 312 * @override |
| 313 * @return {number} | 313 * @return {number} |
| 314 */ | 314 */ |
| 315 totalTime() { | 315 totalTime() { |
| 316 return this._profile.root.total; | 316 return this._profile.root.total; |
| 317 } | 317 } |
| 318 | 318 |
| 319 /** | 319 /** |
| 320 * @override | 320 * @override |
| 321 * @param {number} value | 321 * @param {number} value |
| 322 * @param {number=} precision | 322 * @param {number=} precision |
| 323 * @return {string} | 323 * @return {string} |
| 324 */ | 324 */ |
| 325 formatValue(value, precision) { | 325 formatValue(value, precision) { |
| 326 return WebInspector.UIString('%s\u2009KB', Number.withThousandsSeparator(val
ue / 1e3)); | 326 return Common.UIString('%s\u2009KB', Number.withThousandsSeparator(value / 1
e3)); |
| 327 } | 327 } |
| 328 | 328 |
| 329 /** | 329 /** |
| 330 * @override | 330 * @override |
| 331 * @return {!WebInspector.FlameChart.TimelineData} | 331 * @return {!UI.FlameChart.TimelineData} |
| 332 */ | 332 */ |
| 333 _calculateTimelineData() { | 333 _calculateTimelineData() { |
| 334 /** | 334 /** |
| 335 * @param {!WebInspector.ProfileNode} node | 335 * @param {!SDK.ProfileNode} node |
| 336 * @return {number} | 336 * @return {number} |
| 337 */ | 337 */ |
| 338 function nodesCount(node) { | 338 function nodesCount(node) { |
| 339 return node.children.reduce((count, node) => count + nodesCount(node), 1); | 339 return node.children.reduce((count, node) => count + nodesCount(node), 1); |
| 340 } | 340 } |
| 341 var count = nodesCount(this._profile.root); | 341 var count = nodesCount(this._profile.root); |
| 342 /** @type {!Array<!WebInspector.ProfileNode>} */ | 342 /** @type {!Array<!SDK.ProfileNode>} */ |
| 343 var entryNodes = new Array(count); | 343 var entryNodes = new Array(count); |
| 344 var entryLevels = new Uint16Array(count); | 344 var entryLevels = new Uint16Array(count); |
| 345 var entryTotalTimes = new Float32Array(count); | 345 var entryTotalTimes = new Float32Array(count); |
| 346 var entryStartTimes = new Float64Array(count); | 346 var entryStartTimes = new Float64Array(count); |
| 347 var depth = 0; | 347 var depth = 0; |
| 348 var maxDepth = 0; | 348 var maxDepth = 0; |
| 349 var position = 0; | 349 var position = 0; |
| 350 var index = 0; | 350 var index = 0; |
| 351 | 351 |
| 352 /** | 352 /** |
| 353 * @param {!WebInspector.ProfileNode} node | 353 * @param {!SDK.ProfileNode} node |
| 354 */ | 354 */ |
| 355 function addNode(node) { | 355 function addNode(node) { |
| 356 var start = position; | 356 var start = position; |
| 357 entryNodes[index] = node; | 357 entryNodes[index] = node; |
| 358 entryLevels[index] = depth; | 358 entryLevels[index] = depth; |
| 359 entryTotalTimes[index] = node.total; | 359 entryTotalTimes[index] = node.total; |
| 360 entryStartTimes[index] = position; | 360 entryStartTimes[index] = position; |
| 361 ++index; | 361 ++index; |
| 362 ++depth; | 362 ++depth; |
| 363 node.children.forEach(addNode); | 363 node.children.forEach(addNode); |
| 364 --depth; | 364 --depth; |
| 365 maxDepth = Math.max(maxDepth, depth); | 365 maxDepth = Math.max(maxDepth, depth); |
| 366 position = start + node.total; | 366 position = start + node.total; |
| 367 } | 367 } |
| 368 addNode(this._profile.root); | 368 addNode(this._profile.root); |
| 369 | 369 |
| 370 this._maxStackDepth = maxDepth + 1; | 370 this._maxStackDepth = maxDepth + 1; |
| 371 this._entryNodes = entryNodes; | 371 this._entryNodes = entryNodes; |
| 372 this._timelineData = new WebInspector.FlameChart.TimelineData(entryLevels, e
ntryTotalTimes, entryStartTimes, null); | 372 this._timelineData = new UI.FlameChart.TimelineData(entryLevels, entryTotalT
imes, entryStartTimes, null); |
| 373 | 373 |
| 374 return this._timelineData; | 374 return this._timelineData; |
| 375 } | 375 } |
| 376 | 376 |
| 377 /** | 377 /** |
| 378 * @override | 378 * @override |
| 379 * @param {number} entryIndex | 379 * @param {number} entryIndex |
| 380 * @return {?Element} | 380 * @return {?Element} |
| 381 */ | 381 */ |
| 382 prepareHighlightedEntryInfo(entryIndex) { | 382 prepareHighlightedEntryInfo(entryIndex) { |
| 383 var node = this._entryNodes[entryIndex]; | 383 var node = this._entryNodes[entryIndex]; |
| 384 if (!node) | 384 if (!node) |
| 385 return null; | 385 return null; |
| 386 var entryInfo = []; | 386 var entryInfo = []; |
| 387 /** | 387 /** |
| 388 * @param {string} title | 388 * @param {string} title |
| 389 * @param {string} value | 389 * @param {string} value |
| 390 */ | 390 */ |
| 391 function pushEntryInfoRow(title, value) { | 391 function pushEntryInfoRow(title, value) { |
| 392 entryInfo.push({title: title, value: value}); | 392 entryInfo.push({title: title, value: value}); |
| 393 } | 393 } |
| 394 pushEntryInfoRow(WebInspector.UIString('Name'), WebInspector.beautifyFunctio
nName(node.functionName)); | 394 pushEntryInfoRow(Common.UIString('Name'), UI.beautifyFunctionName(node.funct
ionName)); |
| 395 pushEntryInfoRow(WebInspector.UIString('Self size'), Number.bytesToString(no
de.self)); | 395 pushEntryInfoRow(Common.UIString('Self size'), Number.bytesToString(node.sel
f)); |
| 396 pushEntryInfoRow(WebInspector.UIString('Total size'), Number.bytesToString(n
ode.total)); | 396 pushEntryInfoRow(Common.UIString('Total size'), Number.bytesToString(node.to
tal)); |
| 397 var linkifier = new WebInspector.Linkifier(); | 397 var linkifier = new Components.Linkifier(); |
| 398 var link = linkifier.maybeLinkifyConsoleCallFrame(this._target, node.callFra
me); | 398 var link = linkifier.maybeLinkifyConsoleCallFrame(this._target, node.callFra
me); |
| 399 if (link) | 399 if (link) |
| 400 pushEntryInfoRow(WebInspector.UIString('URL'), link.textContent); | 400 pushEntryInfoRow(Common.UIString('URL'), link.textContent); |
| 401 linkifier.dispose(); | 401 linkifier.dispose(); |
| 402 return WebInspector.ProfileView.buildPopoverTable(entryInfo); | 402 return Profiler.ProfileView.buildPopoverTable(entryInfo); |
| 403 } | 403 } |
| 404 }; | 404 }; |
| OLD | NEW |