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 ...@@ -175,6 +175,7 @@ Profiler.BottomUpProfileDataGridTree = class extends Profiler.ProfileDataGridTre
*/ */
constructor(formatter, searchableView, rootProfileNode, total) { constructor(formatter, searchableView, rootProfileNode, total) {
super(formatter, searchableView, total); super(formatter, searchableView, total);
this.deepSearch = false;
// Iterate each node in pre-order. // Iterate each node in pre-order.
var profileNodeUIDs = 0; var profileNodeUIDs = 0;
...@@ -289,28 +290,6 @@ Profiler.BottomUpProfileDataGridTree = class extends Profiler.ProfileDataGridTre ...@@ -289,28 +290,6 @@ Profiler.BottomUpProfileDataGridTree = class extends Profiler.ProfileDataGridTre
this.sort(this.lastComparator, true); 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 * @override
*/ */
......
...@@ -33,12 +33,8 @@ ...@@ -33,12 +33,8 @@
* @unrestricted * @unrestricted
*/ */
Profiler.ProfileFlameChartDataProvider = class { Profiler.ProfileFlameChartDataProvider = class {
/** constructor() {
* @param {?SDK.Target} target
*/
constructor(target) {
UI.FlameChartDataProvider.call(this); UI.FlameChartDataProvider.call(this);
this._target = target;
this._colorGenerator = Profiler.ProfileFlameChartDataProvider.colorGenerator(); this._colorGenerator = Profiler.ProfileFlameChartDataProvider.colorGenerator();
} }
......
...@@ -190,7 +190,7 @@ Profiler.CPUProfileType = class extends Profiler.ProfileType { ...@@ -190,7 +190,7 @@ Profiler.CPUProfileType = class extends Profiler.ProfileType {
startRecordingProfile() { startRecordingProfile() {
var target = UI.context.flavor(SDK.Target); var target = UI.context.flavor(SDK.Target);
if (this._profileBeingRecorded || !target) if (this.profileBeingRecorded() || !target)
return; return;
var profile = new Profiler.CPUProfileHeader(target, this); var profile = new Profiler.CPUProfileHeader(target, this);
this.setProfileBeingRecorded(profile); this.setProfileBeingRecorded(profile);
...@@ -203,7 +203,7 @@ Profiler.CPUProfileType = class extends Profiler.ProfileType { ...@@ -203,7 +203,7 @@ Profiler.CPUProfileType = class extends Profiler.ProfileType {
stopRecordingProfile() { stopRecordingProfile() {
this._recording = false; this._recording = false;
if (!this._profileBeingRecorded || !this._profileBeingRecorded.target()) if (!this.profileBeingRecorded() || !this.profileBeingRecorded().target())
return; return;
var recordedProfile; var recordedProfile;
...@@ -213,12 +213,12 @@ Profiler.CPUProfileType = class extends Profiler.ProfileType { ...@@ -213,12 +213,12 @@ Profiler.CPUProfileType = class extends Profiler.ProfileType {
* @this {Profiler.CPUProfileType} * @this {Profiler.CPUProfileType}
*/ */
function didStopProfiling(profile) { function didStopProfiling(profile) {
if (!this._profileBeingRecorded) if (!this.profileBeingRecorded())
return; return;
console.assert(profile); console.assert(profile);
this._profileBeingRecorded.setProtocolProfile(profile); this.profileBeingRecorded().setProtocolProfile(profile);
this._profileBeingRecorded.updateStatus(''); this.profileBeingRecorded().updateStatus('');
recordedProfile = this._profileBeingRecorded; recordedProfile = this.profileBeingRecorded();
this.setProfileBeingRecorded(null); this.setProfileBeingRecorded(null);
} }
...@@ -229,7 +229,7 @@ Profiler.CPUProfileType = class extends Profiler.ProfileType { ...@@ -229,7 +229,7 @@ Profiler.CPUProfileType = class extends Profiler.ProfileType {
this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete, recordedProfile); this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete, recordedProfile);
} }
this._profileBeingRecorded.target() this.profileBeingRecorded().target()
.cpuProfilerModel.stopRecording() .cpuProfilerModel.stopRecording()
.then(didStopProfiling.bind(this)) .then(didStopProfiling.bind(this))
.then(SDK.targetManager.resumeAllTargets.bind(SDK.targetManager)) .then(SDK.targetManager.resumeAllTargets.bind(SDK.targetManager))
...@@ -332,8 +332,9 @@ Profiler.CPUFlameChartDataProvider = class extends Profiler.ProfileFlameChartDat ...@@ -332,8 +332,9 @@ Profiler.CPUFlameChartDataProvider = class extends Profiler.ProfileFlameChartDat
* @param {?SDK.Target} target * @param {?SDK.Target} target
*/ */
constructor(cpuProfile, target) { constructor(cpuProfile, target) {
super(target); super();
this._cpuProfile = cpuProfile; this._cpuProfile = cpuProfile;
this._target = target;
} }
/** /**
......
...@@ -97,7 +97,7 @@ Profiler.SamplingHeapProfileType = class extends Profiler.ProfileType { ...@@ -97,7 +97,7 @@ Profiler.SamplingHeapProfileType = class extends Profiler.ProfileType {
startRecordingProfile() { startRecordingProfile() {
var target = UI.context.flavor(SDK.Target); var target = UI.context.flavor(SDK.Target);
if (this._profileBeingRecorded || !target) if (this.profileBeingRecorded() || !target)
return; return;
var profile = new Profiler.SamplingHeapProfileHeader(target, this); var profile = new Profiler.SamplingHeapProfileHeader(target, this);
this.setProfileBeingRecorded(profile); this.setProfileBeingRecorded(profile);
...@@ -110,7 +110,7 @@ Profiler.SamplingHeapProfileType = class extends Profiler.ProfileType { ...@@ -110,7 +110,7 @@ Profiler.SamplingHeapProfileType = class extends Profiler.ProfileType {
stopRecordingProfile() { stopRecordingProfile() {
this._recording = false; this._recording = false;
if (!this._profileBeingRecorded || !this._profileBeingRecorded.target()) if (!this.profileBeingRecorded() || !this.profileBeingRecorded().target())
return; return;
var recordedProfile; var recordedProfile;
...@@ -120,12 +120,12 @@ Profiler.SamplingHeapProfileType = class extends Profiler.ProfileType { ...@@ -120,12 +120,12 @@ Profiler.SamplingHeapProfileType = class extends Profiler.ProfileType {
* @this {Profiler.SamplingHeapProfileType} * @this {Profiler.SamplingHeapProfileType}
*/ */
function didStopProfiling(profile) { function didStopProfiling(profile) {
if (!this._profileBeingRecorded) if (!this.profileBeingRecorded())
return; return;
console.assert(profile); console.assert(profile);
this._profileBeingRecorded.setProtocolProfile(profile); this.profileBeingRecorded().setProtocolProfile(profile);
this._profileBeingRecorded.updateStatus(''); this.profileBeingRecorded().updateStatus('');
recordedProfile = this._profileBeingRecorded; recordedProfile = this.profileBeingRecorded();
this.setProfileBeingRecorded(null); this.setProfileBeingRecorded(null);
} }
...@@ -136,7 +136,7 @@ Profiler.SamplingHeapProfileType = class extends Profiler.ProfileType { ...@@ -136,7 +136,7 @@ Profiler.SamplingHeapProfileType = class extends Profiler.ProfileType {
this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete, recordedProfile); this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete, recordedProfile);
} }
this._profileBeingRecorded.target() this.profileBeingRecorded().target()
.heapProfilerModel.stopSampling() .heapProfilerModel.stopSampling()
.then(didStopProfiling.bind(this)) .then(didStopProfiling.bind(this))
.then(SDK.targetManager.resumeAllTargets.bind(SDK.targetManager)) .then(SDK.targetManager.resumeAllTargets.bind(SDK.targetManager))
...@@ -294,8 +294,9 @@ Profiler.HeapFlameChartDataProvider = class extends Profiler.ProfileFlameChartDa ...@@ -294,8 +294,9 @@ Profiler.HeapFlameChartDataProvider = class extends Profiler.ProfileFlameChartDa
* @param {?SDK.Target} target * @param {?SDK.Target} target
*/ */
constructor(profile, target) { constructor(profile, target) {
super(target); super();
this._profile = profile; this._profile = profile;
this._target = target;
} }
/** /**
......
...@@ -1036,7 +1036,7 @@ Profiler.HeapSnapshotProfileType = class extends Profiler.ProfileType { ...@@ -1036,7 +1036,7 @@ Profiler.HeapSnapshotProfileType = class extends Profiler.ProfileType {
* @this {Profiler.HeapSnapshotProfileType} * @this {Profiler.HeapSnapshotProfileType}
*/ */
function didTakeHeapSnapshot(error) { function didTakeHeapSnapshot(error) {
var profile = this._profileBeingRecorded; var profile = this.profileBeingRecorded();
profile.title = Common.UIString('Snapshot %d', profile.uid); profile.title = Common.UIString('Snapshot %d', profile.uid);
profile._finishLoad(); profile._finishLoad();
this.setProfileBeingRecorded(null); this.setProfileBeingRecorded(null);
...@@ -1070,11 +1070,11 @@ Profiler.HeapSnapshotProfileType = class extends Profiler.ProfileType { ...@@ -1070,11 +1070,11 @@ Profiler.HeapSnapshotProfileType = class extends Profiler.ProfileType {
} }
_resetProfiles() { _resetProfiles() {
this._reset(); this.reset();
} }
_snapshotReceived(profile) { _snapshotReceived(profile) {
if (this._profileBeingRecorded === profile) if (this.profileBeingRecorded() === profile)
this.setProfileBeingRecorded(null); this.setProfileBeingRecorded(null);
this.dispatchEventToListeners(Profiler.HeapSnapshotProfileType.SnapshotReceived, profile); this.dispatchEventToListeners(Profiler.HeapSnapshotProfileType.SnapshotReceived, profile);
} }
...@@ -1150,7 +1150,7 @@ Profiler.TrackingHeapSnapshotProfileType = class extends Profiler.HeapSnapshotPr ...@@ -1150,7 +1150,7 @@ Profiler.TrackingHeapSnapshotProfileType = class extends Profiler.HeapSnapshotPr
if (profileSamples.totalTime < data.timestamp - profileSamples.timestamps[0]) if (profileSamples.totalTime < data.timestamp - profileSamples.timestamps[0])
profileSamples.totalTime *= 2; profileSamples.totalTime *= 2;
this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.HeapStatsUpdate, this._profileSamples); 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 ...@@ -1194,15 +1194,15 @@ Profiler.TrackingHeapSnapshotProfileType = class extends Profiler.HeapSnapshotPr
var target = UI.context.flavor(SDK.Target); var target = UI.context.flavor(SDK.Target);
this.setProfileBeingRecorded(new Profiler.HeapProfileHeader(target, this, undefined)); this.setProfileBeingRecorded(new Profiler.HeapProfileHeader(target, this, undefined));
this._profileSamples = new Profiler.TrackingHeapSnapshotProfileType.Samples(); this._profileSamples = new Profiler.TrackingHeapSnapshotProfileType.Samples();
this._profileBeingRecorded._profileSamples = this._profileSamples; this.profileBeingRecorded()._profileSamples = this._profileSamples;
this._recording = true; this._recording = true;
this.addProfile(this._profileBeingRecorded); this.addProfile(/** @type {!Profiler.ProfileHeader} */ (this.profileBeingRecorded()));
this._profileBeingRecorded.updateStatus(Common.UIString('Recording\u2026')); this.profileBeingRecorded().updateStatus(Common.UIString('Recording\u2026'));
this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.TrackingStarted); this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.TrackingStarted);
} }
_stopRecordingProfile() { _stopRecordingProfile() {
this._profileBeingRecorded.updateStatus(Common.UIString('Snapshotting\u2026')); this.profileBeingRecorded().updateStatus(Common.UIString('Snapshotting\u2026'));
/** /**
* @param {?string} error * @param {?string} error
* @this {Profiler.HeapSnapshotProfileType} * @this {Profiler.HeapSnapshotProfileType}
...@@ -1217,7 +1217,7 @@ Profiler.TrackingHeapSnapshotProfileType = class extends Profiler.HeapSnapshotPr ...@@ -1217,7 +1217,7 @@ Profiler.TrackingHeapSnapshotProfileType = class extends Profiler.HeapSnapshotPr
this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete, profile); this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete, profile);
} }
this._profileBeingRecorded.target().heapProfilerAgent().stopTrackingHeapObjects( this.profileBeingRecorded().target().heapProfilerAgent().stopTrackingHeapObjects(
true, didTakeHeapSnapshot.bind(this)); true, didTakeHeapSnapshot.bind(this));
this._recording = false; this._recording = false;
this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.TrackingStopped); this.dispatchEventToListeners(Profiler.TrackingHeapSnapshotProfileType.TrackingStopped);
...@@ -1453,7 +1453,7 @@ Profiler.HeapProfileHeader = class extends Profiler.ProfileHeader { ...@@ -1453,7 +1453,7 @@ Profiler.HeapProfileHeader = class extends Profiler.ProfileHeader {
notifySnapshotReceived() { notifySnapshotReceived() {
this._fulfillLoad(this._snapshotProxy); this._fulfillLoad(this._snapshotProxy);
this._profileType._snapshotReceived(this); this.profileType()._snapshotReceived(this);
if (this.canSaveToFile()) if (this.canSaveToFile())
this.dispatchEventToListeners(Profiler.ProfileHeader.Events.ProfileReceived); this.dispatchEventToListeners(Profiler.ProfileHeader.Events.ProfileReceived);
} }
...@@ -1494,7 +1494,7 @@ Profiler.HeapProfileHeader = class extends Profiler.ProfileHeader { ...@@ -1494,7 +1494,7 @@ Profiler.HeapProfileHeader = class extends Profiler.ProfileHeader {
this._updateSaveProgress(0, 1); 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)); fileOutputStream.open(this._fileName, onOpen.bind(this));
} }
......
...@@ -332,6 +332,7 @@ Profiler.ProfileDataGridTree = class { ...@@ -332,6 +332,7 @@ Profiler.ProfileDataGridTree = class {
this.total = total; this.total = total;
this.lastComparator = null; this.lastComparator = null;
this.childrenByCallUID = new Map(); this.childrenByCallUID = new Map();
this.deepSearch = true;
} }
/** /**
...@@ -547,7 +548,8 @@ Profiler.ProfileDataGridTree = class { ...@@ -547,7 +548,8 @@ Profiler.ProfileDataGridTree = class {
return; return;
this._searchResults = []; 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)) if (matchesQuery(current))
this._searchResults.push({profileNode: current}); this._searchResults.push({profileNode: current});
} }
......
...@@ -419,8 +419,8 @@ Profiler.WritableProfileHeader = class extends Profiler.ProfileHeader { ...@@ -419,8 +419,8 @@ Profiler.WritableProfileHeader = class extends Profiler.ProfileHeader {
this._jsonifiedProfile = null; this._jsonifiedProfile = null;
this.updateStatus(Common.UIString('Loaded'), false); this.updateStatus(Common.UIString('Loaded'), false);
if (this._profileType.profileBeingRecorded() === this) if (this.profileType().profileBeingRecorded() === this)
this._profileType.setProfileBeingRecorded(null); this.profileType().setProfileBeingRecorded(null);
} }
/** /**
...@@ -512,7 +512,7 @@ Profiler.WritableProfileHeader = class extends Profiler.ProfileHeader { ...@@ -512,7 +512,7 @@ Profiler.WritableProfileHeader = class extends Profiler.ProfileHeader {
} }
} }
this._fileName = this._fileName || 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)); fileOutputStream.open(this._fileName, onOpenForSave.bind(this));
} }
......
...@@ -220,12 +220,9 @@ Profiler.ProfileType = class extends Common.Object { ...@@ -220,12 +220,9 @@ Profiler.ProfileType = class extends Common.Object {
profileBeingRecordedRemoved() { profileBeingRecordedRemoved() {
} }
_reset() { reset() {
var profiles = this._profiles.slice(0); this._profiles.slice(0).forEach(this._disposeProfile.bind(this));
for (var i = 0; i < profiles.length; ++i)
this._disposeProfile(profiles[i]);
this._profiles = []; this._profiles = [];
this._nextProfileUid = 1; this._nextProfileUid = 1;
} }
...@@ -598,9 +595,7 @@ Profiler.ProfilesPanel = class extends UI.PanelWithSidebar { ...@@ -598,9 +595,7 @@ Profiler.ProfilesPanel = class extends UI.PanelWithSidebar {
} }
_reset() { _reset() {
var types = Profiler.ProfileTypeRegistry.instance.profileTypes(); Profiler.ProfileTypeRegistry.instance.profileTypes().forEach(type => type.reset());
for (var i = 0; i < types.length; i++)
types[i]._reset();
delete this.visibleView; 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