зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1315044 - Cache ContentActor forms to prevent creating new one when calling RootActor.getProcess multiple times. r=jryans
MozReview-Commit-ID: 3YyShRXQhel --HG-- extra : rebase_source : 670ce6dc1b4c451bdb59dcebfa859d6089ed2624
This commit is contained in:
Родитель
4c7f0577fe
Коммит
c1adf2fe24
|
@ -103,6 +103,7 @@ function RootActor(aConnection, aParameters) {
|
||||||
this.conn.addActorPool(this._globalActorPool);
|
this.conn.addActorPool(this._globalActorPool);
|
||||||
|
|
||||||
this._chromeActor = null;
|
this._chromeActor = null;
|
||||||
|
this._processActors = new Map();
|
||||||
}
|
}
|
||||||
|
|
||||||
RootActor.prototype = {
|
RootActor.prototype = {
|
||||||
|
@ -230,6 +231,7 @@ RootActor.prototype = {
|
||||||
this._globalActorPool = null;
|
this._globalActorPool = null;
|
||||||
this._parameters = null;
|
this._parameters = null;
|
||||||
this._chromeActor = null;
|
this._chromeActor = null;
|
||||||
|
this._processActors.clear();
|
||||||
},
|
},
|
||||||
|
|
||||||
/* The 'listTabs' request and the 'tabListChanged' notification. */
|
/* The 'listTabs' request and the 'tabListChanged' notification. */
|
||||||
|
@ -471,13 +473,24 @@ RootActor.prototype = {
|
||||||
|
|
||||||
return { form: this._chromeActor.form() };
|
return { form: this._chromeActor.form() };
|
||||||
} else {
|
} else {
|
||||||
let mm = ppmm.getChildAt(aRequest.id);
|
let { id } = aRequest;
|
||||||
|
let mm = ppmm.getChildAt(id);
|
||||||
if (!mm) {
|
if (!mm) {
|
||||||
return { error: "noProcess",
|
return { error: "noProcess",
|
||||||
message: "There is no process with id '" + aRequest.id + "'." };
|
message: "There is no process with id '" + id + "'." };
|
||||||
}
|
}
|
||||||
return DebuggerServer.connectToContent(this.conn, mm)
|
let form = this._processActors.get(id);
|
||||||
.then(form => ({ form }));
|
if (form) {
|
||||||
|
return { form };
|
||||||
|
}
|
||||||
|
let onDestroy = () => {
|
||||||
|
this._processActors.delete(id);
|
||||||
|
};
|
||||||
|
return DebuggerServer.connectToContent(this.conn, mm, onDestroy)
|
||||||
|
.then(form => {
|
||||||
|
this._processActors.set(id, form);
|
||||||
|
return { form };
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -715,7 +715,7 @@ var DebuggerServer = {
|
||||||
return this._onConnection(transport, prefix, true);
|
return this._onConnection(transport, prefix, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
connectToContent(connection, mm) {
|
connectToContent(connection, mm, onDestroy) {
|
||||||
let deferred = SyncPromise.defer();
|
let deferred = SyncPromise.defer();
|
||||||
|
|
||||||
let prefix = connection.allocID("content-process");
|
let prefix = connection.allocID("content-process");
|
||||||
|
@ -764,6 +764,10 @@ var DebuggerServer = {
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (onDestroy) {
|
||||||
|
onDestroy(mm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let onMessageManagerClose = DevToolsUtils.makeInfallible((subject, topic, data) => {
|
let onMessageManagerClose = DevToolsUtils.makeInfallible((subject, topic, data) => {
|
||||||
|
|
|
@ -97,12 +97,24 @@ function runTests() {
|
||||||
text: "var a = 42; a"
|
text: "var a = 42; a"
|
||||||
}, function (response) {
|
}, function (response) {
|
||||||
ok(response.result, 42, "console.eval worked");
|
ok(response.result, 42, "console.eval worked");
|
||||||
cleanup();
|
|
||||||
|
getProcessAgain(actor, content.id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assert that calling client.getProcess against the same process id is
|
||||||
|
// returning the same actor.
|
||||||
|
function getProcessAgain(firstActor, id) {
|
||||||
|
client.getProcess(id).then(response => {
|
||||||
|
let actor = response.form;
|
||||||
|
is(actor, firstActor,
|
||||||
|
"Second call to getProcess with the same id returns the same form");
|
||||||
|
cleanup();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
client.close().then(function () {
|
client.close().then(function () {
|
||||||
DebuggerServer.destroy();
|
DebuggerServer.destroy();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче