mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 793672 - Allow to get notifications for arbitrary observer topics through RDP with the profiler actor. r=past
This commit is contained in:
parent
cbb20704b2
commit
958dbfdb59
@ -164,10 +164,10 @@ const ThreadStateTypes = {
|
|||||||
* by the client.
|
* by the client.
|
||||||
*/
|
*/
|
||||||
const UnsolicitedNotifications = {
|
const UnsolicitedNotifications = {
|
||||||
|
"eventNotification": "eventNotification",
|
||||||
"newScript": "newScript",
|
"newScript": "newScript",
|
||||||
"tabDetached": "tabDetached",
|
"tabDetached": "tabDetached",
|
||||||
"tabNavigated": "tabNavigated",
|
"tabNavigated": "tabNavigated"
|
||||||
"profilerStateChanged": "profilerStateChanged"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,19 +10,18 @@
|
|||||||
*/
|
*/
|
||||||
function ProfilerActor(aConnection)
|
function ProfilerActor(aConnection)
|
||||||
{
|
{
|
||||||
this._conn = aConnection;
|
|
||||||
this._profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
|
this._profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
|
||||||
this._started = false;
|
this._started = false;
|
||||||
|
this._observedEvents = [];
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
|
||||||
Services.obs.addObserver(this, "profiler-started", false);
|
|
||||||
Services.obs.addObserver(this, "profiler-stopped", false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfilerActor.prototype = {
|
ProfilerActor.prototype = {
|
||||||
actorPrefix: "profiler",
|
actorPrefix: "profiler",
|
||||||
|
|
||||||
disconnect: function() {
|
disconnect: function() {
|
||||||
|
for (var event of this._observedEvents) {
|
||||||
|
Services.obs.removeObserver(this, event);
|
||||||
|
}
|
||||||
if (this._profiler && this._started) {
|
if (this._profiler && this._started) {
|
||||||
this._profiler.StopProfiler();
|
this._profiler.StopProfiler();
|
||||||
}
|
}
|
||||||
@ -64,12 +63,59 @@ ProfilerActor.prototype = {
|
|||||||
var sharedLibraries = this._profiler.getSharedLibraryInformation();
|
var sharedLibraries = this._profiler.getSharedLibraryInformation();
|
||||||
return { "sharedLibraryInformation": sharedLibraries }
|
return { "sharedLibraryInformation": sharedLibraries }
|
||||||
},
|
},
|
||||||
observe: function(aSubject, aTopic, aData) {
|
onRegisterEventNotifications: function(aRequest) {
|
||||||
if (aTopic == "profiler-started") {
|
let registered = [];
|
||||||
this.conn.send({ from: this.actorID, type: "profilerStateChanged", isActive: true });
|
for (var event of aRequest.events) {
|
||||||
} else if (aTopic == "profiler-stopped") {
|
if (this._observedEvents.indexOf(event) != -1)
|
||||||
this.conn.send({ from: this.actorID, type: "profilerStateChanged", isActive: false });
|
continue;
|
||||||
|
Services.obs.addObserver(this, event, false);
|
||||||
|
this._observedEvents.push(event);
|
||||||
|
registered.push(event);
|
||||||
}
|
}
|
||||||
|
return { registered: registered }
|
||||||
|
},
|
||||||
|
onUnregisterEventNotifications: function(aRequest) {
|
||||||
|
let unregistered = [];
|
||||||
|
for (var event of aRequest.events) {
|
||||||
|
let idx = this._observedEvents.indexOf(event);
|
||||||
|
if (idx == -1)
|
||||||
|
continue;
|
||||||
|
Services.obs.removeObserver(this, event);
|
||||||
|
this._observedEvents.splice(idx, 1);
|
||||||
|
unregistered.push(event);
|
||||||
|
}
|
||||||
|
return { unregistered: unregistered }
|
||||||
|
},
|
||||||
|
observe: function(aSubject, aTopic, aData) {
|
||||||
|
function unWrapper(obj) {
|
||||||
|
if (obj && typeof obj == "object" && ("wrappedJSObject" in obj)) {
|
||||||
|
obj = obj.wrappedJSObject;
|
||||||
|
if (("wrappedJSObject" in obj) && (obj.wrappedJSObject == obj)) {
|
||||||
|
/* If the object defines wrappedJSObject as itself, which is the
|
||||||
|
* typical idiom for wrapped JS objects, JSON.stringify won't be
|
||||||
|
* able to work because the object is cyclic.
|
||||||
|
* But removing the wrappedJSObject property will break aSubject
|
||||||
|
* for possible other observers of the same topic, so we need
|
||||||
|
* to restore wrappedJSObject afterwards */
|
||||||
|
delete obj.wrappedJSObject;
|
||||||
|
return { unwrapped: obj,
|
||||||
|
fixup: function() {
|
||||||
|
this.unwrapped.wrappedJSObject = this.unwrapped;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { unwrapped: obj, fixup: function() { } }
|
||||||
|
}
|
||||||
|
var subject = unWrapper(aSubject);
|
||||||
|
var data = unWrapper(aData);
|
||||||
|
this.conn.send({ from: this.actorID,
|
||||||
|
type: "eventNotification",
|
||||||
|
event: aTopic,
|
||||||
|
subject: subject.unwrapped,
|
||||||
|
data: data.unwrapped });
|
||||||
|
data.fixup();
|
||||||
|
subject.fixup();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -84,7 +130,9 @@ ProfilerActor.prototype.requestTypes = {
|
|||||||
"isActive": ProfilerActor.prototype.onIsActive,
|
"isActive": ProfilerActor.prototype.onIsActive,
|
||||||
"getResponsivenessTimes": ProfilerActor.prototype.onGetResponsivenessTimes,
|
"getResponsivenessTimes": ProfilerActor.prototype.onGetResponsivenessTimes,
|
||||||
"getFeatures": ProfilerActor.prototype.onGetFeatures,
|
"getFeatures": ProfilerActor.prototype.onGetFeatures,
|
||||||
"getSharedLibraryInformation": ProfilerActor.prototype.onGetSharedLibraryInformation
|
"getSharedLibraryInformation": ProfilerActor.prototype.onGetSharedLibraryInformation,
|
||||||
|
"registerEventNotifications": ProfilerActor.prototype.onRegisterEventNotifications,
|
||||||
|
"unregisterEventNotifications": ProfilerActor.prototype.onUnregisterEventNotifications
|
||||||
};
|
};
|
||||||
|
|
||||||
DebuggerServer.addGlobalActor(ProfilerActor, "profilerActor");
|
DebuggerServer.addGlobalActor(ProfilerActor, "profilerActor");
|
||||||
|
Loading…
Reference in New Issue
Block a user