mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Co-locate with other private methods
This commit is contained in:
@@ -36,18 +36,6 @@ class ObjectsRegistry {
|
||||
return id
|
||||
}
|
||||
|
||||
// Clear the storage when webContents is reloaded/navigated.
|
||||
registerDeleteListener (webContents, webContentsId) {
|
||||
const processId = webContents.getProcessId()
|
||||
const listener = (event, deletedProcessId) => {
|
||||
if (deletedProcessId === processId) {
|
||||
webContents.removeListener('render-view-deleted', listener)
|
||||
this.clear(webContentsId)
|
||||
}
|
||||
}
|
||||
webContents.on('render-view-deleted', listener)
|
||||
}
|
||||
|
||||
// Get an object according to its ID.
|
||||
get (id) {
|
||||
return this.storage[id].object
|
||||
@@ -101,6 +89,18 @@ class ObjectsRegistry {
|
||||
delete this.storage[id]
|
||||
}
|
||||
}
|
||||
|
||||
// Private: Clear the storage when webContents is reloaded/navigated.
|
||||
registerDeleteListener (webContents, webContentsId) {
|
||||
const processId = webContents.getProcessId()
|
||||
const listener = (event, deletedProcessId) => {
|
||||
if (deletedProcessId === processId) {
|
||||
webContents.removeListener('render-view-deleted', listener)
|
||||
this.clear(webContentsId)
|
||||
}
|
||||
}
|
||||
webContents.on('render-view-deleted', listener)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new ObjectsRegistry()
|
||||
|
||||
Reference in New Issue
Block a user