blob: 7d7d51697b4afafbefb284bfe4719b95d4ea5ad4 [file] [log] [blame]
/*
* weinre is available under *either* the terms of the modified BSD license *or* the
* MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
*
* Copyright (c) 2010, 2011 IBM Corporation
*/
require ../common/Ex
require ../common/IDLTools
require ../common/Socket
require ../common/Weinre
//-----------------------------------------------------------------------------
class InspectorBackendImpl
this.registeredDomainDispatchers = {}
Socket.setInspectorBackend(this)
//-----------------------------------------------------------------------------
static method setupProxies
var intfNames = [
"ApplicationCache",
"BrowserDebugger",
"CSS",
"Console",
"DOM",
"DOMStorage",
"Database",
"Debugger",
"FileSystem",
"InjectedScript",
"Inspector",
"Network",
"Profiler",
"Runtime"
]
intfNames.forEach(function(intfName) {
var proxy = Weinre.webSocket.createProxy(intfName)
var intf = IDLTools.getIDL(intfName)
if (!intf) {
throw new Ex(arguments, "interface not registered: '" + intfName + "'")
}
intf.methods.forEach(function(method) {
var proxyMethod = InspectorBackendImpl.getProxyMethod(proxy, method)
InspectorBackendImpl.prototype[method.name] = proxyMethod
})
})
//-----------------------------------------------------------------------------
static method getProxyMethod(proxy, method)
return function() {
return proxy[method.name].apply(proxy, arguments)
}
//-----------------------------------------------------------------------------
method registerDomainDispatcher(name, intf)
this.registeredDomainDispatchers[name] = intf
//-----------------------------------------------------------------------------
method getRegisteredDomainDispatcher(name)
return this.registeredDomainDispatchers[name]