[globals] self.SDK.isolateManager

R=aerotwist@chromium.org

Bug: 1058320
Change-Id: Id455a3c9e5c9a9f220f7a933279196dc5e66f2cb
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2391250
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
This commit is contained in:
Tim van der Lippe
2020-09-08 13:04:19 +00:00
committed by Commit Bot
parent b2541af131
commit d5de9a0d88
4 changed files with 24 additions and 12 deletions
+7 -5
View File
@@ -39,7 +39,7 @@ export class IsolateSelector extends UI.Widget.VBox {
this._totalTrendDiv.title = ls`Total page JS heap size change trend over the last ${trendIntervalMinutes} minutes.`;
this._totalValueDiv.title = ls`Total page JS heap size across all VM instances.`;
self.SDK.isolateManager.observeIsolates(this);
SDK.IsolateManager.IsolateManager.instance().observeIsolates(this);
SDK.SDKModel.TargetManager.instance().addEventListener(SDK.SDKModel.Events.NameChanged, this._targetChanged, this);
SDK.SDKModel.TargetManager.instance().addEventListener(
SDK.SDKModel.Events.InspectedURLChanged, this._targetChanged, this);
@@ -49,14 +49,16 @@ export class IsolateSelector extends UI.Widget.VBox {
* @override
*/
wasShown() {
self.SDK.isolateManager.addEventListener(SDK.IsolateManager.Events.MemoryChanged, this._heapStatsChanged, this);
SDK.IsolateManager.IsolateManager.instance().addEventListener(
SDK.IsolateManager.Events.MemoryChanged, this._heapStatsChanged, this);
}
/**
* @override
*/
willHide() {
self.SDK.isolateManager.removeEventListener(SDK.IsolateManager.Events.MemoryChanged, this._heapStatsChanged, this);
SDK.IsolateManager.IsolateManager.instance().removeEventListener(
SDK.IsolateManager.Events.MemoryChanged, this._heapStatsChanged, this);
}
/**
@@ -108,7 +110,7 @@ export class IsolateSelector extends UI.Widget.VBox {
if (!model) {
return;
}
const isolate = self.SDK.isolateManager.isolateByModel(model);
const isolate = SDK.IsolateManager.IsolateManager.instance().isolateByModel(model);
const item = isolate && this._itemByIsolate.get(isolate);
if (item) {
item.updateTitle();
@@ -130,7 +132,7 @@ export class IsolateSelector extends UI.Widget.VBox {
_updateTotal() {
let total = 0;
let trend = 0;
for (const isolate of self.SDK.isolateManager.isolates()) {
for (const isolate of SDK.IsolateManager.IsolateManager.instance().isolates()) {
total += isolate.usedHeapSize();
trend += isolate.usedHeapSizeGrowRate();
}
+1 -1
View File
@@ -114,7 +114,7 @@ export class LiveHeapProfileView extends UI.Widget.VBox {
async _poll() {
const pollId = this._currentPollId;
do {
const isolates = Array.from(self.SDK.isolateManager.isolates());
const isolates = Array.from(SDK.IsolateManager.IsolateManager.instance().isolates());
const profiles = await Promise.all(
isolates.map(isolate => isolate.heapProfilerModel() && isolate.heapProfilerModel().getSamplingProfile()));
if (this._currentPollId !== pollId) {
+15 -5
View File
@@ -8,15 +8,15 @@ import {HeapProfilerModel} from './HeapProfilerModel.js'; // eslint-disable-lin
import {RuntimeModel} from './RuntimeModel.js';
import {SDKModelObserver, TargetManager} from './SDKModel.js'; // eslint-disable-line no-unused-vars
/** @type {!IsolateManager} */
let isolateManagerInstance;
/**
* @implements {SDKModelObserver<!RuntimeModel>}
*/
export class IsolateManager extends Common.ObjectWrapper.ObjectWrapper {
constructor() {
super();
// @ts-ignore
// TODO(crbug.com/1058320): Replace self.SDK.isolateManager global.
console.assert(!self.SDK.isolateManager, 'Use self.SDK.isolateManager singleton.');
/** @type {!Map<string, !Isolate>} */
this._isolates = new Map();
// _isolateIdByModel contains null while the isolateId is being retrieved.
@@ -28,6 +28,17 @@ export class IsolateManager extends Common.ObjectWrapper.ObjectWrapper {
this._pollId = 0;
}
/**
* @param {{forceNew: boolean}} opts
*/
static instance({forceNew} = {forceNew: false}) {
if (!isolateManagerInstance || forceNew) {
isolateManagerInstance = new IsolateManager();
}
return isolateManagerInstance;
}
/**
* @param {!Observer} observer
*/
@@ -225,8 +236,7 @@ export class Isolate {
}
this._usedHeapSize = usage.usedSize;
this._memoryTrend.add(this._usedHeapSize);
// @ts-ignore Replace with IsolateManager.instance.
self.SDK.isolateManager.dispatchEventToListeners(Events.MemoryChanged, this);
IsolateManager.instance().dispatchEventToListeners(Events.MemoryChanged, this);
}
/**
+1 -1
View File
@@ -251,5 +251,5 @@ SDK.TracingModel.DevToolsMetadataEventCategory = SDKModule.TracingModel.DevTools
SDK.TracingModel.Event = SDKModule.TracingModel.Event;
self.SDK.targetManager = SDKModule.SDKModel.TargetManager.instance();
self.SDK.isolateManager = new SDKModule.IsolateManager.IsolateManager();
self.SDK.isolateManager = SDKModule.IsolateManager.IsolateManager.instance({forceNew: true});
self.SDK.domModelUndoStack = SDKModule.DOMModel.DOMModelUndoStack.instance();