blob: 56f6b1e3ea2352520c1a7cfa769447716f335644 [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/Weinre
//-----------------------------------------------------------------------------
class InspectorBackendImpl
this.registeredDomainDispatchers = {}
//-----------------------------------------------------------------------------
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("Wi" + intfName)
var intf = IDLTools.getIDL("Wi" + 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)
if (this.registeredDomainDispatchers[name]) {
throw new Ex(arguments, "domain dispatcher already registered for '" + name + "'")
}
this.registeredDomainDispatchers[name] = intf
//-----------------------------------------------------------------------------
method getRegisteredDomainDispatchers
return this.registeredDomainDispatchers
registerInterface(intfName, intf, validate)