Clean up CallbackRegistry
There were some ancient code there.
This commit is contained in:
parent
94f64c755d
commit
d9fdfb711f
2 changed files with 5 additions and 10 deletions
|
@ -71,7 +71,7 @@ unwrapArgs = (sender, args) ->
|
||||||
ret = ->
|
ret = ->
|
||||||
if rendererReleased
|
if rendererReleased
|
||||||
throw new Error("Attempting to call a function in a renderer window
|
throw new Error("Attempting to call a function in a renderer window
|
||||||
that has been closed or released. Function provided here: #{meta.id}.")
|
that has been closed or released. Function provided here: #{meta.id}.")
|
||||||
sender.send 'ATOM_RENDERER_CALLBACK', meta.id, valueToMeta(sender, arguments)
|
sender.send 'ATOM_RENDERER_CALLBACK', meta.id, valueToMeta(sender, arguments)
|
||||||
v8Util.setDestructor ret, ->
|
v8Util.setDestructor ret, ->
|
||||||
return if rendererReleased
|
return if rendererReleased
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
savedGlobal = global # the "global.global" might be deleted later
|
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
class CallbacksRegistry
|
class CallbacksRegistry
|
||||||
constructor: ->
|
constructor: ->
|
||||||
@emptyFunc = -> throw new Error "Browser trying to call a non-exist callback
|
@nextId = 0
|
||||||
in renderer, this usually happens when renderer code forgot to release
|
|
||||||
a callback installed on objects in browser when renderer was going to be
|
|
||||||
unloaded or released."
|
|
||||||
@callbacks = {}
|
@callbacks = {}
|
||||||
|
|
||||||
add: (callback) ->
|
add: (callback) ->
|
||||||
id = Math.random().toString()
|
id = ++@nextId
|
||||||
|
|
||||||
# Capture the location of the function and put it in the ID string,
|
# Capture the location of the function and put it in the ID string,
|
||||||
# so that release errors can be tracked down easily.
|
# so that release errors can be tracked down easily.
|
||||||
|
@ -32,10 +27,10 @@ class CallbacksRegistry
|
||||||
@callbacks[id] ? ->
|
@callbacks[id] ? ->
|
||||||
|
|
||||||
call: (id, args...) ->
|
call: (id, args...) ->
|
||||||
@get(id).call savedGlobal, args...
|
@get(id).call global, args...
|
||||||
|
|
||||||
apply: (id, args...) ->
|
apply: (id, args...) ->
|
||||||
@get(id).apply savedGlobal, args...
|
@get(id).apply global, args...
|
||||||
|
|
||||||
remove: (id) ->
|
remove: (id) ->
|
||||||
delete @callbacks[id]
|
delete @callbacks[id]
|
||||||
|
|
Loading…
Reference in a new issue