Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
sql support basically working
  • Loading branch information
pmuellr committed Jul 20, 2011
1 parent 8b383b5 commit b9426fa702c1adbbce5c2a572f5ffae26ee1701f
Showing 13 changed files with 233 additions and 49 deletions.
@@ -290,10 +290,12 @@
<delete dir="${CACHED}/json-idl"/>
<mkdir dir="${CACHED}/json-idl"/>

<simple-idl2json name="WeinreClientCommands" oDir="${CACHED}/json-idl" iDir="../${PROJECT_SERVER}/interfaces"/>
<simple-idl2json name="WeinreClientEvents" oDir="${CACHED}/json-idl" iDir="../${PROJECT_SERVER}/interfaces"/>
<simple-idl2json name="WeinreTargetCommands" oDir="${CACHED}/json-idl" iDir="../${PROJECT_SERVER}/interfaces"/>
<simple-idl2json name="WeinreTargetEvents" oDir="${CACHED}/json-idl" iDir="../${PROJECT_SERVER}/interfaces"/>
<simple-idl2json name="WeinreClientCommands" oDir="${CACHED}/json-idl" iDir="../${PROJECT_SERVER}/interfaces"/>
<simple-idl2json name="WeinreClientEvents" oDir="${CACHED}/json-idl" iDir="../${PROJECT_SERVER}/interfaces"/>
<simple-idl2json name="WeinreTargetCommands" oDir="${CACHED}/json-idl" iDir="../${PROJECT_SERVER}/interfaces"/>
<simple-idl2json name="WeinreTargetEvents" oDir="${CACHED}/json-idl" iDir="../${PROJECT_SERVER}/interfaces"/>
<simple-idl2json name="WeinreExtraClientCommands" oDir="${CACHED}/json-idl" iDir="../${PROJECT_SERVER}/interfaces"/>
<simple-idl2json name="WeinreExtraTargetEvents" oDir="${CACHED}/json-idl" iDir="../${PROJECT_SERVER}/interfaces"/>

<simple-idl2json name="InjectedScriptHost" oDir="${CACHED}/json-idl" iDir="${VENDOR}/webkit/WebCore/inspector"/>

@@ -14,7 +14,7 @@ module weinre {

void getTargets(out Object[] targets);
void getClients(out Object[] clients);

void connectTarget(in string clientId, in string targetId);
void disconnectTarget(in string clientId);

@@ -0,0 +1,17 @@
/*
* 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) 2011 IBM Corporation
*/

// extra messages from the client to the target

module weinre {
interface WeinreExtraClientCommands {

void getDatabases(out Object[] databaseRecords);

};
}

@@ -0,0 +1,17 @@
/*
* 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) 2011 IBM Corporation
*/

// extra messages from the target to the client

module weinre {
interface WeinreExtraTargetEvents {

void databaseOpened(in Object databaseRecord);

};
}

@@ -14,7 +14,7 @@ module weinre {
void connectionDestroyed(string clientId, string targetId);

void sendCallback(string callbackId, Object result);

};
}

@@ -43,6 +43,7 @@
<script src="/weinre/target/InjectedScript.js"></script>
<script src="/weinre/target/Timeline.transportd.js"></script>
<script src="/weinre/target/SqlStepper.transportd.js"></script>
<script src="/weinre/target/WeinreExtraClientCommandsImpl.transportd.js"></script>
<script src="/interfaces/all-json-idls-min.js"></script>

<script type="text/javascript">
@@ -44,7 +44,7 @@ function onLoad() {
outputElement.innerHTML = ""
})

setTimeout(_openDatabase,1000)
openTheDatabase()
}

//------------------------------------------------------------------------------
@@ -134,9 +134,9 @@ function createDatabase(tx) {
}

