| OLD | NEW |
| 1 <import src="/mojo/public/sky/connection.sky" as="connection" /> | 1 <import src="/mojo/public/sky/connection.sky" as="connection" /> |
| 2 <import src="/mojo/public/sky/core.sky" as="core" /> | 2 <import src="/mojo/public/sky/core.sky" as="core" /> |
| 3 <import src="/mojo/public/sky/support.sky" as="support" /> | 3 <import src="/mojo/public/sky/support.sky" as="support" /> |
| 4 <import src="/sky/services/inspector/inspector.mojom.sky" as="inspector" /> | 4 <import src="/sky/services/inspector/inspector.mojom.sky" as="inspector" /> |
| 5 <import src="console-agent.sky" as="ConsoleAgent" /> | 5 <import src="console-agent.sky" as="ConsoleAgent" /> |
| 6 <import src="dom-agent.sky" as="DOMAgent" /> | 6 <import src="dom-agent.sky" as="DOMAgent" /> |
| 7 <import src="page-agent.sky" as="PageAgent" /> | 7 <import src="page-agent.sky" as="PageAgent" /> |
| 8 <import src="worker-agent.sky" as="WorkerAgent" /> | 8 <import src="worker-agent.sky" as="WorkerAgent" /> |
| 9 <import src="runtime-agent.sky" as="RuntimeAgent" /> | 9 <import src="runtime-agent.sky" as="RuntimeAgent" /> |
| 10 <import src="indexeddb-agent.sky" as="IndexedDBAgent" /> | 10 <import src="indexeddb-agent.sky" as="IndexedDBAgent" /> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 CSS: new CSSAgent(domAgent), | 22 CSS: new CSSAgent(domAgent), |
| 23 IndexedDB: new IndexedDBAgent(), | 23 IndexedDB: new IndexedDBAgent(), |
| 24 }; | 24 }; |
| 25 this.missingNames_ = {}; | 25 this.missingNames_ = {}; |
| 26 this.unansweredMessages_ = []; | 26 this.unansweredMessages_ = []; |
| 27 } | 27 } |
| 28 | 28 |
| 29 InspectorBackend.prototype = Object.create( | 29 InspectorBackend.prototype = Object.create( |
| 30 inspector.InspectorBackend.stubClass.prototype); | 30 inspector.InspectorBackend.stubClass.prototype); |
| 31 | 31 |
| 32 InspectorBackend.prototype.IMPLEMENTED_IN_CPP = "IMPLEMENTED_IN_CPP"; |
| 32 InspectorBackend.prototype.ASYNC_RESPONSE = "ASYNC_RESPONSE"; | 33 InspectorBackend.prototype.ASYNC_RESPONSE = "ASYNC_RESPONSE"; |
| 33 InspectorBackend.prototype.MESSAGE_TIMEOUT_MS = 30000; | 34 InspectorBackend.prototype.MESSAGE_TIMEOUT_MS = 30000; |
| 34 | 35 |
| 35 InspectorBackend.prototype.onConnect = function() { | 36 InspectorBackend.prototype.onConnect = function() { |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 InspectorBackend.prototype.onDisconnect = function() { | 39 InspectorBackend.prototype.onDisconnect = function() { |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 InspectorBackend.prototype.logMissing_ = function(name) { | 42 InspectorBackend.prototype.logMissing_ = function(name) { |
| 42 if (name in this.missingNames_) | 43 if (name in this.missingNames_) |
| 43 return; | 44 return; |
| 44 this.missingNames_[name] = true; | 45 this.missingNames_[name] = true; |
| 45 console.log("InspectorBackend missing " + name); | 46 console.log("InspectorBackend missing " + name); |
| 46 } | 47 } |
| 47 | 48 |
| 48 InspectorBackend.prototype.dispatch_ = function(descriptor, params, message_id)
{ | 49 InspectorBackend.prototype.dispatch_ = function(descriptor, params, message_id)
{ |
| 49 var parsed = descriptor.split('.'); | 50 var parsed = descriptor.split('.'); |
| 50 | 51 |
| 51 var agentName = parsed[0]; | 52 var agentName = parsed[0]; |
| 52 var methodName = parsed[1]; | 53 var methodName = parsed[1]; |
| 53 | 54 |
| 54 // Debugger is implemented in c++. | 55 // Debugger is implemented in c++. |
| 55 if (agentName == "Debugger") | 56 if (agentName == "Debugger") |
| 56 return; | 57 return this.IMPLEMENTED_IN_CPP; |
| 57 | 58 |
| 58 if (!(agentName in this.agents)) { | 59 if (!(agentName in this.agents)) { |
| 59 this.logMissing_(agentName); | 60 this.logMissing_(agentName); |
| 60 return {}; | 61 return {}; |
| 61 } | 62 } |
| 62 | 63 |
| 63 var agent = this.agents[agentName]; | 64 var agent = this.agents[agentName]; |
| 64 | 65 |
| 65 if (!(methodName in agent)) { | 66 if (!(methodName in agent)) { |
| 66 this.logMissing_(descriptor); | 67 this.logMissing_(descriptor); |
| 67 return {}; | 68 return {}; |
| 68 } | 69 } |
| 69 | 70 |
| 70 try { | 71 try { |
| 71 return agent[methodName](params, message_id); | 72 return agent[methodName](params, message_id); |
| 72 } catch(ex) { | 73 } catch(ex) { |
| 73 console.log(descriptor + ": " + ex); | 74 console.log(descriptor + ": " + ex); |
| 74 } | 75 } |
| 75 }; | 76 }; |
| 76 | 77 |
| 77 InspectorBackend.prototype.onMessage = function(data) { | 78 InspectorBackend.prototype.onMessage = function(data) { |
| 78 var message = JSON.parse(data); | 79 var message = JSON.parse(data); |
| 79 var result = this.dispatch_(message.method, message.params, message.id); | 80 var result = this.dispatch_(message.method, message.params, message.id); |
| 81 if (result === this.IMPLEMENTED_IN_CPP) |
| 82 return; |
| 80 this.unansweredMessages_.push(message.id); | 83 this.unansweredMessages_.push(message.id); |
| 81 // FIXME: This magic return value is kinda hacky. | 84 // FIXME: This magic return value is kinda hacky. |
| 82 if (result != this.ASYNC_RESPONSE) | 85 if (result != this.ASYNC_RESPONSE) |
| 83 this.sendResponse(message.id, result); | 86 this.sendResponse(message.id, result); |
| 84 else { | 87 else { |
| 85 window.setTimeout(function() { | 88 window.setTimeout(function() { |
| 86 if (this.unansweredMessages_.indexOf(message.id) == -1) | 89 if (this.unansweredMessages_.indexOf(message.id) == -1) |
| 87 return; | 90 return; |
| 88 console.log("Error, failed to reply to message id " + message.id); | 91 console.log("Error, failed to reply to message id " + message.id); |
| 89 }.bind(this), this.MESSAGE_TIMEOUT_MS); | 92 }.bind(this), this.MESSAGE_TIMEOUT_MS); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 114 | 117 |
| 115 var frontendHandle = internals.connectToService( | 118 var frontendHandle = internals.connectToService( |
| 116 "mojo:sky_inspector_server", inspector.InspectorFrontend.name); | 119 "mojo:sky_inspector_server", inspector.InspectorFrontend.name); |
| 117 window.frontendConnection = new connection.Connection( | 120 window.frontendConnection = new connection.Connection( |
| 118 frontendHandle, | 121 frontendHandle, |
| 119 InspectorBackend, | 122 InspectorBackend, |
| 120 inspector.InspectorFrontend.proxyClass); | 123 inspector.InspectorFrontend.proxyClass); |
| 121 | 124 |
| 122 window.frontend = frontendConnection.remote; | 125 window.frontend = frontendConnection.remote; |
| 123 </script> | 126 </script> |
| OLD | NEW |