OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Run with, e.g.: | 5 // Run with, e.g.: |
6 // mojo_shell "mojo:dart_wget http://www.google.com" | 6 // mojo_shell "mojo:dart_wget http://www.google.com" |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:typed_data'; | 9 import 'dart:typed_data'; |
10 import 'mojo:application'; | 10 import 'mojo:application'; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 var urlResponse = await _urlLoaderProxy.start(urlRequest); | 48 var urlResponse = await _urlLoaderProxy.start(urlRequest); |
49 print(">>> Headers <<<"); | 49 print(">>> Headers <<<"); |
50 print(urlResponse.response.headers.join('\n')); | 50 print(urlResponse.response.headers.join('\n')); |
51 | 51 |
52 return DataPipeDrainer.drainHandle(urlResponse.response.body); | 52 return DataPipeDrainer.drainHandle(urlResponse.response.body); |
53 } | 53 } |
54 | 54 |
55 void _initProxiesIfNeeded() { | 55 void _initProxiesIfNeeded() { |
56 if (_networkService == null) { | 56 if (_networkService == null) { |
57 _networkService = new NetworkServiceProxy.unbound(); | 57 _networkService = new NetworkServiceProxy.unbound(); |
58 connectToService("mojo:network_service", _networkService); | 58 connectToService( |
| 59 "mojo:network_service", NetworkServiceRequest(_networkService)); |
59 } | 60 } |
60 if (_urlLoaderProxy == null) { | 61 if (_urlLoaderProxy == null) { |
61 _urlLoaderProxy = new UrlLoaderProxy.unbound(); | 62 _urlLoaderProxy = new UrlLoaderProxy.unbound(); |
62 _networkService.createUrlLoader(_urlLoaderProxy); | 63 _networkService.createUrlLoader(UrlLoaderRequest(_urlLoaderProxy)); |
63 } | 64 } |
64 } | 65 } |
65 | 66 |
66 void _closeProxies() { | 67 void _closeProxies() { |
67 _urlLoaderProxy.close(); | 68 UrlLoaderProxyClose(_urlLoaderProxy); |
68 _networkService.close(); | 69 NetworkServiceProxyClose(_networkService); |
69 _urlLoaderProxy = null; | 70 _urlLoaderProxy = null; |
70 _networkService = null; | 71 _networkService = null; |
71 } | 72 } |
72 } | 73 } |
73 | 74 |
74 main(List args) { | 75 main(List args) { |
75 MojoHandle appHandle = new MojoHandle(args[0]); | 76 MojoHandle appHandle = new MojoHandle(args[0]); |
76 var wget = new WGet.fromHandle(appHandle); | 77 new WGet.fromHandle(appHandle); |
77 wget.listen(); | |
78 } | 78 } |
OLD | NEW |