mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 918695 - Only instanciate one singleton target per app r=paul
This commit is contained in:
parent
6ef67e921c
commit
812398850f
@ -15,6 +15,8 @@ const PR_TRUNCATE = 0x20;
|
||||
|
||||
const CHUNK_SIZE = 10000;
|
||||
|
||||
const appTargets = new Map();
|
||||
|
||||
function addDirToZip(writer, dir, basePath) {
|
||||
let files = dir.directoryEntries;
|
||||
|
||||
@ -212,6 +214,13 @@ function installHosted(client, webappsActor, appId, metadata, manifest) {
|
||||
exports.installHosted = installHosted;
|
||||
|
||||
function getTargetForApp(client, webappsActor, manifestURL) {
|
||||
// Ensure always returning the exact same JS object for a target
|
||||
// of the same app in order to show only one toolbox per app and
|
||||
// avoid re-creating lot of objects twice.
|
||||
let existingTarget = appTargets.get(manifestURL);
|
||||
if (existingTarget)
|
||||
return promise.resolve(existingTarget);
|
||||
|
||||
let deferred = promise.defer();
|
||||
let request = {
|
||||
to: webappsActor,
|
||||
@ -230,6 +239,10 @@ function getTargetForApp(client, webappsActor, manifestURL) {
|
||||
|
||||
devtools.TargetFactory.forRemoteTab(options).then((target) => {
|
||||
target.isApp = true;
|
||||
appTargets.set(manifestURL, target);
|
||||
target.on("close", () => {
|
||||
appTargets.delete(manifestURL);
|
||||
});
|
||||
deferred.resolve(target)
|
||||
}, (error) => {
|
||||
deferred.reject(error);
|
||||
|
Loading…
Reference in New Issue
Block a user