//------------------------------------------------------------------------------
function _openDatabase() {
function openTheDatabase() {
if (window.openDatabase) {
db = window.openDatabase("clicks", "1.0", "clicks", 8192)
db = window.openDatabase("clicks_db", "1.0", "clicks", 8192)
db.transaction(createDatabase)
}
}
@@ -18,6 +18,7 @@ requireClass ../common/IDGenerator
requireClass ./InspectorBackendImpl
requireClass ./InspectorFrontendHostImpl
requireClass ./WeinreClientEventsImpl
requireClass ./WeinreExtraTargetEventsImpl
requireClass ./RemotePanel

//-----------------------------------------------------------------------------
@@ -47,7 +48,10 @@ method initialize

// create the client commands proxy
Weinre.WeinreClientCommands = messageDispatcher.createProxy("WeinreClientCommands")
Weinre.WeinreExtraClientCommands = messageDispatcher.createProxy("WeinreExtraClientCommands")

messageDispatcher.registerInterface("WeinreExtraTargetEvents", new WeinreExtraTargetEventsImpl(), false)

// register WebInspector interface
messageDispatcher.registerInterface("WebInspector", WebInspector, false)

@@ -9,6 +9,8 @@
requireClass ../common/Callback
requireClass ../common/Weinre

requireClass ./WeinreExtraTargetEventsImpl

//-----------------------------------------------------------------------------
class WeinreClientEventsImpl(client)
this.client = client
@@ -67,6 +69,10 @@ method connectionCreated(/*int*/ clientChannel, /*int*/ targetChannel)

WebInspector.inspectedURLChanged(target.url)

Weinre.WeinreExtraClientCommands.getDatabases(function(databaseRecords) {
WeinreExtraTargetEventsImpl.addDatabaseRecords(databaseRecords)
})

//-----------------------------------------------------------------------------
method connectionDestroyed(/*int*/ clientChannel, /*int*/ targetChannel)

@@ -0,0 +1,48 @@

/*
* 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) 2011 IBM Corporation
*/

//-----------------------------------------------------------------------------
class WeinreExtraTargetEventsImpl

//-----------------------------------------------------------------------------
method databaseOpened(databaseRecord)
WeinreExtraTargetEventsImpl.addDatabaseRecords([databaseRecord])

//-----------------------------------------------------------------------------
static method addDatabaseRecords(databaseRecords)
// databaseRecord.id
// databaseRecord.domain
// databaseRecord.name
// databaseRecord.version

if (!WebInspector.panels) return
if (!WebInspector.panels.resources) return
if (!WebInspector.panels.resources._databases) return

var existingDbs = WebInspector.panels.resources._databases
var existingDbNames = {}

for (var i=0; i<existingDbs.length; i++) {
existingDbNames[existingDbs[i].name] = existingDbs[i]
}

for (var i=0; i<databaseRecords.length; i++) {
if (existingDbNames[databaseRecords[i].name]) continue

var databaseRecord = databaseRecords[i]
var database = new WebInspector.Database(
databaseRecord.id,
databaseRecord.domain,
databaseRecord.name,
databaseRecord.version
)

WebInspector.panels.resources.addDatabase(database)
}


@@ -21,6 +21,7 @@ requireClass ./ElementHighlighter
requireClass ./InjectedScriptHostImpl

requireClass ./WeinreTargetEventsImpl
requireClass ./WeinreExtraClientCommandsImpl

requireClass ./WiConsoleImpl
requireClass ./WiCSSImpl
@@ -45,15 +46,16 @@ static method main
}

//------------------------------------------------------------------------------
method setWeinreServerURLFromScriptSrc()
method setWeinreServerURLFromScriptSrc(element)
if (window.WeinreServerURL) return

