| 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 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 * @param {number} uid | 754 * @param {number} uid |
| 755 * @param {string} chunk | 755 * @param {string} chunk |
| 756 */ | 756 */ |
| 757 addHeapSnapshotChunk: function(uid, chunk) | 757 addHeapSnapshotChunk: function(uid, chunk) |
| 758 { | 758 { |
| 759 this._genericCaller("addHeapSnapshotChunk"); | 759 this._genericCaller("addHeapSnapshotChunk"); |
| 760 }, | 760 }, |
| 761 | 761 |
| 762 /** | 762 /** |
| 763 * @override | 763 * @override |
| 764 * @param {number} uid | |
| 765 */ | |
| 766 finishHeapSnapshot: function(uid) | |
| 767 { | |
| 768 this._genericCaller("finishHeapSnapshot"); | |
| 769 }, | |
| 770 | |
| 771 /** | |
| 772 * @override | |
| 773 * @param {number} done | 764 * @param {number} done |
| 774 * @param {number} total | 765 * @param {number} total |
| 775 */ | 766 */ |
| 776 reportHeapSnapshotProgress: function(done, total) | 767 reportHeapSnapshotProgress: function(done, total) |
| 777 { | 768 { |
| 778 this._genericCaller("reportHeapSnapshotProgress"); | 769 this._genericCaller("reportHeapSnapshotProgress"); |
| 779 }, | 770 }, |
| 780 | 771 |
| 781 /** | 772 /** |
| 782 * @override | 773 * @override |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 */ | 905 */ |
| 915 addHeapSnapshotChunk: function(uid, chunk) | 906 addHeapSnapshotChunk: function(uid, chunk) |
| 916 { | 907 { |
| 917 var profile = this._profilesIdMap[this._makeKey(uid)]; | 908 var profile = this._profilesIdMap[this._makeKey(uid)]; |
| 918 if (profile) | 909 if (profile) |
| 919 profile.transferChunk(chunk); | 910 profile.transferChunk(chunk); |
| 920 }, | 911 }, |
| 921 | 912 |
| 922 /** | 913 /** |
| 923 * @override | 914 * @override |
| 924 * @param {number} uid | |
| 925 */ | |
| 926 finishHeapSnapshot: function(uid) | |
| 927 { | |
| 928 var profile = this._profilesIdMap[this._makeKey(uid)]; | |
| 929 if (profile) | |
| 930 profile.finishHeapSnapshot(); | |
| 931 }, | |
| 932 | |
| 933 /** | |
| 934 * @override | |
| 935 * @param {number} done | 915 * @param {number} done |
| 936 * @param {number} total | 916 * @param {number} total |
| 937 */ | 917 */ |
| 938 reportHeapSnapshotProgress: function(done, total) | 918 reportHeapSnapshotProgress: function(done, total) |
| 939 { | 919 { |
| 940 var profile = this.findTemporaryProfile(); | 920 var profile = this.findTemporaryProfile(); |
| 941 if (profile) | 921 if (profile) |
| 942 this.dispatchEventToListeners(WebInspector.ProfileType.Events.Progre
ssUpdated, {"profile": profile, "done": done, "total": total}); | 922 this.dispatchEventToListeners(WebInspector.ProfileType.Events.Progre
ssUpdated, {"profile": profile, "done": done, "total": total}); |
| 943 }, | 923 }, |
| 944 | 924 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 callback(this._snapshotProxy); | 1167 callback(this._snapshotProxy); |
| 1188 return; | 1168 return; |
| 1189 } | 1169 } |
| 1190 | 1170 |
| 1191 this._numberOfChunks = 0; | 1171 this._numberOfChunks = 0; |
| 1192 if (!this._receiver) { | 1172 if (!this._receiver) { |
| 1193 this._setupWorker(); | 1173 this._setupWorker(); |
| 1194 this._transferHandler = new WebInspector.BackendSnapshotLoader(this)
; | 1174 this._transferHandler = new WebInspector.BackendSnapshotLoader(this)
; |
| 1195 this.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026"
); | 1175 this.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026"
); |
| 1196 this.sidebarElement.wait = true; | 1176 this.sidebarElement.wait = true; |
| 1197 this.startSnapshotTransfer(); | 1177 this._transferSnapshot(); |
| 1198 } | 1178 } |
| 1199 var loaderProxy = /** @type {WebInspector.HeapSnapshotLoaderProxy} */ (t
his._receiver); | 1179 var loaderProxy = /** @type {WebInspector.HeapSnapshotLoaderProxy} */ (t
his._receiver); |
| 1200 loaderProxy.addConsumer(callback); | 1180 loaderProxy.addConsumer(callback); |
| 1201 }, | 1181 }, |
| 1202 | 1182 |
| 1203 startSnapshotTransfer: function() | 1183 _transferSnapshot: function() |
| 1204 { | 1184 { |
| 1205 HeapProfilerAgent.getHeapSnapshot(this.uid); | 1185 function finishTransfer() |
| 1186 { |
| 1187 if (this._transferHandler) { |
| 1188 this._transferHandler.finishTransfer(); |
| 1189 this._totalNumberOfChunks = this._transferHandler._totalNumberOf
Chunks; |
| 1190 } |
| 1191 } |
| 1192 HeapProfilerAgent.getHeapSnapshot(this.uid, finishTransfer.bind(this)); |
| 1206 }, | 1193 }, |
| 1207 | 1194 |
| 1208 snapshotConstructorName: function() | 1195 snapshotConstructorName: function() |
| 1209 { | 1196 { |
| 1210 return "JSHeapSnapshot"; | 1197 return "JSHeapSnapshot"; |
| 1211 }, | 1198 }, |
| 1212 | 1199 |
| 1213 snapshotProxyConstructor: function() | 1200 snapshotProxyConstructor: function() |
| 1214 { | 1201 { |
| 1215 return WebInspector.HeapSnapshotProxy; | 1202 return WebInspector.HeapSnapshotProxy; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 } | 1279 } |
| 1293 snapshotProxy.maxJsNodeId(didGetMaxNodeId.bind(this)); | 1280 snapshotProxy.maxJsNodeId(didGetMaxNodeId.bind(this)); |
| 1294 } | 1281 } |
| 1295 }, | 1282 }, |
| 1296 | 1283 |
| 1297 notifySnapshotReceived: function() | 1284 notifySnapshotReceived: function() |
| 1298 { | 1285 { |
| 1299 this._profileType._snapshotReceived(this); | 1286 this._profileType._snapshotReceived(this); |
| 1300 }, | 1287 }, |
| 1301 | 1288 |
| 1302 finishHeapSnapshot: function() | |
| 1303 { | |
| 1304 if (this._transferHandler) { | |
| 1305 this._transferHandler.finishTransfer(); | |
| 1306 this._totalNumberOfChunks = this._transferHandler._totalNumberOfChun
ks; | |
| 1307 } | |
| 1308 }, | |
| 1309 | |
| 1310 // Hook point for tests. | 1289 // Hook point for tests. |
| 1311 _wasShown: function() | 1290 _wasShown: function() |
| 1312 { | 1291 { |
| 1313 }, | 1292 }, |
| 1314 | 1293 |
| 1315 /** | 1294 /** |
| 1316 * @override | 1295 * @override |
| 1317 * @return {boolean} | 1296 * @return {boolean} |
| 1318 */ | 1297 */ |
| 1319 canSaveToFile: function() | 1298 canSaveToFile: function() |
| 1320 { | 1299 { |
| 1321 return !this.fromFile() && !!this._snapshotProxy && !this._receiver; | 1300 return !this.fromFile() && !!this._snapshotProxy && !this._receiver; |
| 1322 }, | 1301 }, |
| 1323 | 1302 |
| 1324 /** | 1303 /** |
| 1325 * @override | 1304 * @override |
| 1326 */ | 1305 */ |
| 1327 saveToFile: function() | 1306 saveToFile: function() |
| 1328 { | 1307 { |
| 1329 var fileOutputStream = new WebInspector.FileOutputStream(); | 1308 var fileOutputStream = new WebInspector.FileOutputStream(); |
| 1330 function onOpen() | 1309 function onOpen() |
| 1331 { | 1310 { |
| 1332 this._receiver = fileOutputStream; | 1311 this._receiver = fileOutputStream; |
| 1333 this._transferHandler = new WebInspector.SaveSnapshotHandler(this); | 1312 this._transferHandler = new WebInspector.SaveSnapshotHandler(this); |
| 1334 HeapProfilerAgent.getHeapSnapshot(this.uid); | 1313 this._transferSnapshot(); |
| 1335 } | 1314 } |
| 1336 this._fileName = this._fileName || "Heap-" + new Date().toISO8601Compact
() + this._profileType.fileExtension(); | 1315 this._fileName = this._fileName || "Heap-" + new Date().toISO8601Compact
() + this._profileType.fileExtension(); |
| 1337 fileOutputStream.open(this._fileName, onOpen.bind(this)); | 1316 fileOutputStream.open(this._fileName, onOpen.bind(this)); |
| 1338 }, | 1317 }, |
| 1339 | 1318 |
| 1340 /** | 1319 /** |
| 1341 * @override | 1320 * @override |
| 1342 * @param {File} file | 1321 * @param {File} file |
| 1343 */ | 1322 */ |
| 1344 loadFromFile: function(file) | 1323 loadFromFile: function(file) |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1828 zeroTime: function() | 1807 zeroTime: function() |
| 1829 { | 1808 { |
| 1830 return this._minimumBoundaries; | 1809 return this._minimumBoundaries; |
| 1831 }, | 1810 }, |
| 1832 | 1811 |
| 1833 boundarySpan: function() | 1812 boundarySpan: function() |
| 1834 { | 1813 { |
| 1835 return this._maximumBoundaries - this._minimumBoundaries; | 1814 return this._maximumBoundaries - this._minimumBoundaries; |
| 1836 } | 1815 } |
| 1837 } | 1816 } |
| OLD | NEW |