Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @implements {UI.ContextMenu.Provider} | |
| 7 * @implements {UI.ActionDelegate} | |
| 8 */ | |
| 9 Profiler.MemoryProfilerPanel = class extends Profiler.ProfilesPanel { | |
| 10 constructor() { | |
|
alph
2017/01/12 20:48:30
redundant
| |
| 11 super(); | |
| 12 } | |
| 13 | |
| 14 /** | |
| 15 * @override | |
| 16 * @param {!Event} event | |
| 17 * @param {!UI.ContextMenu} contextMenu | |
| 18 * @param {!Object} target | |
| 19 */ | |
| 20 appendApplicableItems(event, contextMenu, target) { | |
| 21 if (!(target instanceof SDK.RemoteObject)) | |
| 22 return; | |
| 23 | |
| 24 if (!this.isShowing()) | |
| 25 return; | |
| 26 | |
| 27 var object = /** @type {!SDK.RemoteObject} */ (target); | |
| 28 var objectId = object.objectId; | |
| 29 if (!objectId) | |
| 30 return; | |
| 31 | |
| 32 var heapProfiles = Profiler.ProfileTypeRegistry.instance.heapSnapshotProfile Type.getProfiles(); | |
| 33 if (!heapProfiles.length) | |
| 34 return; | |
| 35 | |
| 36 /** | |
| 37 * @this {Profiler.ProfilesPanel} | |
| 38 */ | |
| 39 function revealInView(viewName) { | |
| 40 object.target().heapProfilerAgent().getHeapObjectId(objectId, didReceiveHe apObjectId.bind(this, viewName)); | |
| 41 } | |
| 42 | |
| 43 /** | |
| 44 * @this {Profiler.ProfilesPanel} | |
| 45 */ | |
| 46 function didReceiveHeapObjectId(viewName, error, result) { | |
| 47 if (!this.isShowing()) | |
| 48 return; | |
| 49 if (!error) | |
| 50 this.showObject(result, viewName); | |
| 51 } | |
| 52 | |
| 53 contextMenu.appendItem(Common.UIString.capitalize('Reveal in Summary ^view') , revealInView.bind(this, 'Summary')); | |
| 54 } | |
| 55 | |
| 56 /** | |
| 57 * @override | |
| 58 * @param {!UI.Context} context | |
| 59 * @param {string} actionId | |
| 60 * @return {boolean} | |
| 61 */ | |
| 62 handleAction(context, actionId) { | |
| 63 var panel = UI.context.flavor(Profiler.MemoryProfilerPanel); | |
| 64 console.assert(panel && panel instanceof Profiler.MemoryProfilerPanel); | |
| 65 panel.toggleRecord(); | |
| 66 return true; | |
| 67 } | |
| 68 | |
| 69 /** | |
| 70 * @override | |
| 71 */ | |
| 72 wasShown() { | |
| 73 UI.context.setFlavor(Profiler.MemoryProfilerPanel, this); | |
| 74 } | |
| 75 | |
| 76 /** | |
| 77 * @override | |
| 78 */ | |
| 79 willHide() { | |
| 80 UI.context.setFlavor(Profiler.MemoryProfilerPanel, null); | |
| 81 } | |
| 82 }; | |
| OLD | NEW |