mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 236c33cffbe4 (bug 1037465) for xpcshell bustage
This commit is contained in:
parent
44ce7fb81d
commit
8868f0fec4
@ -2,67 +2,56 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const {Ci,Cu,Cc} = require("chrome");
|
||||
const {Ci,Cu} = require("chrome");
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const Services = require("Services");
|
||||
let {setTimeout,clearTimeout} = require("sdk/timers");
|
||||
let {setTimeout} = require("sdk/timers");
|
||||
|
||||
function MonitorActor(aConnection) {
|
||||
this.conn = aConnection;
|
||||
this._updates = [];
|
||||
this._started = false;
|
||||
}
|
||||
|
||||
MonitorActor.prototype = {
|
||||
actorPrefix: "monitor",
|
||||
|
||||
// Update agents (see USSAgent for an example).
|
||||
// Updates
|
||||
|
||||
_agents: [],
|
||||
_addAgent: function(agent) {
|
||||
if (this._started) {
|
||||
agent.start();
|
||||
}
|
||||
this._agents.push(agent);
|
||||
},
|
||||
|
||||
// Updates.
|
||||
|
||||
_sendUpdate: function() {
|
||||
if (this._started) {
|
||||
this.conn.sendActorEvent(this.actorID, "update", { data: this._updates });
|
||||
this._updates = [];
|
||||
_toSend: [],
|
||||
_timeout: null,
|
||||
_started: false,
|
||||
_scheduleUpdate: function() {
|
||||
if (this._started && !this._timeout) {
|
||||
this._timeout = setTimeout(() => {
|
||||
if (this._toSend.length > 0) {
|
||||
this.conn.sendActorEvent(this.actorID, "update", this._toSend);
|
||||
this._toSend = [];
|
||||
}
|
||||
this._timeout = null;
|
||||
}, 200);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// Methods available from the front
|
||||
|
||||
start: function() {
|
||||
if (!this._started) {
|
||||
this._started = true;
|
||||
Services.obs.addObserver(this, "devtools-monitor-update", false);
|
||||
Services.obs.notifyObservers(null, "devtools-monitor-start", "");
|
||||
this._agents.forEach(agent => agent.start());
|
||||
}
|
||||
return {};
|
||||
},
|
||||
|
||||
stop: function() {
|
||||
if (this._started) {
|
||||
this._agents.forEach(agent => agent.stop());
|
||||
Services.obs.notifyObservers(null, "devtools-monitor-stop", "");
|
||||
Services.obs.removeObserver(this, "devtools-monitor-update");
|
||||
this._started = false;
|
||||
}
|
||||
return {};
|
||||
},
|
||||
|
||||
disconnect: function() {
|
||||
this.stop();
|
||||
},
|
||||
|
||||
// nsIObserver
|
||||
|
||||
observe: function (subject, topic, data) {
|
||||
@ -75,16 +64,16 @@ MonitorActor.prototype = {
|
||||
return;
|
||||
}
|
||||
if (!Array.isArray(data)) {
|
||||
this._updates.push(data);
|
||||
this._toSend.push(data);
|
||||
} else {
|
||||
this._updates = this._updates.concat(data);
|
||||
this._toSend = this._toSend.concat(data);
|
||||
}
|
||||
this._sendUpdate();
|
||||
this._scheduleUpdate();
|
||||
}
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
|
||||
};
|
||||
}
|
||||
|
||||
MonitorActor.prototype.requestTypes = {
|
||||
"start": MonitorActor.prototype.start,
|
||||
@ -102,37 +91,3 @@ exports.unregister = function(handle) {
|
||||
handle.removeGlobalActor(MonitorActor, "monitorActor");
|
||||
handle.removeTabActor(MonitorActor, "monitorActor");
|
||||
};
|
||||
|
||||
|
||||
let USSAgent = {
|
||||
_mgr: null,
|
||||
_timeout: null,
|
||||
_packet: {
|
||||
graph: "USS",
|
||||
time: null,
|
||||
value: null
|
||||
},
|
||||
|
||||
start: function() {
|
||||
USSAgent._mgr = Cc["@mozilla.org/memory-reporter-manager;1"].getService(Ci.nsIMemoryReporterManager);
|
||||
USSAgent.update();
|
||||
},
|
||||
|
||||
update: function() {
|
||||
if (!USSAgent._mgr) {
|
||||
USSAgent.stop();
|
||||
return;
|
||||
}
|
||||
USSAgent._packet.time = Date.now();
|
||||
USSAgent._packet.value = USSAgent._mgr.residentUnique;
|
||||
Services.obs.notifyObservers(null, "devtools-monitor-update", JSON.stringify(USSAgent._packet));
|
||||
USSAgent._timeout = setTimeout(USSAgent.update, 300);
|
||||
},
|
||||
|
||||
stop: function() {
|
||||
clearTimeout(USSAgent._timeout);
|
||||
USSAgent._mgr = null;
|
||||
}
|
||||
};
|
||||
|
||||
MonitorActor.prototype._addAgent(USSAgent);
|
||||
|
Loading…
Reference in New Issue
Block a user