Don't add too much listeners in BrowserWindowProxy

This commit is contained in:
Cheng Zhao 2015-12-04 11:02:55 +08:00
Родитель 504d3d3088
Коммит 2c6d232254
2 изменённых файлов: 3 добавлений и 4 удалений

Просмотреть файл

@ -44,7 +44,7 @@ createGuest = (embedder, url, frameName, options) ->
guest.removeListener 'closed', closedByUser
guest.destroy()
closedByUser = ->
embedder.send 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSED', guestId
embedder.send "ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSED_#{guestId}"
embedder.removeListener 'render-view-deleted', closedByEmbedder
embedder.once 'render-view-deleted', closedByEmbedder
guest.once 'closed', closedByUser

Просмотреть файл

@ -10,8 +10,7 @@ resolveURL = (url) ->
class BrowserWindowProxy
constructor: (@guestId) ->
@closed = false
ipcRenderer.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSED', (event, guestId) =>
if guestId is @guestId
ipcRenderer.once "ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSED_#{@guestId}", =>
@closed = true
close: ->