| OLD | NEW |
| 1 #!mojo mojo:js_content_handler | 1 #!mojo mojo:js_content_handler |
| 2 // Copyright 2014 The Chromium Authors. All rights reserved. | 2 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 5 | 5 |
| 6 // Demonstrate use of the Mojo network service to load a URL. To run this | 6 // Demonstrate use of the Mojo network service to load a URL. To run this |
| 7 // application with mojo_shell, set DIR to be the absolute path for this | 7 // application with mojo_shell, set DIR to be the absolute path for this |
| 8 // directory, then: | 8 // directory, then: |
| 9 // mojo_shell "file://$DIR/wget.js http://www.google.com" | 9 // mojo_shell "file://$DIR/wget.js http://www.google.com" |
| 10 // Substitute any URL for google.com. To keep the noise down, this app | 10 // Substitute any URL for google.com. To keep the noise down, this app |
| 11 // only displays the number of bytes read and a little http header info. | 11 // only displays the number of bytes read and a little http header info. |
| 12 | 12 |
| 13 define("main", [ | 13 define("main", [ |
| 14 "console", | 14 "console", |
| 15 "mojo/services/public/js/application", | 15 "mojo/services/public/js/application", |
| 16 "mojo/public/js/core", | 16 "mojo/public/js/core", |
| 17 "mojo/services/network/public/interfaces/network_service.mojom", | 17 "mojo/services/network/interfaces/network_service.mojom", |
| 18 "mojo/public/interfaces/network/url_request.mojom", | 18 "mojo/public/interfaces/network/url_request.mojom", |
| 19 ], function(console, application, core, network, request) { | 19 ], function(console, application, core, network, request) { |
| 20 | 20 |
| 21 const Application = application.Application; | 21 const Application = application.Application; |
| 22 const NetworkService = network.NetworkService; | 22 const NetworkService = network.NetworkService; |
| 23 const URLRequest = request.URLRequest; | 23 const URLRequest = request.URLRequest; |
| 24 | 24 |
| 25 class WGet extends Application { | 25 class WGet extends Application { |
| 26 initialize(args) { | 26 initialize(args) { |
| 27 if (args.length != 2) { | 27 if (args.length != 2) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 57 app.quit(); | 57 app.quit(); |
| 58 }); | 58 }); |
| 59 }).catch(function(e) { | 59 }).catch(function(e) { |
| 60 console.log("URLLoader start() failed: " + e.stack); | 60 console.log("URLLoader start() failed: " + e.stack); |
| 61 }); | 61 }); |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 return WGet; | 65 return WGet; |
| 66 }); | 66 }); |
| OLD | NEW |