var element = this.getTargetScriptElement()
var pattern = /(http:\/\/(.*?)\/)/
var match = pattern.exec(element.src)
if (match) {
window.WeinreServerURL = match[1]
return
if (element) {
var pattern = /(http:\/\/(.*?)\/)/
var match = pattern.exec(element.src)
if (match) {
window.WeinreServerURL = match[1]
return
}
}

var message = "unable to calculate the weinre server url; explicity set the variable window.WeinreServerURL instead"
@@ -62,14 +64,25 @@ method setWeinreServerURLFromScriptSrc()


//-----------------------------------------------------------------------------
method setWeinreServerIdFromScriptSrc()
method setWeinreServerIdFromScriptSrc(element)
if (window.WeinreServerId) return

var element = this.getTargetScriptElement()

var hash = element.src.split("#")[1]
if (!hash) hash = "anonymous"

var hash = "anonymous"
if (element) {
var attempt = element.src.split("#")[1]
if (attempt) {
hash = attempt
}
else {
attempt = location.hash.split("#")[1]
if (attempt) {
hash = attempt
}
}
}

window.WeinreServerId = hash

//-----------------------------------------------------------------------------
@@ -92,8 +105,9 @@ method getTargetScriptElement
method initialize()
var self = this

this.setWeinreServerURLFromScriptSrc()
this.setWeinreServerIdFromScriptSrc()
var element = this.getTargetScriptElement()
this.setWeinreServerURLFromScriptSrc(element)
this.setWeinreServerIdFromScriptSrc(element)

if (window.WeinreServerURL[window.WeinreServerURL.length-1] != "/") {
window.WeinreServerURL += "/"
@@ -121,13 +135,13 @@ method initialize()

Weinre.wi = {}

Weinre.wi.Console = new WiConsoleImpl()
Weinre.wi.CSS = new WiCSSImpl()
Weinre.wi.Database = new WiDatabaseImpl()
Weinre.wi.DOM = new WiDOMImpl()
Weinre.wi.DOMStorage = new WiDOMStorageImpl()
Weinre.wi.Inspector = new WiInspectorImpl()
Weinre.wi.Runtime = new WiRuntimeImpl()
Weinre.wi.Console = new WiConsoleImpl()
Weinre.wi.CSS = new WiCSSImpl()
Weinre.wi.Database = new WiDatabaseImpl()
Weinre.wi.DOM = new WiDOMImpl()
Weinre.wi.DOMStorage = new WiDOMStorageImpl()
Weinre.wi.Inspector = new WiInspectorImpl()
Weinre.wi.Runtime = new WiRuntimeImpl()

messageDispatcher.registerInterface("Console", Weinre.wi.Console , false)
messageDispatcher.registerInterface("CSS", Weinre.wi.CSS , false)
@@ -136,8 +150,9 @@ method initialize()
messageDispatcher.registerInterface("DOMStorage", Weinre.wi.DOMStorage , false)
messageDispatcher.registerInterface("Inspector", Weinre.wi.Inspector , false)
messageDispatcher.registerInterface("Runtime", Weinre.wi.Runtime , false)

messageDispatcher.registerInterface("WeinreTargetEvents", new WeinreTargetEventsImpl(), true)

messageDispatcher.registerInterface("WeinreExtraClientCommands", new WeinreExtraClientCommandsImpl() , true)
messageDispatcher.registerInterface("WeinreTargetEvents", new WeinreTargetEventsImpl(), true)

Weinre.wi.ApplicationCacheNotify = messageDispatcher.createProxy("ApplicationCacheNotify")
Weinre.wi.ConsoleNotify = messageDispatcher.createProxy("ConsoleNotify")
@@ -147,7 +162,8 @@ method initialize()
Weinre.wi.InspectorNotify = messageDispatcher.createProxy("InspectorNotify")
Weinre.wi.TimelineNotify = messageDispatcher.createProxy("TimelineNotify")

Weinre.WeinreTargetCommands = messageDispatcher.createProxy("WeinreTargetCommands")
Weinre.WeinreTargetCommands = messageDispatcher.createProxy("WeinreTargetCommands")
Weinre.WeinreExtraTargetEvents = messageDispatcher.createProxy("WeinreExtraTargetEvents")

messageDispatcher.getWebSocket().addEventListener("open", Binding(this, this.cb_webSocketOpened))

@@ -0,0 +1,24 @@

/*
* 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
*/

requireClass ../common/Weinre

requireClass ./WiDatabaseImpl
requireClass ./Console

//-----------------------------------------------------------------------------
class WeinreExtraClientCommandsImpl

//-----------------------------------------------------------------------------
method getDatabases(callback)
if (!callback) return

var result = WiDatabaseImpl.getDatabases()

Weinre.WeinreTargetCommands.sendClientCallback(callback, [result])

0 comments on commit b9426fa

Please sign in to comment.