Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /** | 1 /** |
| 2 * @unrestricted | 2 * @unrestricted |
| 3 */ | 3 */ |
| 4 SDK.HeapProfilerModel = class extends SDK.SDKModel { | 4 SDK.HeapProfilerModel = class extends SDK.SDKModel { |
| 5 /** | 5 /** |
| 6 * @param {!SDK.Target} target | 6 * @param {!SDK.Target} target |
| 7 */ | 7 */ |
| 8 constructor(target) { | 8 constructor(target) { |
| 9 super(target); | 9 super(target); |
| 10 target.registerHeapProfilerDispatcher(new SDK.HeapProfilerDispatcher(this)); | 10 target.registerHeapProfilerDispatcher(new SDK.HeapProfilerDispatcher(this)); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 this._enabled = true; | 34 this._enabled = true; |
| 35 this._heapProfilerAgent.enable(); | 35 this._heapProfilerAgent.enable(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 startSampling() { | 38 startSampling() { |
| 39 var defaultSamplingIntervalInBytes = 16384; | 39 var defaultSamplingIntervalInBytes = 16384; |
| 40 this._heapProfilerAgent.startSampling(defaultSamplingIntervalInBytes); | 40 this._heapProfilerAgent.startSampling(defaultSamplingIntervalInBytes); |
| 41 } | 41 } |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * @return {!Promise.<?Protocol.HeapProfiler.SamplingHeapProfile>} | 44 * @return {!Promise<?Protocol.HeapProfiler.SamplingHeapProfile>} |
| 45 */ | 45 */ |
| 46 stopSampling() { | 46 stopSampling() { |
| 47 this._isRecording = false; | 47 this._isRecording = false; |
| 48 return this._heapProfilerAgent.stopSampling((error, profile) => error ? null : profile); | 48 return this._heapProfilerAgent.stopSampling(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 /** | 51 /** |
| 52 * @return {!Promise} | 52 * @return {!Promise} |
| 53 */ | 53 */ |
| 54 collectGarbage() { | 54 collectGarbage() { |
| 55 return this._heapProfilerAgent.collectGarbage(); | 55 return this._heapProfilerAgent.collectGarbage(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * @param {string} objectId | 59 * @param {string} objectId |
| 60 * @return {!Promise<?string>} | 60 * @return {!Promise<?string>} |
| 61 */ | 61 */ |
| 62 snapshotObjectIdForObjectId(objectId) { | 62 snapshotObjectIdForObjectId(objectId) { |
| 63 return this._heapProfilerAgent.getHeapObjectId(objectId, (error, result) => error ? null : result); | 63 return this._heapProfilerAgent.getHeapObjectId(objectId); |
| 64 } | 64 } |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * @param {string} snapshotObjectId | 67 * @param {string} snapshotObjectId |
| 68 * @param {string} objectGroupName | 68 * @param {string} objectGroupName |
| 69 * @return {!Promise<?SDK.RemoteObject>} | 69 * @return {!Promise<?SDK.RemoteObject>} |
| 70 */ | 70 */ |
| 71 objectForSnapshotObjectId(snapshotObjectId, objectGroupName) { | 71 objectForSnapshotObjectId(snapshotObjectId, objectGroupName) { |
| 72 return this._heapProfilerAgent.getObjectByHeapObjectId(snapshotObjectId, obj ectGroupName, (error, result) => { | 72 return this._heapProfilerAgent.getObjectByHeapObjectId(snapshotObjectId, obj ectGroupName) |
| 73 if (error || !result.type) | 73 .then(result => result && result.type ? this._runtimeModel.createRemoteO bject(result) : null); |
| 74 return null; | |
| 75 return this._runtimeModel.createRemoteObject(result); | |
| 76 }); | |
| 77 } | 74 } |
| 78 | 75 |
| 79 /** | 76 /** |
| 80 * @param {string} snapshotObjectId | 77 * @param {string} snapshotObjectId |
| 81 * @return {!Promise} | 78 * @return {!Promise} |
| 82 */ | 79 */ |
| 83 addInspectedHeapObject(snapshotObjectId) { | 80 addInspectedHeapObject(snapshotObjectId) { |
| 84 return this._heapProfilerAgent.addInspectedHeapObject(snapshotObjectId); | 81 return this._heapProfilerAgent.addInspectedHeapObject(snapshotObjectId); |
| 85 } | 82 } |
| 86 | 83 |
| 87 /** | 84 /** |
| 88 * @param {boolean} reportProgress | 85 * @param {boolean} reportProgress |
| 89 * @return {!Promise<boolean>} | 86 * @return {!Promise<boolean>} |
| 90 */ | 87 */ |
| 91 takeHeapSnapshot(reportProgress) { | 88 takeHeapSnapshot(reportProgress) { |
| 92 return this._heapProfilerAgent.takeHeapSnapshot(reportProgress, error => !er ror); | 89 return this._heapProfilerAgent.invoke_takeHeapSnapshot({reportProgress: repo rtProgress}) |
|
dgozman
2017/05/02 20:03:41
Can we do something here? Do you have an idea how
alph
2017/05/02 22:48:06
Done.
| |
| 90 .then(response => !response[Protocol.Error]); | |
| 93 } | 91 } |
| 94 | 92 |
| 95 /** | 93 /** |
| 96 * @param {boolean} recordAllocationStacks | 94 * @param {boolean} recordAllocationStacks |
| 97 * @return {!Promise} | 95 * @return {!Promise} |
| 98 */ | 96 */ |
| 99 startTrackingHeapObjects(recordAllocationStacks) { | 97 startTrackingHeapObjects(recordAllocationStacks) { |
| 100 return this._heapProfilerAgent.startTrackingHeapObjects(recordAllocationStac ks); | 98 return this._heapProfilerAgent.startTrackingHeapObjects(recordAllocationStac ks); |
| 101 } | 99 } |
| 102 | 100 |
| 103 /** | 101 /** |
| 104 * @param {boolean} reportProgress | 102 * @param {boolean} reportProgress |
| 105 * @return {!Promise<boolean>} | 103 * @return {!Promise<boolean>} |
| 106 */ | 104 */ |
| 107 stopTrackingHeapObjects(reportProgress) { | 105 stopTrackingHeapObjects(reportProgress) { |
| 108 return this._heapProfilerAgent.stopTrackingHeapObjects(reportProgress, error => !error); | 106 return this._heapProfilerAgent.invoke_stopTrackingHeapObjects({reportProgres s: reportProgress}) |
| 107 .then(response => !response[Protocol.Error]); | |
| 109 } | 108 } |
| 110 | 109 |
| 111 /** | 110 /** |
| 112 * @param {!Array.<number>} samples | 111 * @param {!Array<number>} samples |
| 113 */ | 112 */ |
| 114 heapStatsUpdate(samples) { | 113 heapStatsUpdate(samples) { |
| 115 this.dispatchEventToListeners(SDK.HeapProfilerModel.Events.HeapStatsUpdate, samples); | 114 this.dispatchEventToListeners(SDK.HeapProfilerModel.Events.HeapStatsUpdate, samples); |
| 116 } | 115 } |
| 117 | 116 |
| 118 /** | 117 /** |
| 119 * @param {number} lastSeenObjectId | 118 * @param {number} lastSeenObjectId |
| 120 * @param {number} timestamp | 119 * @param {number} timestamp |
| 121 */ | 120 */ |
| 122 lastSeenObjectId(lastSeenObjectId, timestamp) { | 121 lastSeenObjectId(lastSeenObjectId, timestamp) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 this._heapProfilerModel.reportHeapSnapshotProgress(done, total, finished); | 200 this._heapProfilerModel.reportHeapSnapshotProgress(done, total, finished); |
| 202 } | 201 } |
| 203 | 202 |
| 204 /** | 203 /** |
| 205 * @override | 204 * @override |
| 206 */ | 205 */ |
| 207 resetProfiles() { | 206 resetProfiles() { |
| 208 this._heapProfilerModel.resetProfiles(); | 207 this._heapProfilerModel.resetProfiles(); |
| 209 } | 208 } |
| 210 }; | 209 }; |
| OLD | NEW |