Skip to content

Commit

Permalink
Heap profile usability enhancement. Making it easier to navigate thro…
Browse files Browse the repository at this point in the history
…ugh multiple heap profiles.

BUG (rather feature)= 736776

Review-Url: https://codereview.chromium.org/2954973002
Cr-Commit-Position: refs/heads/master@{#485798}
  • Loading branch information
DianaSuvorova authored and Commit Bot committed Jul 12, 2017
1 parent b508c72 commit 8130390
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 18 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ Deepak Singla <deepak.s@samsung.com>
Deokjin Kim <deokjin81.kim@samsung.com>
Derek Halman <d.halman@gmail.com>
Devlin Cronin <rdevlin.cronin@gmail.com>
Diana Suvorova <diana.suvorova@gmail.com>
Diego Ferreiro Val <elfogris@gmail.com>
Dillon Sellars <dill.sellars@gmail.com>
Divya Bansal <divya.bansal@samsung.com>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ Profiler.HeapSnapshotView = class extends UI.SimpleView {

this._populate();
this._searchThrottler = new Common.Throttler(0);

for (var existingProfile of this._profiles())
existingProfile.addEventListener(Profiler.ProfileHeader.Events.ProfileTitleChanged, this._updateControls, this);
}

/**
Expand Down Expand Up @@ -607,33 +610,33 @@ Profiler.HeapSnapshotView = class extends UI.SimpleView {

_updateBaseOptions() {
var list = this._profiles();
// We're assuming that snapshots can only be added.
if (this._baseSelect.size() === list.length)
return;
var selectedIndex = this._baseSelect.selectedIndex();

for (var i = this._baseSelect.size(), n = list.length; i < n; ++i) {
var title = list[i].title;
this._baseSelect.createOption(title);
}
this._baseSelect.removeOptions();
for (var item of list)
this._baseSelect.createOption(item.title);

if (selectedIndex > -1)
this._baseSelect.setSelectedIndex(selectedIndex);
}

_updateFilterOptions() {
var list = this._profiles();
// We're assuming that snapshots can only be added.
if (this._filterSelect.size() - 1 === list.length)
return;
var selectedIndex = this._filterSelect.selectedIndex();

if (!this._filterSelect.size())
this._filterSelect.createOption(Common.UIString('All objects'));

for (var i = this._filterSelect.size() - 1, n = list.length; i < n; ++i) {
var title = list[i].title;
this._filterSelect.removeOptions();
this._filterSelect.createOption(Common.UIString('All objects'));
for (var i = 0; i < list.length; ++i) {
var title;
if (!i)
title = Common.UIString('Objects allocated before %s', title);
title = Common.UIString('Objects allocated before %s', list[i].title);
else
title = Common.UIString('Objects allocated between %s and %s', list[i - 1].title, title);
title = Common.UIString('Objects allocated between %s and %s', list[i - 1].title, list[i].title);
this._filterSelect.createOption(title);
}

if (selectedIndex > -1)
this._filterSelect.setSelectedIndex(selectedIndex);
}

_updateControls() {
Expand All @@ -647,13 +650,17 @@ Profiler.HeapSnapshotView = class extends UI.SimpleView {
*/
_onReceiveSnapshot(event) {
this._updateControls();
var profile = event.data;
profile.addEventListener(Profiler.ProfileHeader.Events.ProfileTitleChanged, this._updateControls, this);
}

/**
* @param {!Common.Event} event
*/
_onProfileHeaderRemoved(event) {
var profile = event.data;
profile.removeEventListener(Profiler.ProfileHeader.Events.ProfileTitleChanged, this._updateControls, this);

if (this._profile === profile) {
this.detach();
this._profile.profileType().removeEventListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ Profiler.ProfileHeader = class extends Common.Object {
this._fromFile = false;
}

/**
* @param {string} title
*/
setTitle(title) {
this.title = title;
this.dispatchEventToListeners(Profiler.ProfileHeader.Events.ProfileTitleChanged, this);
}

/**
* @return {!Profiler.ProfileType}
*/
Expand Down Expand Up @@ -108,5 +116,6 @@ Profiler.ProfileHeader.StatusUpdate = class {
/** @enum {symbol} */
Profiler.ProfileHeader.Events = {
UpdateStatus: Symbol('UpdateStatus'),
ProfileReceived: Symbol('ProfileReceived')
ProfileReceived: Symbol('ProfileReceived'),
ProfileTitleChanged: Symbol('ProfileTitleChanged')
};
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,41 @@ Profiler.ProfileSidebarTreeElement = class extends UI.TreeElement {
this.listItemElement.classList.toggle('wait', statusUpdate.wait);
}

/**
* @override
* @param {!Event} event
* @return {boolean}
*/
ondblclick(event) {
if (!this._editing)
this._startEditing(/** @type {!Element} */ (event.target));
return false;
}

/**
* @param {!Element} eventTarget
*/
_startEditing(eventTarget) {
var container = eventTarget.enclosingNodeOrSelfWithClass('title');
if (!container)
return;
var config = new UI.InplaceEditor.Config(this._editingCommitted.bind(this), this._editingCancelled.bind(this));
this._editing = UI.InplaceEditor.startEditing(container, config);
}

/**
* @param {!Element} container
* @param {string} newTitle
*/
_editingCommitted(container, newTitle) {
delete this._editing;
this.profile.setTitle(newTitle);
}

_editingCancelled() {
delete this._editing;
}

dispose() {
this.profile.removeEventListener(Profiler.ProfileHeader.Events.UpdateStatus, this._updateStatus, this);
this.profile.removeEventListener(Profiler.ProfileHeader.Events.ProfileReceived, this._onProfileReceived, this);
Expand Down

0 comments on commit 8130390

Please sign in to comment.