Commit 8e1b46d2 authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

DevTools: Move memory panel isolate selector out of experiment.

BUG=823874

Change-Id: Ib433aaf4bd56eef002861c0ea1a77f442283b5b6
Reviewed-on: https://chromium-review.googlesource.com/985248
Commit-Queue: Alexei Filippov <alph@chromium.org>
Reviewed-by: default avatarPavel Feldman <pfeldman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547358}
parent 24a7b027
......@@ -7,13 +7,15 @@
await TestRunner.loadModule('cpu_profiler_test_runner');
await TestRunner.showPanel('js_profiler');
CPUProfilerTestRunner.runProfilerTestSuite([function testProfiling(next) {
CPUProfilerTestRunner.runProfilerTestSuite([async function testProfiling(next) {
var cpuProfiler = TestRunner.cpuProfilerModel;
var targetManager = SDK.targetManager;
targetManager.addEventListener(SDK.TargetManager.Events.SuspendStateChanged, onSuspendStateChanged);
var profilesPanel = UI.panels.js_profiler;
TestRunner.addSniffer(cpuProfiler, 'stopRecording', stopRecording);
TestRunner.addSniffer(profilesPanel, '_addProfileHeader', onAddProfileHeader);
if (!UI.context.flavor(SDK.CPUProfilerModel))
await new Promise(resolve => UI.context.addFlavorChangeListener(SDK.CPUProfilerModel, resolve));
profilesPanel.toggleRecord(); // Start profiling.
function onAddProfileHeader() {
......
......@@ -9,7 +9,7 @@
HeapProfilerTestRunner.runHeapSnapshotTestSuite([async function testProfiling(next) {
HeapProfilerTestRunner.startSamplingHeapProfiler();
await HeapProfilerTestRunner.startSamplingHeapProfiler();
await TestRunner.evaluateInPagePromise(`
function pageFunction() {
(function () {
......
......@@ -11,7 +11,7 @@
var sourceStringified = JSON.stringify(source);
var partSize = sourceStringified.length >> 3;
function injectMockProfile(callback) {
async function injectMockProfile(callback) {
var dispatcher = TestRunner.mainTarget._dispatchers['HeapProfiler']._dispatchers[0];
var panel = UI.panels.heap_profiler;
panel._reset();
......@@ -33,6 +33,8 @@
callback(this);
}
TestRunner.addSniffer(Profiler.HeapProfileHeader.prototype, '_didWriteToTempFile', tempFileReady);
if (!UI.context.flavor(SDK.HeapProfilerModel))
await new Promise(resolve => UI.context.addFlavorChangeListener(SDK.HeapProfilerModel, resolve));
profileType._takeHeapSnapshot();
}
......
......@@ -509,7 +509,6 @@ all_devtools_files = [
"front_end/profiler/profilesSidebarTree.css",
"front_end/profiler/ProfileTypeRegistry.js",
"front_end/profiler/ProfileView.js",
"front_end/profiler/TargetsComboBoxController.js",
"front_end/profiler/TopDownProfileDataGrid.js",
"front_end/protocol/InspectorBackend.js",
"front_end/protocol/module.json",
......
......@@ -593,7 +593,7 @@ HeapProfilerTestRunner.switchToView = function(title, callback) {
HeapProfilerTestRunner._currentGrid().scrollContainer.style.height = '10000px';
};
HeapProfilerTestRunner.takeAndOpenSnapshot = function(generator, callback) {
HeapProfilerTestRunner.takeAndOpenSnapshot = async function(generator, callback) {
callback = TestRunner.safeWrap(callback);
const snapshot = generator();
const profileType = Profiler.ProfileTypeRegistry.instance.heapSnapshotProfileType;
......@@ -601,19 +601,17 @@ HeapProfilerTestRunner.takeAndOpenSnapshot = function(generator, callback) {
function pushGeneratedSnapshot(reportProgress) {
if (reportProgress) {
profileType._reportHeapSnapshotProgress({data: {done: 50, total: 100, finished: false}});
profileType._reportHeapSnapshotProgress({data: {done: 100, total: 100, finished: true}});
}
snapshot.snapshot.typeId = 'HEAP';
profileType._addHeapSnapshotChunk({data: JSON.stringify(snapshot)});
return Promise.resolve();
}
TestRunner.override(TestRunner.HeapProfilerAgent, 'takeHeapSnapshot', pushGeneratedSnapshot);
HeapProfilerTestRunner._takeAndOpenSnapshotCallback = callback;
TestRunner.override(TestRunner.HeapProfilerAgent, 'takeHeapSnapshot', pushGeneratedSnapshot);
if (!UI.context.flavor(SDK.HeapProfilerModel))
await new Promise(resolve => UI.context.addFlavorChangeListener(SDK.HeapProfilerModel, resolve));
profileType._takeHeapSnapshot();
};
......@@ -675,7 +673,9 @@ HeapProfilerTestRunner._profileViewRefresh = function() {
}
};
HeapProfilerTestRunner.startSamplingHeapProfiler = function() {
HeapProfilerTestRunner.startSamplingHeapProfiler = async function() {
if (!UI.context.flavor(SDK.HeapProfilerModel))
await new Promise(resolve => UI.context.addFlavorChangeListener(SDK.HeapProfilerModel, resolve));
Profiler.SamplingHeapProfileType.instance.startRecordingProfile();
};
......
......@@ -110,7 +110,6 @@ Main.Main = class {
Runtime.experiments.register('colorContrastRatio', 'Color contrast ratio line in color picker', true);
Runtime.experiments.register('emptySourceMapAutoStepping', 'Empty sourcemap auto-stepping');
Runtime.experiments.register('inputEventsOnTimelineOverview', 'Input events on Timeline overview', true);
Runtime.experiments.register('memoryLauncherViewV2', 'Memory profile launcher view V2');
Runtime.experiments.register('nativeHeapProfiler', 'Native memory sampling heap profiler', true);
Runtime.experiments.register('networkSearch', 'Network search');
Runtime.experiments.register('oopifInlineDOM', 'OOPIF: inline DOM ', true);
......
......@@ -43,16 +43,9 @@ Profiler.ProfileLauncherView = class extends UI.VBox {
this._contentElement = this.element.createChild('div', 'profile-launcher-view-content');
this._innerContentElement = this._contentElement.createChild('div');
const controlDiv = this._contentElement.createChild('div', 'hbox profile-launcher-control');
if (Runtime.experiments.isEnabled('memoryLauncherViewV2')) {
controlDiv.createChild('h1').textContent = ls`Select JavaScript VM instance`;
const targetDiv = controlDiv.createChild('div', 'hbox profile-launcher-target-list');
new Profiler.IsolateSelector().show(targetDiv);
} else {
const targetDiv = controlDiv.createChild('div', 'hbox profile-launcher-target');
targetDiv.createChild('div').textContent = ls`Target:`;
const targetsSelect = targetDiv.createChild('select', 'chrome-select');
new Profiler.TargetsComboBoxController(targetsSelect, targetDiv);
}
controlDiv.createChild('h1').textContent = ls`Select JavaScript VM instance`;
const targetDiv = controlDiv.createChild('div', 'hbox profile-launcher-target-list');
new Profiler.IsolateSelector().show(targetDiv);
this._controlButton =
UI.createTextButton('', this._controlButtonClicked.bind(this), 'profile-launcher-button', true /* primary */);
this._contentElement.appendChild(this._controlButton);
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @implements {SDK.TargetManager.Observer}
* @unrestricted
*/
Profiler.TargetsComboBoxController = class {
/**
* @param {!Element} selectElement
* @param {!Element} elementToHide
*/
constructor(selectElement, elementToHide) {
elementToHide.classList.add('hidden');
selectElement.addEventListener('change', this._onComboBoxSelectionChange.bind(this), false);
this._selectElement = selectElement;
this._elementToHide = elementToHide;
/** @type {!Map.<!SDK.Target, !Element>} */
this._targetToOption = new Map();
UI.context.addFlavorChangeListener(SDK.Target, this._targetChangedExternally, this);
SDK.targetManager.addEventListener(SDK.TargetManager.Events.NameChanged, this._targetNameChanged, this);
SDK.targetManager.observeTargets(this, SDK.Target.Capability.JS);
}
/**
* @override
* @param {!SDK.Target} target
*/
targetAdded(target) {
const option = this._selectElement.createChild('option');
option.text = target.name();
option.__target = target;
this._targetToOption.set(target, option);
if (UI.context.flavor(SDK.Target) === target) {
this._selectElement.selectedIndex = Array.prototype.indexOf.call(/** @type {?} */ (this._selectElement), option);
UI.context.setFlavor(SDK.HeapProfilerModel, target.model(SDK.HeapProfilerModel));
UI.context.setFlavor(SDK.CPUProfilerModel, target.model(SDK.CPUProfilerModel));
}
this._updateVisibility();
}
/**
* @override
* @param {!SDK.Target} target
*/
targetRemoved(target) {
const option = this._targetToOption.remove(target);
this._selectElement.removeChild(option);
this._updateVisibility();
}
/**
* @param {!Common.Event} event
*/
_targetNameChanged(event) {
const target = /** @type {!SDK.Target} */ (event.data);
const option = this._targetToOption.get(target);
option.text = target.name();
}
_onComboBoxSelectionChange() {
const selectedOption = this._selectElement[this._selectElement.selectedIndex];
if (!selectedOption)
return;
UI.context.setFlavor(SDK.Target, selectedOption.__target);
UI.context.setFlavor(SDK.HeapProfilerModel, selectedOption.__target.model(SDK.HeapProfilerModel));
UI.context.setFlavor(SDK.CPUProfilerModel, selectedOption.__target.model(SDK.CPUProfilerModel));
}
_updateVisibility() {
const hidden = this._selectElement.childElementCount === 1;
this._elementToHide.classList.toggle('hidden', hidden);
}
/**
* @param {!Common.Event} event
*/
_targetChangedExternally(event) {
const target = /** @type {?SDK.Target} */ (event.data);
if (!target)
return;
const option = this._targetToOption.get(target);
if (!option)
return;
this._select(option);
UI.context.setFlavor(SDK.HeapProfilerModel, target.model(SDK.HeapProfilerModel));
UI.context.setFlavor(SDK.CPUProfilerModel, target.model(SDK.CPUProfilerModel));
}
/**
* @param {!Element} option
*/
_select(option) {
this._selectElement.selectedIndex = Array.prototype.indexOf.call(/** @type {?} */ (this._selectElement), option);
}
};
......@@ -99,8 +99,7 @@
"HeapProfilerPanel.js",
"IsolateSelector.js",
"ProfileLauncherView.js",
"ProfileTypeRegistry.js",
"TargetsComboBoxController.js"
"ProfileTypeRegistry.js"
],
"resources": [
"heapProfiler.css",
......
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