| 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 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 var profile = new Profiler.HeapProfileHeader(target, this); | 1029 var profile = new Profiler.HeapProfileHeader(target, this); |
| 1030 this.setProfileBeingRecorded(profile); | 1030 this.setProfileBeingRecorded(profile); |
| 1031 this.addProfile(profile); | 1031 this.addProfile(profile); |
| 1032 profile.updateStatus(Common.UIString('Snapshotting\u2026')); | 1032 profile.updateStatus(Common.UIString('Snapshotting\u2026')); |
| 1033 | 1033 |
| 1034 /** | 1034 /** |
| 1035 * @param {?string} error | 1035 * @param {?string} error |
| 1036 * @this {Profiler.HeapSnapshotProfileType} | 1036 * @this {Profiler.HeapSnapshotProfileType} |
| 1037 */ | 1037 */ |
| 1038 function didTakeHeapSnapshot(error) { | 1038 function didTakeHeapSnapshot(error) { |
| 1039 var profile = this._profileBeingRecorded; | 1039 var profile = this.profileBeingRecorded(); |
| 1040 profile.title = Common.UIString('Snapshot %d', profile.uid); | 1040 profile.title = Common.UIString('Snapshot %d', profile.uid); |
| 1041 profile._finishLoad(); | 1041 profile._finishLoad(); |
| 1042 this.setProfileBeingRecorded(null); | 1042 this.setProfileBeingRecorded(null); |
| 1043 this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete,
profile); | 1043 this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete,
profile); |
| 1044 callback(); | 1044 callback(); |
| 1045 } | 1045 } |
| 1046 target.heapProfilerAgent().takeHeapSnapshot(true, didTakeHeapSnapshot.bind(t
his)); | 1046 target.heapProfilerAgent().takeHeapSnapshot(true, didTakeHeapSnapshot.bind(t
his)); |
| 1047 } | 1047 } |
| 1048 | 1048 |
| 1049 /** | 1049 /** |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1063 var profile = this.profileBeingRecorded(); | 1063 var profile = this.profileBeingRecorded(); |
| 1064 if (!profile) | 1064 if (!profile) |
| 1065 return; | 1065 return; |
| 1066 var data = /** @type {{done: number, total: number, finished: boolean}} */ (
event.data); | 1066 var data = /** @type {{done: number, total: number, finished: boolean}} */ (
event.data); |
| 1067 profile.updateStatus(Common.UIString('%.0f%%', (data.done / data.total) * 10
0), true); | 1067 profile.updateStatus(Common.UIString('%.0f%%', (data.done / data.total) * 10
0), true); |
| 1068 if (data.finished) | 1068 if (data.finished) |
| 1069 profile._prepareToLoad(); | 1069 profile._prepareToLoad(); |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 _resetProfiles() { | 1072 _resetProfiles() { |
| 1073 this._reset(); | 1073 this.reset(); |
| 1074 } | 1074 } |
| 1075 | 1075 |
| 1076 _snapshotReceived(profile) { | 1076 _snapshotReceived(profile) { |
| 1077 if (this._profileBeingRecorded === profile) | 1077 if (this.profileBeingRecorded() === profile) |
| 1078 this.setProfileBeingRecorded(null); | 1078 this.setProfileBeingRecorded(null); |
| 1079 this.dispatchEventToListeners(Profiler.HeapSnapshotProfileType.SnapshotRecei
ved, profile); | 1079 this.dispatchEventToListeners(Profiler.HeapSnapshotProfileType.SnapshotRecei
ved, profile); |
| 1080 } | 1080 } |
| 1081 }; | 1081 }; |
| 1082 | 1082 |
| 1083 Profiler.HeapSnapshotProfileType.TypeId = 'HEAP'; | 1083 Profiler.HeapSnapshotProfileType.TypeId = 'HEAP'; |
| 1084 Profiler.HeapSnapshotProfileType.SnapshotReceived = 'SnapshotReceived'; | 1084 Profiler.HeapSnapshotProfileType.SnapshotReceived = 'SnapshotReceived'; |
| 1085 | 1085 |
| 1086 /** | 1086 /** |
| 1087 * @unrestricted | 1087 * @unrestricted |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 var currentIndex = Math.max(profileSamples.ids.length, profileSamples.max.le
ngth - 1); | 1143 var currentIndex = Math.max(profileSamples.ids.length, profileSamples.max.le
ngth - 1); |
| 1144 profileSamples.ids[currentIndex] = data.lastSeenObjectId; | 1144 profileSamples.ids[currentIndex] = data.lastSeenObjectId; |
| 1145 if (!profileSamples.max[currentIndex]) { | 1145 if (!profileSamples.max[currentIndex]) { |
| 1146 profileSamples.max[currentIndex] = 0; | 1146 profileSamples.max[currentIndex] = 0; |
| 1147 profileSamples.sizes[currentIndex] = 0; | 1147 profileSamples.sizes[currentIndex] = 0; |
| 1148 } | 1148 } |
| 1149 profileSamples.timestamps[currentIndex] = data.timestamp; | 1149 profileSamples.timestamps[currentIndex] = data.timestamp; |
| 1150 if (profileSamples.totalTime < data.timestamp - profileSamples.timestamps[0]
) | 1150 if (profileSamples.totalTime < data.timestamp - profileSamples.timestamps[0]
) |
| 1151 profileSamples.totalTime *= 2; | 1151 profileSamples.totalTime *= 2; |
| 1152 this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.HeapS
tatsUpdate, this._profileSamples); | 1152 this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.HeapS
tatsUpdate, this._profileSamples); |
| 1153 this._profileBeingRecorded.updateStatus(null, true); | 1153 this.profileBeingRecorded().updateStatus(null, true); |
| 1154 } | 1154 } |
| 1155 | 1155 |
| 1156 /** | 1156 /** |
| 1157 * @override | 1157 * @override |
| 1158 * @return {boolean} | 1158 * @return {boolean} |
| 1159 */ | 1159 */ |
| 1160 hasTemporaryView() { | 1160 hasTemporaryView() { |
| 1161 return true; | 1161 return true; |
| 1162 } | 1162 } |
| 1163 | 1163 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1187 return; | 1187 return; |
| 1188 this._addNewProfile(); | 1188 this._addNewProfile(); |
| 1189 var recordAllocationStacks = Common.moduleSetting('recordAllocationStacks').
get(); | 1189 var recordAllocationStacks = Common.moduleSetting('recordAllocationStacks').
get(); |
| 1190 this.profileBeingRecorded().target().heapProfilerAgent().startTrackingHeapOb
jects(recordAllocationStacks); | 1190 this.profileBeingRecorded().target().heapProfilerAgent().startTrackingHeapOb
jects(recordAllocationStacks); |
| 1191 } | 1191 } |
| 1192 | 1192 |
| 1193 _addNewProfile() { | 1193 _addNewProfile() { |
| 1194 var target = UI.context.flavor(SDK.Target); | 1194 var target = UI.context.flavor(SDK.Target); |
| 1195 this.setProfileBeingRecorded(new Profiler.HeapProfileHeader(target, this, un
defined)); | 1195 this.setProfileBeingRecorded(new Profiler.HeapProfileHeader(target, this, un
defined)); |
| 1196 this._profileSamples = new Profiler.TrackingHeapSnapshotProfileType.Samples(
); | 1196 this._profileSamples = new Profiler.TrackingHeapSnapshotProfileType.Samples(
); |
| 1197 this._profileBeingRecorded._profileSamples = this._profileSamples; | 1197 this.profileBeingRecorded()._profileSamples = this._profileSamples; |
| 1198 this._recording = true; | 1198 this._recording = true; |
| 1199 this.addProfile(this._profileBeingRecorded); | 1199 this.addProfile(/** @type {!Profiler.ProfileHeader} */ (this.profileBeingRec
orded())); |
| 1200 this._profileBeingRecorded.updateStatus(Common.UIString('Recording\u2026')); | 1200 this.profileBeingRecorded().updateStatus(Common.UIString('Recording\u2026'))
; |
| 1201 this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.Track
ingStarted); | 1201 this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.Track
ingStarted); |
| 1202 } | 1202 } |
| 1203 | 1203 |
| 1204 _stopRecordingProfile() { | 1204 _stopRecordingProfile() { |
| 1205 this._profileBeingRecorded.updateStatus(Common.UIString('Snapshotting\u2026'
)); | 1205 this.profileBeingRecorded().updateStatus(Common.UIString('Snapshotting\u2026
')); |
| 1206 /** | 1206 /** |
| 1207 * @param {?string} error | 1207 * @param {?string} error |
| 1208 * @this {Profiler.HeapSnapshotProfileType} | 1208 * @this {Profiler.HeapSnapshotProfileType} |
| 1209 */ | 1209 */ |
| 1210 function didTakeHeapSnapshot(error) { | 1210 function didTakeHeapSnapshot(error) { |
| 1211 var profile = this.profileBeingRecorded(); | 1211 var profile = this.profileBeingRecorded(); |
| 1212 if (!profile) | 1212 if (!profile) |
| 1213 return; | 1213 return; |
| 1214 profile._finishLoad(); | 1214 profile._finishLoad(); |
| 1215 this._profileSamples = null; | 1215 this._profileSamples = null; |
| 1216 this.setProfileBeingRecorded(null); | 1216 this.setProfileBeingRecorded(null); |
| 1217 this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete,
profile); | 1217 this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete,
profile); |
| 1218 } | 1218 } |
| 1219 | 1219 |
| 1220 this._profileBeingRecorded.target().heapProfilerAgent().stopTrackingHeapObje
cts( | 1220 this.profileBeingRecorded().target().heapProfilerAgent().stopTrackingHeapObj
ects( |
| 1221 true, didTakeHeapSnapshot.bind(this)); | 1221 true, didTakeHeapSnapshot.bind(this)); |
| 1222 this._recording = false; | 1222 this._recording = false; |
| 1223 this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.Track
ingStopped); | 1223 this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.Track
ingStopped); |
| 1224 } | 1224 } |
| 1225 | 1225 |
| 1226 _toggleRecording() { | 1226 _toggleRecording() { |
| 1227 if (this._recording) | 1227 if (this._recording) |
| 1228 this._stopRecordingProfile(); | 1228 this._stopRecordingProfile(); |
| 1229 else | 1229 else |
| 1230 this._startRecordingProfile(); | 1230 this._startRecordingProfile(); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1446 this._receiver = null; | 1446 this._receiver = null; |
| 1447 this._snapshotProxy = snapshotProxy; | 1447 this._snapshotProxy = snapshotProxy; |
| 1448 this.maxJSObjectId = snapshotProxy.maxJSObjectId(); | 1448 this.maxJSObjectId = snapshotProxy.maxJSObjectId(); |
| 1449 this._didCompleteSnapshotTransfer(); | 1449 this._didCompleteSnapshotTransfer(); |
| 1450 this._workerProxy.startCheckingForLongRunningCalls(); | 1450 this._workerProxy.startCheckingForLongRunningCalls(); |
| 1451 this.notifySnapshotReceived(); | 1451 this.notifySnapshotReceived(); |
| 1452 } | 1452 } |
| 1453 | 1453 |
| 1454 notifySnapshotReceived() { | 1454 notifySnapshotReceived() { |
| 1455 this._fulfillLoad(this._snapshotProxy); | 1455 this._fulfillLoad(this._snapshotProxy); |
| 1456 this._profileType._snapshotReceived(this); | 1456 this.profileType()._snapshotReceived(this); |
| 1457 if (this.canSaveToFile()) | 1457 if (this.canSaveToFile()) |
| 1458 this.dispatchEventToListeners(Profiler.ProfileHeader.Events.ProfileReceive
d); | 1458 this.dispatchEventToListeners(Profiler.ProfileHeader.Events.ProfileReceive
d); |
| 1459 } | 1459 } |
| 1460 | 1460 |
| 1461 // Hook point for tests. | 1461 // Hook point for tests. |
| 1462 _wasShown() { | 1462 _wasShown() { |
| 1463 } | 1463 } |
| 1464 | 1464 |
| 1465 /** | 1465 /** |
| 1466 * @override | 1466 * @override |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1487 Common.console.error('Failed to open temp file with heap snapshot'); | 1487 Common.console.error('Failed to open temp file with heap snapshot'); |
| 1488 fileOutputStream.close(); | 1488 fileOutputStream.close(); |
| 1489 } else if (this._tempFile) { | 1489 } else if (this._tempFile) { |
| 1490 var delegate = new Profiler.SaveSnapshotOutputStreamDelegate(this); | 1490 var delegate = new Profiler.SaveSnapshotOutputStreamDelegate(this); |
| 1491 this._tempFile.copyToOutputStream(fileOutputStream, delegate); | 1491 this._tempFile.copyToOutputStream(fileOutputStream, delegate); |
| 1492 } else { | 1492 } else { |
| 1493 this._onTempFileReady = onOpen.bind(this, accepted); | 1493 this._onTempFileReady = onOpen.bind(this, accepted); |
| 1494 this._updateSaveProgress(0, 1); | 1494 this._updateSaveProgress(0, 1); |
| 1495 } | 1495 } |
| 1496 } | 1496 } |
| 1497 this._fileName = this._fileName || 'Heap-' + new Date().toISO8601Compact() +
this._profileType.fileExtension(); | 1497 this._fileName = this._fileName || 'Heap-' + new Date().toISO8601Compact() +
this.profileType().fileExtension(); |
| 1498 fileOutputStream.open(this._fileName, onOpen.bind(this)); | 1498 fileOutputStream.open(this._fileName, onOpen.bind(this)); |
| 1499 } | 1499 } |
| 1500 | 1500 |
| 1501 _updateSaveProgress(value, total) { | 1501 _updateSaveProgress(value, total) { |
| 1502 var percentValue = ((total ? (value / total) : 0) * 100).toFixed(0); | 1502 var percentValue = ((total ? (value / total) : 0) * 100).toFixed(0); |
| 1503 this.updateStatus(Common.UIString('Saving\u2026 %d%%', percentValue)); | 1503 this.updateStatus(Common.UIString('Saving\u2026 %d%%', percentValue)); |
| 1504 } | 1504 } |
| 1505 | 1505 |
| 1506 /** | 1506 /** |
| 1507 * @override | 1507 * @override |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2082 var name = frameDiv.createChild('div'); | 2082 var name = frameDiv.createChild('div'); |
| 2083 name.textContent = UI.beautifyFunctionName(frame.functionName); | 2083 name.textContent = UI.beautifyFunctionName(frame.functionName); |
| 2084 if (frame.scriptId) { | 2084 if (frame.scriptId) { |
| 2085 var urlElement = this._linkifier.linkifyScriptLocation( | 2085 var urlElement = this._linkifier.linkifyScriptLocation( |
| 2086 this._target, String(frame.scriptId), frame.scriptName, frame.line -
1, frame.column - 1); | 2086 this._target, String(frame.scriptId), frame.scriptName, frame.line -
1, frame.column - 1); |
| 2087 frameDiv.appendChild(urlElement); | 2087 frameDiv.appendChild(urlElement); |
| 2088 } | 2088 } |
| 2089 } | 2089 } |
| 2090 } | 2090 } |
| 2091 }; | 2091 }; |
| OLD | NEW |