Mojo JS Bindings: merge Application, Shell, ServiceProvider with Sky

Enable Sky applications to be written in terms of the Application,
Shell, ServiceProvider classes.

Add a shellProxyHandle() method to the Sky Internals class. It returns
a message pipe handle that the JS Shell class will assume ownership of.

BUG=
R=abarth@chromium.org

Review URL: https://codereview.chromium.org/837283002
This commit is contained in:
Hans Muller 2015-01-08 09:24:30 -08:00
parent 619808fe2f
commit 5233793bd5
2 changed files with 22 additions and 13 deletions

View File

@ -5,28 +5,26 @@
<import src="/mojo/public/sky/connection.sky" as="connection" /> <import src="/mojo/public/sky/connection.sky" as="connection" />
<import src="/mojo/services/network/public/interfaces/network_service.mojom.sky" as="net" /> <import src="/mojo/services/network/public/interfaces/network_service.mojom.sky" as="net" />
<import src="/mojo/services/network/public/interfaces/url_loader.mojom.sky" as="loader" /> <import src="/mojo/services/network/public/interfaces/url_loader.mojom.sky" as="loader" />
<import src="/mojo/services/public/sky/application.sky" as="application" />
<script> <script>
describe('Mojo network_service', function() { describe('Mojo network_service', function() {
this.enableTimeouts(false); this.enableTimeouts(false);
it('should be able to fetch text files', function(done) { it('should be able to fetch text files', function(done) {
var netServiceHandle = internals.connectToService( var app = new application.Application(internals.passShellProxyHandle());
"mojo:network_service", "mojo::NetworkService"); var netService = app.shell.connectToService(
var netConnection = new connection.Connection( "mojo:network_service", net.NetworkService);
netServiceHandle,
net.NetworkService.stubClass, var urlLoader;
net.NetworkService.proxyClass); netService.createURLLoader(function(urlLoaderProxy) {
var urlLoaderPipe = new core.createMessagePipe(); urlLoader = urlLoaderProxy;
netConnection.remote.createURLLoader(urlLoaderPipe.handle1); });
var urlLoaderConnection = new connection.Connection(
urlLoaderPipe.handle0,
loader.URLLoader.stubClass,
loader.URLLoader.proxyClass);
var urlRequest = new loader.URLRequest(); var urlRequest = new loader.URLRequest();
urlRequest.url = "http://127.0.0.1:8000/sky/tests/services/resources/pass.txt"; urlRequest.url = "http://127.0.0.1:8000/sky/tests/services/resources/pass.txt";
urlRequest.method = "GET"; urlRequest.method = "GET";
urlRequest.auto_follow_redirects = true; urlRequest.auto_follow_redirects = true;
var urlRequestPromise = urlLoaderConnection.remote.start(urlRequest); var urlRequestPromise = urlLoader.start(urlRequest);
urlRequestPromise.then(function(result) { urlRequestPromise.then(function(result) {
console.log("url => " + result.response["url"]); console.log("url => " + result.response["url"]);
console.log("status_line => " + result.response["status_line"]); console.log("status_line => " + result.response["status_line"]);

View File

@ -54,6 +54,8 @@ class SkyDebugger(object):
parser.add_argument('--use-osmesa', action='store_true', parser.add_argument('--use-osmesa', action='store_true',
default=self._in_chromoting()) default=self._in_chromoting())
parser.add_argument('url_or_path', nargs='?', type=str) parser.add_argument('url_or_path', nargs='?', type=str)
parser.add_argument('--show-command', action='store_true',
help='Display the shell command and exit')
configuration.add_arguments(parser) configuration.add_arguments(parser)
args = parser.parse_args() args = parser.parse_args()
@ -89,6 +91,15 @@ class SkyDebugger(object):
subprocess.check_call(shell_command) subprocess.check_call(shell_command)
else: else:
subprocess.check_call(shell_command) subprocess.check_call(shell_command)
if args.show_command:
print " ".join(shell_command)
else:
subprocess.check_call(shell_command)
def shutdown(self):
print "Quitting"
if self._sky_server:
self._sky_server.terminate()
if __name__ == '__main__': if __name__ == '__main__':