# Create a delegate function to do asynchronous RPC call.
ret = ->
args = new Meta(processId, routingId, arguments)
- ipc.sendChannel processId, routingId, 'ATOM_INTERNAL_FUNCTION_CALL', meta.id, args
+ ipc.sendChannel processId, routingId, 'ATOM_RENDERER_FUNCTION_CALL', meta.id, args
v8_util.setDestructor ret, ->
- ipc.sendChannel processId, routingId, 'ATOM_INTERNAL_DEREFERENCE', meta.id
+ ipc.sendChannel processId, routingId, 'ATOM_RENDERER_DEREFERENCE', meta.id
ret
constructCallback meta for meta in metas
@type = 'value'
@value = value
-ipc.on 'ATOM_INTERNAL_REQUIRE', (event, processId, routingId, module) ->
+ipc.on 'ATOM_BROWSER_REQUIRE', (event, processId, routingId, module) ->
try
event.result = new Meta(processId, routingId, require(module))
catch e
event.result = type: 'error', value: e.message
-ipc.on 'ATOM_INTERNAL_CURRENT_WINDOW', (event, processId, routingId) ->
+ipc.on 'ATOM_BROWSER_CURRENT_WINDOW', (event, processId, routingId) ->
try
windows = objectsRegistry.getAllWindows()
for window in windows
catch e
event.result = type: 'error', value: e.message
-ipc.on 'ATOM_INTERNAL_CONSTRUCTOR', (event, processId, routingId, id, args) ->
+ipc.on 'ATOM_BROWSER_CONSTRUCTOR', (event, processId, routingId, id, args) ->
try
args = argsToValues processId, routingId, args
constructor = objectsRegistry.get id
catch e
event.result = type: 'error', value: e.message
-ipc.on 'ATOM_INTERNAL_FUNCTION_CALL', (event, processId, routingId, id, args) ->
+ipc.on 'ATOM_BROWSER_FUNCTION_CALL', (event, processId, routingId, id, args) ->
try
args = argsToValues processId, routingId, args
func = objectsRegistry.get id
catch e
event.result = type: 'error', value: e.message
-ipc.on 'ATOM_INTERNAL_MEMBER_CALL', (event, processId, routingId, id, method, args) ->
+ipc.on 'ATOM_BROWSER_MEMBER_CALL', (event, processId, routingId, id, method, args) ->
try
args = argsToValues processId, routingId, args
obj = objectsRegistry.get id
catch e
event.result = type: 'error', value: e.message
-ipc.on 'ATOM_INTERNAL_MEMBER_SET', (event, processId, routingId, id, name, value) ->
+ipc.on 'ATOM_BROWSER_MEMBER_SET', (event, processId, routingId, id, name, value) ->
try
obj = objectsRegistry.get id
obj[name] = value
catch e
event.result = type: 'error', value: e.message
-ipc.on 'ATOM_INTERNAL_MEMBER_GET', (event, processId, routingId, id, name) ->
+ipc.on 'ATOM_BROWSER_MEMBER_GET', (event, processId, routingId, id, name) ->
try
obj = objectsRegistry.get id
event.result = new Meta(processId, routingId, obj[name])
catch e
event.result = type: 'error', value: e.message
-ipc.on 'ATOM_INTERNAL_REFERENCE', (event, processId, routingId, id) ->
+ipc.on 'ATOM_BROWSER_REFERENCE', (event, processId, routingId, id) ->
try
obj = objectsRegistry.get id
event.result = new Meta(processId, routingId, obj)
catch e
event.result = type: 'error', value: e.message
-ipc.on 'ATOM_INTERNAL_DEREFERENCE', (processId, routingId, storeId) ->
+ipc.on 'ATOM_BROWSER_DEREFERENCE', (processId, routingId, storeId) ->
objectsRegistry.remove processId, routingId, storeId
constructor: ->
if @constructor == RemoteFunction
# Constructor call.
- obj = ipc.sendChannelSync 'ATOM_INTERNAL_CONSTRUCTOR', meta.id, argumentsToMetaList(arguments)
+ obj = ipc.sendChannelSync 'ATOM_BROWSER_CONSTRUCTOR', meta.id, argumentsToMetaList(arguments)
# Returning object in constructor will replace constructed object
# with the returned object.
return metaToValue obj
else
# Function call.
- ret = ipc.sendChannelSync 'ATOM_INTERNAL_FUNCTION_CALL', meta.id, argumentsToMetaList(arguments)
+ ret = ipc.sendChannelSync 'ATOM_BROWSER_FUNCTION_CALL', meta.id, argumentsToMetaList(arguments)
return metaToValue ret
else
ret = v8_util.createObjectWithName meta.name
if member.type is 'function'
ret[member.name] = ->
# Call member function.
- ret = ipc.sendChannelSync 'ATOM_INTERNAL_MEMBER_CALL', meta.id, member.name, argumentsToMetaList(arguments)
+ ret = ipc.sendChannelSync 'ATOM_BROWSER_MEMBER_CALL', meta.id, member.name, argumentsToMetaList(arguments)
metaToValue ret
else
ret.__defineSetter__ member.name, (value) ->
# Set member data.
- ipc.sendChannelSync 'ATOM_INTERNAL_MEMBER_SET', meta.id, member.name, value
+ ipc.sendChannelSync 'ATOM_BROWSER_MEMBER_SET', meta.id, member.name, value
ret.__defineGetter__ member.name, ->
# Get member data.
- ret = ipc.sendChannelSync 'ATOM_INTERNAL_MEMBER_GET', meta.id, member.name
+ ret = ipc.sendChannelSync 'ATOM_BROWSER_MEMBER_GET', meta.id, member.name
metaToValue ret
# Track delegate object's life time, and tell the browser to clean up
# when the object is GCed.
v8_util.setDestructor ret, ->
- ipc.sendChannel 'ATOM_INTERNAL_DEREFERENCE', meta.storeId
+ ipc.sendChannel 'ATOM_BROWSER_DEREFERENCE', meta.storeId
ret
# Browser calls a callback in renderer.
-ipc.on 'ATOM_INTERNAL_FUNCTION_CALL', (callbackId, args) ->
+ipc.on 'ATOM_RENDERER_FUNCTION_CALL', (callbackId, args) ->
callback = callbacksRegistry.get callbackId
callback.apply global, metaToValue(args)
# Browser releases a callback in renderer.
-ipc.on 'ATOM_INTERNAL_DEREFERENCE', (callbackId) ->
+ipc.on 'ATOM_RENDERER_DEREFERENCE', (callbackId) ->
+ console.log callbackId
callbacksRegistry.remove callbackId
# Get remote module.
exports.require = (module) ->
- meta = ipc.sendChannelSync 'ATOM_INTERNAL_REQUIRE', module
+ meta = ipc.sendChannelSync 'ATOM_BROWSER_REQUIRE', module
metaToValue meta
# Get object with specified id.
exports.getObject = (id) ->
- meta = ipc.sendChannelSync 'ATOM_INTERNAL_REFERENCE', id
+ meta = ipc.sendChannelSync 'ATOM_BROWSER_REFERENCE', id
metaToValue meta
# Get current window object.
exports.getCurrentWindow = ->
- meta = ipc.sendChannelSync 'ATOM_INTERNAL_CURRENT_WINDOW'
+ meta = ipc.sendChannelSync 'ATOM_BROWSER_CURRENT_WINDOW'
metaToValue meta