Commit 2db959f2 authored by alph's avatar alph Committed by Commit bot

DevTools: Fix profiler private field accesses.

Review-Url: https://codereview.chromium.org/2566983004
Cr-Commit-Position: refs/heads/master@{#437966}
parent 2a395c27
......@@ -175,6 +175,7 @@ Profiler.BottomUpProfileDataGridTree = class extends Profiler.ProfileDataGridTre
*/
constructor(formatter, searchableView, rootProfileNode, total) {
super(formatter, searchableView, total);
this.deepSearch = false;
// Iterate each node in pre-order.
var profileNodeUIDs = 0;
......@@ -289,28 +290,6 @@ Profiler.BottomUpProfileDataGridTree = class extends Profiler.ProfileDataGridTre
this.sort(this.lastComparator, true);
}
/**
* @override
* @param {!UI.SearchableView.SearchConfig} searchConfig
* @param {boolean} shouldJump
* @param {boolean=} jumpBackwards
*/
performSearch(searchConfig, shouldJump, jumpBackwards) {
this.searchCanceled();
var matchesQuery = this._matchFunction(searchConfig);
if (!matchesQuery)
return;
this._searchResults = [];
for (var current = this.children[0]; current; current = current.traverseNextNode(true, null, true)) {
if (matchesQuery(current))
this._searchResults.push({profileNode: current});
}
this._searchResultIndex = jumpBackwards ? 0 : this._searchResults.length - 1;
this._searchableView.updateSearchMatchesCount(this._searchResults.length);
this._searchableView.updateCurrentMatchIndex(this._searchResultIndex);
}
/**
* @override
*/
......
......@@ -33,12 +33,8 @@
* @unrestricted
*/
Profiler.ProfileFlameChartDataProvider = class {
/**
* @param {?SDK.Target} target
*/
constructor(target) {
constructor() {
UI.FlameChartDataProvider.call(this);
this._target = target;
this._colorGenerator = Profiler.ProfileFlameChartDataProvider.colorGenerator();
}
......
......@@ -190,7 +190,7 @@ Profiler.CPUProfileType = class extends Profiler.ProfileType {
startRecordingProfile() {
var target = UI.context.flavor(SDK.Target);
if (this._profileBeingRecorded || !target)
if (this.profileBeingRecorded() || !target)
return;
var profile = new Profiler.CPUProfileHeader(target, this);
this.setProfileBeingRecorded(profile);
......@@ -203,7 +203,7 @@ Profiler.CPUProfileType = class extends Profiler.ProfileType {
stopRecordingProfile() {
this._recording = false;
if (!this._profileBeingRecorded || !this._profileBeingRecorded.target())
if (!this.profileBeingRecorded() || !this.profileBeingRecorded().target())
return;
var recordedProfile;
......@@ -213,12 +213,12 @@ Profiler.CPUProfileType = class extends Profiler.ProfileType {
* @this {Profiler.CPUProfileType}
*/
function didStopProfiling(profile) {
if (!this._profileBeingRecorded)
if (!this.profileBeingRecorded())
return;
console.assert(profile);
this._profileBeingRecorded.setProtocolProfile(profile);
this._profileBeingRecorded.updateStatus('');
recordedProfile = this._profileBeingRecorded;
this.profileBeingRecorded().setProtocolProfile(profile);
this.profileBeingRecorded().updateStatus('');
recordedProfile = this.profileBeingRecorded();
this.setProfileBeingRecorded(null);
}
......@@ -229,7 +229,7 @@ Profiler.CPUProfileType = class extends Profiler.ProfileType {
this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete, recordedProfile);
}
this._profileBeingRecorded.target()
this.profileBeingRecorded().target()
.cpuProfilerModel.stopRecording()
.then(didStopProfiling.bind(this))
.then(SDK.targetManager.resumeAllTargets.bind(SDK.targetManager))
......@@ -332,8 +332,9 @@ Profiler.CPUFlameChartDataProvider = class extends Profiler.ProfileFlameChartDat
* @param {?SDK.Target} target
*/
constructor(cpuProfile, target) {
super(target);
super();
this._cpuProfile = cpuProfile;
this._target = target;
}
/**
......
......@@ -97,7 +97,7 @@ Profiler.SamplingHeapProfileType = class extends Profiler.ProfileType {
startRecordingProfile() {
var target = UI.context.flavor(SDK.Target);
if (this._profileBeingRecorded || !target)
if (this.profileBeingRecorded() || !target)
return;
var profile = new Profiler.SamplingHeapProfileHeader(target, this);
this.setProfileBeingRecorded(profile);
......@@ -110,7 +110,7 @@ Profiler.SamplingHeapProfileType = class extends Profiler.ProfileType {
stopRecordingProfile() {
this._recording = false;
if (!this._profileBeingRecorded || !this._profileBeingRecorded.target())
if (!this.profileBeingRecorded() || !this.profileBeingRecorded().target())
return;
var recordedProfile;
......@@ -120,12 +120,12 @@ Profiler.SamplingHeapProfileType = class extends Profiler.ProfileType {
* @this {Profiler.SamplingHeapProfileType}
*/
function didStopProfiling(profile) {
if (!this._profileBeingRecorded)
if (!this.profileBeingRecorded())
return;
console.assert(profile);
this._profileBeingRecorded.setProtocolProfile(profile);
this._profileBeingRecorded.updateStatus('');
recordedProfile = this._profileBeingRecorded;
this.profileBeingRecorded().setProtocolProfile(profile);
this.profileBeingRecorded().updateStatus('');
recordedProfile = this.profileBeingRecorded();
this.setProfileBeingRecorded(null);
}
......@@ -136,7 +136,7 @@ Profiler.SamplingHeapProfileType = class extends Profiler.ProfileType {
this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete, recordedProfile);
}
this._profileBeingRecorded.target()
this.profileBeingRecorded().target()
.heapProfilerModel.stopSampling()
.then(didStopProfiling.bind(this))
.then(SDK.targetManager.resumeAllTargets.bind(SDK.targetManager))
......@@ -294,8 +294,9 @@ Profiler.HeapFlameChartDataProvider = class extends Profiler.ProfileFlameChartDa
* @param {?SDK.Target} target
*/
constructor(profile, target) {
super(target);
super();
this._profile = profile;
this._target = target;
}
/**
......
......@@ -1036,7 +1036,7 @@ Profiler.HeapSnapshotProfileType = class extends Profiler.ProfileType {
* @this {Profiler.HeapSnapshotProfileType}
*/
function didTakeHeapSnapshot(error) {
var profile = this._profileBeingRecorded;
var profile = this.profileBeingRecorded();
profile.title = Common.UIString('Snapshot %d', profile.uid);
profile._finishLoad();
this.setProfileBeingRecorded(null);
......@@ -1070,11 +1070,11 @@ Profiler.HeapSnapshotProfileType = class extends Profiler.ProfileType {
}
_resetProfiles() {
this._reset();
this.reset();
}
_snapshotReceived(profile) {
if (this._profileBeingRecorded === profile)
if (this.profileBeingRecorded() === profile)
this.setProfileBeingRecorded(null);
this.dispatchEventToListeners(Profiler.HeapSnapshotProfileType.SnapshotReceived, profile);
}
......@@ -1150,7 +1150,7 @@ Profiler.TrackingHeapSnapshotProfileType = class extends Profiler.HeapSnapshotPr
if (profileSamples.totalTime < data.timestamp - profileSamples.timestamps[0])
profileSamples.totalTime *= 2;
this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.HeapStatsUpdate, this._profileSamples);
this._profileBeingRecorded.updateStatus(null, true);
this.profileBeingRecorded().updateStatus(null, true);
}
/**
......@@ -1194,15 +1194,15 @@ Profiler.TrackingHeapSnapshotProfileType = class extends Profiler.HeapSnapshotPr
var target = UI.context.flavor(SDK.Target);
this.setProfileBeingRecorded(new Profiler.HeapProfileHeader(target, this, undefined));
this._profileSamples = new Profiler.TrackingHeapSnapshotProfileType.Samples();
this._profileBeingRecorded._profileSamples = this._profileSamples;
this.profileBeingRecorded()._profileSamples = this._profileSamples;
this._recording = true;
this.addProfile(this._profileBeingRecorded);
this._profileBeingRecorded.updateStatus(Common.UIString('Recording\u2026'));
this.addProfile(/** @type {!Profiler.ProfileHeader} */ (this.profileBeingRecorded()));
this.profileBeingRecorded().updateStatus(Common.UIString('Recording\u2026'));
this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.TrackingStarted);
}
_stopRecordingProfile() {
this._profileBeingRecorded.updateStatus(Common.UIString('Snapshotting\u2026'));
this.profileBeingRecorded().updateStatus(Common.UIString('Snapshotting\u2026'));
/**
* @param {?string} error
* @this {Profiler.HeapSnapshotProfileType}
......@@ -1217,7 +1217,7 @@ Profiler.TrackingHeapSnapshotProfileType = class extends Profiler.HeapSnapshotPr
this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete, profile);
}
this._profileBeingRecorded.target().heapProfilerAgent().stopTrackingHeapObjects(
this.profileBeingRecorded().target().heapProfilerAgent().stopTrackingHeapObjects(
true, didTakeHeapSnapshot.bind(this));
this._recording = false;
this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.TrackingStopped);
......@@ -1453,7 +1453,7 @@ Profiler.HeapProfileHeader = class extends Profiler.ProfileHeader {
notifySnapshotReceived() {
this._fulfillLoad(this._snapshotProxy);
this._profileType._snapshotReceived(this);
this.profileType()._snapshotReceived(this);
if (this.canSaveToFile())
this.dispatchEventToListeners(Profiler.ProfileHeader.Events.ProfileReceived);
}
......@@ -1494,7 +1494,7 @@ Profiler.HeapProfileHeader = class extends Profiler.ProfileHeader {
this._updateSaveProgress(0, 1);
}
}
this._fileName = this._fileName || 'Heap-' + new Date().toISO8601Compact() + this._profileType.fileExtension();
this._fileName = this._fileName || 'Heap-' + new Date().toISO8601Compact() + this.profileType().fileExtension();
fileOutputStream.open(this._fileName, onOpen.bind(this));
}
......
......@@ -332,6 +332,7 @@ Profiler.ProfileDataGridTree = class {
this.total = total;
this.lastComparator = null;
this.childrenByCallUID = new Map();
this.deepSearch = true;
}
/**
......@@ -547,7 +548,8 @@ Profiler.ProfileDataGridTree = class {
return;
this._searchResults = [];
for (var current = this.children[0]; current; current = current.traverseNextNode(false, null, false)) {
const deepSearch = this.deepSearch;
for (var current = this.children[0]; current; current = current.traverseNextNode(!deepSearch, null, !deepSearch)) {
if (matchesQuery(current))
this._searchResults.push({profileNode: current});
}
......
......@@ -419,8 +419,8 @@ Profiler.WritableProfileHeader = class extends Profiler.ProfileHeader {
this._jsonifiedProfile = null;
this.updateStatus(Common.UIString('Loaded'), false);
if (this._profileType.profileBeingRecorded() === this)
this._profileType.setProfileBeingRecorded(null);
if (this.profileType().profileBeingRecorded() === this)
this.profileType().setProfileBeingRecorded(null);
}
/**
......@@ -512,7 +512,7 @@ Profiler.WritableProfileHeader = class extends Profiler.ProfileHeader {
}
}
this._fileName = this._fileName ||
`${this._profileType.typeName()}-${new Date().toISO8601Compact()}${this._profileType.fileExtension()}`;
`${this.profileType().typeName()}-${new Date().toISO8601Compact()}${this.profileType().fileExtension()}`;
fileOutputStream.open(this._fileName, onOpenForSave.bind(this));
}
......
......@@ -220,12 +220,9 @@ Profiler.ProfileType = class extends Common.Object {
profileBeingRecordedRemoved() {
}
_reset() {
var profiles = this._profiles.slice(0);
for (var i = 0; i < profiles.length; ++i)
this._disposeProfile(profiles[i]);
reset() {
this._profiles.slice(0).forEach(this._disposeProfile.bind(this));
this._profiles = [];
this._nextProfileUid = 1;
}
......@@ -598,9 +595,7 @@ Profiler.ProfilesPanel = class extends UI.PanelWithSidebar {
}
_reset() {
var types = Profiler.ProfileTypeRegistry.instance.profileTypes();
for (var i = 0; i < types.length; i++)
types[i]._reset();
Profiler.ProfileTypeRegistry.instance.profileTypes().forEach(type => type.reset());
delete this.visibleView;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment