mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 989043 - Network monitor support for e10s. r=ochameau
This commit is contained in:
parent
c74236a7e0
commit
194d4fe0d9
@ -118,11 +118,7 @@ let developerHUD = {
|
||||
if (this._targets.has(frame))
|
||||
return;
|
||||
|
||||
let mm = frame.QueryInterface(Ci.nsIFrameLoaderOwner)
|
||||
.frameLoader
|
||||
.messageManager;
|
||||
|
||||
DebuggerServer.connectToChild(this._conn, mm).then(actor => {
|
||||
DebuggerServer.connectToChild(this._conn, frame).then(actor => {
|
||||
let target = new Target(frame, actor);
|
||||
this._targets.set(frame, target);
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
function ContentActor(connection, chromeGlobal)
|
||||
{
|
||||
TabActor.call(this, connection, chromeGlobal);
|
||||
this._chromeGlobal = chromeGlobal;
|
||||
this.traits.reconfigure = false;
|
||||
}
|
||||
|
||||
@ -33,7 +32,7 @@ ContentActor.prototype.constructor = ContentActor;
|
||||
|
||||
Object.defineProperty(ContentActor.prototype, "docShell", {
|
||||
get: function() {
|
||||
return this._chromeGlobal.docShell;
|
||||
return this.chromeEventHandler.docShell;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: false
|
||||
@ -41,7 +40,6 @@ Object.defineProperty(ContentActor.prototype, "docShell", {
|
||||
|
||||
ContentActor.prototype.exit = function() {
|
||||
TabActor.prototype.exit.call(this);
|
||||
this._chromeGlobal = null;
|
||||
};
|
||||
|
||||
// Override grip just to rename this._tabActorPool to this._tabActorPool2
|
||||
|
@ -14,11 +14,6 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "NetworkMonitorManager", () => {
|
||||
return devtools.require("devtools/toolkit/webconsole/network-monitor")
|
||||
.NetworkMonitorManager;
|
||||
});
|
||||
|
||||
let promise;
|
||||
|
||||
function debug(aMsg) {
|
||||
@ -828,21 +823,15 @@ WebappsActor.prototype = {
|
||||
.frameLoader
|
||||
.messageManager;
|
||||
let actor = map.get(mm);
|
||||
let netMonitor = null;
|
||||
if (!actor) {
|
||||
let onConnect = actor => {
|
||||
map.set(mm, actor);
|
||||
netMonitor = new NetworkMonitorManager(appFrame);
|
||||
return { actor: actor };
|
||||
};
|
||||
let onDisconnect = mm => {
|
||||
map.delete(mm);
|
||||
if (netMonitor) {
|
||||
netMonitor.destroy();
|
||||
netMonitor = null;
|
||||
}
|
||||
};
|
||||
return DebuggerServer.connectToChild(this.conn, mm, onDisconnect)
|
||||
return DebuggerServer.connectToChild(this.conn, appFrame, onDisconnect)
|
||||
.then(onConnect);
|
||||
}
|
||||
|
||||
|
@ -525,6 +525,13 @@ TabActor.prototype = {
|
||||
return this._chromeEventHandler;
|
||||
},
|
||||
|
||||
/**
|
||||
* Getter for the nsIMessageManager associated to the tab.
|
||||
*/
|
||||
get messageManager() {
|
||||
return this._chromeEventHandler;
|
||||
},
|
||||
|
||||
/**
|
||||
* Getter for the tab's doc shell.
|
||||
*/
|
||||
@ -982,6 +989,14 @@ Object.defineProperty(BrowserTabActor.prototype, "docShell", {
|
||||
configurable: false
|
||||
});
|
||||
|
||||
Object.defineProperty(BrowserTabActor.prototype, "messageManager", {
|
||||
get: function() {
|
||||
return this._browser.messageManager;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: false
|
||||
});
|
||||
|
||||
Object.defineProperty(BrowserTabActor.prototype, "title", {
|
||||
get: function() {
|
||||
let title = this.contentDocument.contentTitle;
|
||||
@ -1034,7 +1049,7 @@ function RemoteBrowserTabActor(aConnection, aBrowser)
|
||||
|
||||
RemoteBrowserTabActor.prototype = {
|
||||
connect: function() {
|
||||
return DebuggerServer.connectToChild(this._conn, this._browser.messageManager);
|
||||
return DebuggerServer.connectToChild(this._conn, this._browser);
|
||||
},
|
||||
|
||||
form: function() {
|
||||
|
@ -508,9 +508,8 @@ WebConsoleActor.prototype =
|
||||
let messageManager = null;
|
||||
|
||||
if (this._parentIsContentActor) {
|
||||
// Filter network requests by appId on Firefox OS devices.
|
||||
appId = this.parentActor.docShell.appId;
|
||||
messageManager = this.parentActor._chromeGlobal;
|
||||
messageManager = this.parentActor.messageManager;
|
||||
}
|
||||
|
||||
while (aRequest.listeners.length > 0) {
|
||||
@ -534,9 +533,10 @@ WebConsoleActor.prototype =
|
||||
break;
|
||||
case "NetworkActivity":
|
||||
if (!this.networkMonitor) {
|
||||
if (appId && messageManager) {
|
||||
if (appId || messageManager) {
|
||||
this.networkMonitor =
|
||||
new NetworkMonitorChild(appId, messageManager, this);
|
||||
new NetworkMonitorChild(appId, messageManager,
|
||||
this.parentActor.actorID, this);
|
||||
}
|
||||
else {
|
||||
this.networkMonitor = new NetworkMonitor({ window: window }, this);
|
||||
|
@ -70,6 +70,10 @@ this.all = all;
|
||||
Cu.import("resource://gre/modules/devtools/SourceMap.jsm");
|
||||
Cu.import("resource://gre/modules/devtools/Console.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "NetworkMonitorManager", () => {
|
||||
return require("devtools/toolkit/webconsole/network-monitor").NetworkMonitorManager;
|
||||
});
|
||||
|
||||
function dumpn(str) {
|
||||
if (wantLogging) {
|
||||
dump("DBG-SERVER: " + str + "\n");
|
||||
@ -536,14 +540,29 @@ var DebuggerServer = {
|
||||
return this._onConnection(transport, aPrefix, true);
|
||||
},
|
||||
|
||||
connectToChild: function(aConnection, aMessageManager, aOnDisconnect) {
|
||||
let deferred = Promise.defer();
|
||||
/**
|
||||
* Connect to a child process.
|
||||
*
|
||||
* @param object aConnection
|
||||
* The debugger server connection to use.
|
||||
* @param nsIDOMElement aFrame
|
||||
* The browser element that holds the child process.
|
||||
* @param function [aOnDisconnect]
|
||||
* Optional function to invoke when the child is disconnected.
|
||||
* @return object
|
||||
* A promise object that is resolved once the connection is
|
||||
* established.
|
||||
*/
|
||||
connectToChild: function(aConnection, aFrame, aOnDisconnect) {
|
||||
let deferred = defer();
|
||||
|
||||
let mm = aMessageManager;
|
||||
let mm = aFrame.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader
|
||||
.messageManager;
|
||||
mm.loadFrameScript("resource://gre/modules/devtools/server/child.js", false);
|
||||
|
||||
let actor, childTransport;
|
||||
let prefix = aConnection.allocID("child");
|
||||
let netMonitor = null;
|
||||
|
||||
let onActorCreated = DevToolsUtils.makeInfallible(function (msg) {
|
||||
mm.removeMessageListener("debug:actor", onActorCreated);
|
||||
@ -562,6 +581,8 @@ var DebuggerServer = {
|
||||
|
||||
actor = msg.json.actor;
|
||||
|
||||
netMonitor = new NetworkMonitorManager(aFrame, actor.actor);
|
||||
|
||||
deferred.resolve(actor);
|
||||
}).bind(this);
|
||||
mm.addMessageListener("debug:actor", onActorCreated);
|
||||
@ -589,6 +610,11 @@ var DebuggerServer = {
|
||||
actor = null;
|
||||
}
|
||||
|
||||
if (netMonitor) {
|
||||
netMonitor.destroy();
|
||||
netMonitor = null;
|
||||
}
|
||||
|
||||
if (aOnDisconnect) {
|
||||
aOnDisconnect(mm);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ function runTests() {
|
||||
let transport = DebuggerServer.connectPipe();
|
||||
let conn = transport._serverConnection;
|
||||
let client = new DebuggerClient(transport);
|
||||
DebuggerServer.connectToChild(conn, mm).then(actor => {
|
||||
DebuggerServer.connectToChild(conn, iframe).then(actor => {
|
||||
ok(actor.testActor, "Got the test actor");
|
||||
|
||||
// Ensure sending at least one request to our actor,
|
||||
@ -104,7 +104,7 @@ function runTests() {
|
||||
let transport = DebuggerServer.connectPipe();
|
||||
let conn = transport._serverConnection;
|
||||
let client = new DebuggerClient(transport);
|
||||
DebuggerServer.connectToChild(conn, mm).then(actor => {
|
||||
DebuggerServer.connectToChild(conn, iframe).then(actor => {
|
||||
ok(actor.testActor, "Got a test actor for the second connection");
|
||||
isnot(actor.testActor, firstActor, "We get different actor instances between two connections");
|
||||
|
||||
|
@ -1001,11 +1001,14 @@ NetworkMonitor.prototype = {
|
||||
* The web appId of the child process.
|
||||
* @param nsIMessageManager messageManager
|
||||
* The nsIMessageManager to use to communicate with the parent process.
|
||||
* @param string connID
|
||||
* The connection ID to use for send messages to the parent process.
|
||||
* @param object owner
|
||||
* The WebConsoleActor that is listening for the network requests.
|
||||
*/
|
||||
function NetworkMonitorChild(appId, messageManager, owner) {
|
||||
function NetworkMonitorChild(appId, messageManager, connID, owner) {
|
||||
this.appId = appId;
|
||||
this.connID = connID;
|
||||
this.owner = owner;
|
||||
this._messageManager = messageManager;
|
||||
this._onNewEvent = this._onNewEvent.bind(this);
|
||||
@ -1027,7 +1030,7 @@ NetworkMonitorChild.prototype = {
|
||||
set saveRequestAndResponseBodies(val) {
|
||||
this._saveRequestAndResponseBodies = val;
|
||||
|
||||
this._messageManager.sendAsyncMessage("debug:netmonitor", {
|
||||
this._messageManager.sendAsyncMessage("debug:netmonitor:" + this.connID, {
|
||||
appId: this.appId,
|
||||
action: "setPreferences",
|
||||
preferences: {
|
||||
@ -1037,9 +1040,12 @@ NetworkMonitorChild.prototype = {
|
||||
},
|
||||
|
||||
init: function() {
|
||||
this._messageManager.addMessageListener("debug:netmonitor:newEvent", this._onNewEvent);
|
||||
this._messageManager.addMessageListener("debug:netmonitor:updateEvent", this._onUpdateEvent);
|
||||
this._messageManager.sendAsyncMessage("debug:netmonitor", {
|
||||
let mm = this._messageManager;
|
||||
mm.addMessageListener("debug:netmonitor:" + this.connID + ":newEvent",
|
||||
this._onNewEvent);
|
||||
mm.addMessageListener("debug:netmonitor:" + this.connID + ":updateEvent",
|
||||
this._onUpdateEvent);
|
||||
mm.sendAsyncMessage("debug:netmonitor:" + this.connID, {
|
||||
appId: this.appId,
|
||||
action: "start",
|
||||
});
|
||||
@ -1067,9 +1073,14 @@ NetworkMonitorChild.prototype = {
|
||||
}),
|
||||
|
||||
destroy: function() {
|
||||
this._messageManager.removeMessageListener("debug:netmonitor:newEvent", this._onNewEvent);
|
||||
this._messageManager.removeMessageListener("debug:netmonitor:updateEvent", this._onUpdateEvent);
|
||||
this._messageManager.sendAsyncMessage("debug:netmonitor", { action: "disconnect" });
|
||||
let mm = this._messageManager;
|
||||
mm.removeMessageListener("debug:netmonitor:" + this.connID + ":newEvent",
|
||||
this._onNewEvent);
|
||||
mm.removeMessageListener("debug:netmonitor:" + this.connID + ":updateEvent",
|
||||
this._onUpdateEvent);
|
||||
mm.sendAsyncMessage("debug:netmonitor:" + this.connID, {
|
||||
action: "disconnect",
|
||||
});
|
||||
this._netEvents.clear();
|
||||
this._messageManager = null;
|
||||
this.owner = null;
|
||||
@ -1090,9 +1101,12 @@ NetworkMonitorChild.prototype = {
|
||||
* @param nsIMessageManager messageManager
|
||||
* The message manager for the child app process. This is used for
|
||||
* communication with the NetworkMonitorChild instance of the process.
|
||||
* @param string connID
|
||||
* The connection ID to use to send messages to the child process.
|
||||
*/
|
||||
function NetworkEventActorProxy(messageManager) {
|
||||
function NetworkEventActorProxy(messageManager, connID) {
|
||||
this.id = gSequenceId();
|
||||
this.connID = connID;
|
||||
this.messageManager = messageManager;
|
||||
}
|
||||
exports.NetworkEventActorProxy = NetworkEventActorProxy;
|
||||
@ -1100,7 +1114,8 @@ exports.NetworkEventActorProxy = NetworkEventActorProxy;
|
||||
NetworkEventActorProxy.methodFactory = function(method) {
|
||||
return DevToolsUtils.makeInfallible(function() {
|
||||
let args = Array.slice(arguments);
|
||||
this.messageManager.sendAsyncMessage("debug:netmonitor:updateEvent", {
|
||||
let mm = this.messageManager;
|
||||
mm.sendAsyncMessage("debug:netmonitor:" + this.connID + ":updateEvent", {
|
||||
id: this.id,
|
||||
method: method,
|
||||
args: args,
|
||||
@ -1120,7 +1135,8 @@ NetworkEventActorProxy.prototype = {
|
||||
*/
|
||||
init: DevToolsUtils.makeInfallible(function(event)
|
||||
{
|
||||
this.messageManager.sendAsyncMessage("debug:netmonitor:newEvent", {
|
||||
let mm = this.messageManager;
|
||||
mm.sendAsyncMessage("debug:netmonitor:" + this.connID + ":newEvent", {
|
||||
id: this.id,
|
||||
event: event,
|
||||
});
|
||||
@ -1148,16 +1164,19 @@ NetworkEventActorProxy.prototype = {
|
||||
* @constructor
|
||||
* @param nsIDOMElement frame
|
||||
* The browser frame to work with (mozbrowser).
|
||||
* @param string id
|
||||
* Instance identifier to use for messages.
|
||||
*/
|
||||
function NetworkMonitorManager(frame)
|
||||
function NetworkMonitorManager(frame, id)
|
||||
{
|
||||
this.id = id;
|
||||
let mm = frame.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader.messageManager;
|
||||
this.messageManager = mm;
|
||||
this.frame = frame;
|
||||
this.onNetMonitorMessage = this.onNetMonitorMessage.bind(this);
|
||||
this.onNetworkEvent = this.onNetworkEvent.bind(this);
|
||||
|
||||
mm.addMessageListener("debug:netmonitor", this.onNetMonitorMessage);
|
||||
mm.addMessageListener("debug:netmonitor:" + id, this.onNetMonitorMessage);
|
||||
}
|
||||
exports.NetworkMonitorManager = NetworkMonitorManager;
|
||||
|
||||
@ -1175,7 +1194,6 @@ NetworkMonitorManager.prototype = {
|
||||
*/
|
||||
onNetMonitorMessage: DevToolsUtils.makeInfallible(function _onNetMonitorMessage(msg) {
|
||||
let { action, appId } = msg.json;
|
||||
|
||||
// Pipe network monitor data from parent to child via the message manager.
|
||||
switch (action) {
|
||||
case "start":
|
||||
@ -1222,13 +1240,15 @@ NetworkMonitorManager.prototype = {
|
||||
* data about the request is available.
|
||||
*/
|
||||
onNetworkEvent: DevToolsUtils.makeInfallible(function _onNetworkEvent(event) {
|
||||
return new NetworkEventActorProxy(this.messageManager).init(event);
|
||||
return new NetworkEventActorProxy(this.messageManager, this.id).init(event);
|
||||
}),
|
||||
|
||||
destroy: function()
|
||||
{
|
||||
this.messageManager.removeMessageListener("debug:netmonitor",
|
||||
this.onNetMonitorMessage);
|
||||
if (this.messageManager) {
|
||||
this.messageManager.removeMessageListener("debug:netmonitor:" + this.id,
|
||||
this.onNetMonitorMessage);
|
||||
}
|
||||
this.messageManager = null;
|
||||
this.filters = null;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user