| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 */ | 1028 */ |
| 1029 isInstantProfile() { | 1029 isInstantProfile() { |
| 1030 return true; | 1030 return true; |
| 1031 } | 1031 } |
| 1032 | 1032 |
| 1033 /** | 1033 /** |
| 1034 * @override | 1034 * @override |
| 1035 * @return {boolean} | 1035 * @return {boolean} |
| 1036 */ | 1036 */ |
| 1037 buttonClicked() { | 1037 buttonClicked() { |
| 1038 this._takeHeapSnapshot(function() {}); | 1038 this._takeHeapSnapshot(); |
| 1039 Host.userMetrics.actionTaken(Host.UserMetrics.Action.ProfilesHeapProfileTake
n); | 1039 Host.userMetrics.actionTaken(Host.UserMetrics.Action.ProfilesHeapProfileTake
n); |
| 1040 return false; | 1040 return false; |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 get treeItemTitle() { | 1043 get treeItemTitle() { |
| 1044 return Common.UIString('HEAP SNAPSHOTS'); | 1044 return Common.UIString('HEAP SNAPSHOTS'); |
| 1045 } | 1045 } |
| 1046 | 1046 |
| 1047 get description() { | 1047 get description() { |
| 1048 return Common.UIString( | 1048 return Common.UIString( |
| 1049 'Heap snapshot profiles show memory distribution among your page\'s Java
Script objects and related DOM nodes.'); | 1049 'Heap snapshot profiles show memory distribution among your page\'s Java
Script objects and related DOM nodes.'); |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 /** | 1052 /** |
| 1053 * @override | 1053 * @override |
| 1054 * @param {string} title | 1054 * @param {string} title |
| 1055 * @return {!Profiler.ProfileHeader} | 1055 * @return {!Profiler.ProfileHeader} |
| 1056 */ | 1056 */ |
| 1057 createProfileLoadedFromFile(title) { | 1057 createProfileLoadedFromFile(title) { |
| 1058 return new Profiler.HeapProfileHeader(null, this, title); | 1058 return new Profiler.HeapProfileHeader(null, this, title); |
| 1059 } | 1059 } |
| 1060 | 1060 |
| 1061 _takeHeapSnapshot(callback) { | 1061 async _takeHeapSnapshot() { |
| 1062 if (this.profileBeingRecorded()) | 1062 if (this.profileBeingRecorded()) |
| 1063 return; | 1063 return; |
| 1064 var heapProfilerModel = UI.context.flavor(SDK.HeapProfilerModel); | 1064 var heapProfilerModel = UI.context.flavor(SDK.HeapProfilerModel); |
| 1065 if (!heapProfilerModel) | 1065 if (!heapProfilerModel) |
| 1066 return; | 1066 return; |
| 1067 | 1067 |
| 1068 var profile = new Profiler.HeapProfileHeader(heapProfilerModel, this); | 1068 var profile = new Profiler.HeapProfileHeader(heapProfilerModel, this); |
| 1069 this.setProfileBeingRecorded(profile); | 1069 this.setProfileBeingRecorded(profile); |
| 1070 this.addProfile(profile); | 1070 this.addProfile(profile); |
| 1071 profile.updateStatus(Common.UIString('Snapshotting\u2026')); | 1071 profile.updateStatus(Common.UIString('Snapshotting\u2026')); |
| 1072 | 1072 |
| 1073 heapProfilerModel.takeHeapSnapshot(true).then(success => { | 1073 await heapProfilerModel.takeHeapSnapshot(true); |
| 1074 var profile = this.profileBeingRecorded(); | 1074 // ------------ ASYNC ------------ |
| 1075 profile.title = Common.UIString('Snapshot %d', profile.uid); | 1075 profile = this.profileBeingRecorded(); |
| 1076 profile._finishLoad(); | 1076 profile.title = Common.UIString('Snapshot %d', profile.uid); |
| 1077 this.setProfileBeingRecorded(null); | 1077 profile._finishLoad(); |
| 1078 this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete,
profile); | 1078 this.setProfileBeingRecorded(null); |
| 1079 callback(); | 1079 this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete, p
rofile); |
| 1080 }); | |
| 1081 } | 1080 } |
| 1082 | 1081 |
| 1083 /** | 1082 /** |
| 1084 * @param {!Common.Event} event | 1083 * @param {!Common.Event} event |
| 1085 */ | 1084 */ |
| 1086 _addHeapSnapshotChunk(event) { | 1085 _addHeapSnapshotChunk(event) { |
| 1087 if (!this.profileBeingRecorded()) | 1086 if (!this.profileBeingRecorded()) |
| 1088 return; | 1087 return; |
| 1089 var chunk = /** @type {string} */ (event.data); | 1088 var chunk = /** @type {string} */ (event.data); |
| 1090 this.profileBeingRecorded().transferChunk(chunk); | 1089 this.profileBeingRecorded().transferChunk(chunk); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1239 this.setProfileBeingRecorded(new Profiler.HeapProfileHeader(heapProfilerMode
l, this, undefined)); | 1238 this.setProfileBeingRecorded(new Profiler.HeapProfileHeader(heapProfilerMode
l, this, undefined)); |
| 1240 this._profileSamples = new Profiler.TrackingHeapSnapshotProfileType.Samples(
); | 1239 this._profileSamples = new Profiler.TrackingHeapSnapshotProfileType.Samples(
); |
| 1241 this.profileBeingRecorded()._profileSamples = this._profileSamples; | 1240 this.profileBeingRecorded()._profileSamples = this._profileSamples; |
| 1242 this._recording = true; | 1241 this._recording = true; |
| 1243 this.addProfile(/** @type {!Profiler.ProfileHeader} */ (this.profileBeingRec
orded())); | 1242 this.addProfile(/** @type {!Profiler.ProfileHeader} */ (this.profileBeingRec
orded())); |
| 1244 this.profileBeingRecorded().updateStatus(Common.UIString('Recording\u2026'))
; | 1243 this.profileBeingRecorded().updateStatus(Common.UIString('Recording\u2026'))
; |
| 1245 this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.Track
ingStarted); | 1244 this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.Track
ingStarted); |
| 1246 return heapProfilerModel; | 1245 return heapProfilerModel; |
| 1247 } | 1246 } |
| 1248 | 1247 |
| 1249 _stopRecordingProfile() { | 1248 async _stopRecordingProfile() { |
| 1250 this.profileBeingRecorded().updateStatus(Common.UIString('Snapshotting\u2026
')); | 1249 this.profileBeingRecorded().updateStatus(Common.UIString('Snapshotting\u2026
')); |
| 1251 /** | 1250 var stopPromise = this.profileBeingRecorded()._heapProfilerModel.stopTrackin
gHeapObjects(true); |
| 1252 * @param {boolean} success | |
| 1253 * @this {Profiler.HeapSnapshotProfileType} | |
| 1254 */ | |
| 1255 function didTakeHeapSnapshot(success) { | |
| 1256 var profile = this.profileBeingRecorded(); | |
| 1257 if (!profile) | |
| 1258 return; | |
| 1259 profile._finishLoad(); | |
| 1260 this._profileSamples = null; | |
| 1261 this.setProfileBeingRecorded(null); | |
| 1262 this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete,
profile); | |
| 1263 } | |
| 1264 | |
| 1265 this.profileBeingRecorded()._heapProfilerModel.stopTrackingHeapObjects(true)
.then(didTakeHeapSnapshot.bind(this)); | |
| 1266 this._recording = false; | 1251 this._recording = false; |
| 1267 this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.Track
ingStopped); | 1252 this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.Track
ingStopped); |
| 1253 await stopPromise; |
| 1254 // ------------ ASYNC ------------ |
| 1255 var profile = this.profileBeingRecorded(); |
| 1256 if (!profile) |
| 1257 return; |
| 1258 profile._finishLoad(); |
| 1259 this._profileSamples = null; |
| 1260 this.setProfileBeingRecorded(null); |
| 1261 this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete, p
rofile); |
| 1268 } | 1262 } |
| 1269 | 1263 |
| 1270 _toggleRecording() { | 1264 _toggleRecording() { |
| 1271 if (this._recording) | 1265 if (this._recording) |
| 1272 this._stopRecordingProfile(); | 1266 this._stopRecordingProfile(); |
| 1273 else | 1267 else |
| 1274 this._startRecordingProfile(); | 1268 this._startRecordingProfile(); |
| 1275 return this._recording; | 1269 return this._recording; |
| 1276 } | 1270 } |
| 1277 | 1271 |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2128 name.textContent = UI.beautifyFunctionName(frame.functionName); | 2122 name.textContent = UI.beautifyFunctionName(frame.functionName); |
| 2129 if (frame.scriptId) { | 2123 if (frame.scriptId) { |
| 2130 var urlElement = this._linkifier.linkifyScriptLocation( | 2124 var urlElement = this._linkifier.linkifyScriptLocation( |
| 2131 this._heapProfilerModel ? this._heapProfilerModel.target() : null, S
tring(frame.scriptId), frame.scriptName, | 2125 this._heapProfilerModel ? this._heapProfilerModel.target() : null, S
tring(frame.scriptId), frame.scriptName, |
| 2132 frame.line - 1, frame.column - 1); | 2126 frame.line - 1, frame.column - 1); |
| 2133 frameDiv.appendChild(urlElement); | 2127 frameDiv.appendChild(urlElement); |
| 2134 } | 2128 } |
| 2135 } | 2129 } |
| 2136 } | 2130 } |
| 2137 }; | 2131 }; |
| OLD | NEW |