| OLD | NEW |
| 1 #!mojo:js_content_handler | 1 #!mojo:js_content_handler |
| 2 // Demonstrate use of the Mojo network service to load a URL. To run this | 2 // Demonstrate use of the Mojo network service to load a URL. To run this |
| 3 // application with mojo_shell, set DIR to be the absolute path for this | 3 // application with mojo_shell, set DIR to be the absolute path for this |
| 4 // directory, then: | 4 // directory, then: |
| 5 // mojo_shell "file://$DIR/wget.js http://www.google.com" | 5 // mojo_shell "file://$DIR/wget.js http://www.google.com" |
| 6 // Substitute any URL for google.com. To keep the noise down, this app | 6 // Substitute any URL for google.com. To keep the noise down, this app |
| 7 // only displays the number of bytes read and a little http header info. | 7 // only displays the number of bytes read and a little http header info. |
| 8 | 8 |
| 9 define("main", [ | 9 define("main", [ |
| 10 "console", | 10 "console", |
| 11 "mojo/public/js/core", | 11 "mojo/public/js/core", |
| 12 "mojo/services/public/interfaces/network/network_service.mojom", | 12 "mojo/services/network/public/interfaces/network_service.mojom", |
| 13 "mojo/services/public/interfaces/network/url_loader.mojom", | 13 "mojo/services/network/public/interfaces/url_loader.mojom", |
| 14 "mojo/services/public/js/application", | 14 "mojo/services/public/js/application", |
| 15 ], function(console, coreModule, netModule, loaderModule, appModule) { | 15 ], function(console, coreModule, netModule, loaderModule, appModule) { |
| 16 | 16 |
| 17 class WGet extends appModule.Application { | 17 class WGet extends appModule.Application { |
| 18 initialize(args) { | 18 initialize(args) { |
| 19 if (args.length != 2) { | 19 if (args.length != 2) { |
| 20 console.log("Expected URL argument"); | 20 console.log("Expected URL argument"); |
| 21 return; | 21 return; |
| 22 } | 22 } |
| 23 | 23 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 45 }) | 45 }) |
| 46 .then(function() { | 46 .then(function() { |
| 47 app.quit(); | 47 app.quit(); |
| 48 }); | 48 }); |
| 49 }); | 49 }); |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 return WGet; | 53 return WGet; |
| 54 }); | 54 }); |
| OLD | NEW |