Store frame to guests in map

This commit is contained in:
Kevin Sawicki 2017-04-25 13:53:29 -07:00
parent 9643b2a5c5
commit 91a1e5cdfe

View file

@ -5,7 +5,7 @@ const {isSameOrigin} = process.atomBinding('v8_util')
const parseFeaturesString = require('../common/parse-features-string')
const hasProp = {}.hasOwnProperty
const frameToGuest = {}
const frameToGuest = new Map()
// Copy attribute of |parent| to |child| if it is not defined in |child|.
const mergeOptions = function (child, parent, visited) {
@ -92,10 +92,10 @@ const setupGuest = function (embedder, frameName, guest, options) {
guest.once('closed', closedByUser)
}
if (frameName) {
frameToGuest[frameName] = guest
frameToGuest.set(frameName, guest)
guest.frameName = frameName
guest.once('closed', function () {
delete frameToGuest[frameName]
frameToGuest.delete(frameName)
})
}
return guestId
@ -103,7 +103,7 @@ const setupGuest = function (embedder, frameName, guest, options) {
// Create a new guest created by |embedder| with |options|.
const createGuest = function (embedder, url, frameName, options, postData) {
let guest = frameToGuest[frameName]
let guest = frameToGuest.get(frameName)
if (frameName && (guest != null)) {
guest.loadURL(url)
return guest.webContents.id