Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: lib/src/io_html.dart

Issue 2353933002: Use configurable imports to avoid having two versions of everything. (Closed)
Patch Set: Remove more warnings. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "dart:async" show Future, Stream; 5 import "dart:async" show Future, Stream;
6 import "dart:convert" show Encoding, LATIN1, UTF8; 6 import "dart:convert" show Encoding;
7 import "dart:html"; 7 import "dart:html";
8 import "dart:typed_data" show Uint8List, ByteBuffer; 8 import "dart:typed_data" show ByteBuffer;
9 9
10 /// Reads the bytes of a URI as a stream of bytes. 10 /// Reads the bytes of a URI as a stream of bytes.
11 Stream<List<int>> readAsStream(Uri uri) async* { 11 Stream<List<int>> readAsStream(Uri uri) async* {
12 // TODO(lrn): Should file be run through XmlHTTPRequest too? 12 // TODO(lrn): Should file be run through XmlHTTPRequest too?
13 if (uri.scheme == "http" || uri.scheme == "https") { 13 if (uri.scheme == "http" || uri.scheme == "https") {
14 // TODO: Stream in chunks if DOM has a way to do so. 14 // TODO: Stream in chunks if DOM has a way to do so.
15 List<int> response = await _httpGetBytes(uri); 15 List<int> response = await _httpGetBytes(uri);
16 yield response; 16 yield response;
17 return; 17 return;
18 } 18 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 Future<List<int>> _httpGetBytes(Uri uri) { 53 Future<List<int>> _httpGetBytes(Uri uri) {
54 return HttpRequest 54 return HttpRequest
55 .request(uri.toString(), responseType: "arraybuffer") 55 .request(uri.toString(), responseType: "arraybuffer")
56 .then((request) { 56 .then((request) {
57 ByteBuffer data = request.response; 57 ByteBuffer data = request.response;
58 return data.asUint8List(); 58 return data.asUint8List();
59 }); 59 });
60 } 60 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698