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

Side by Side Diff: sdk/lib/io/file_impl.dart

Issue 14057010: Re-write _BufferList to keep an internal Uint8List buffer, that will grow on demand. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix comment Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/buffer_list.dart ('k') | sdk/lib/io/websocket_impl.dart » ('j') | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.io; 5 part of dart.io;
6 6
7 // Read the file in blocks of size 64k. 7 // Read the file in blocks of size 64k.
8 const int _BLOCK_SIZE = 64 * 1024; 8 const int _BLOCK_SIZE = 64 * 1024;
9 9
10 10
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 return new IOSink(consumer, encoding: encoding); 471 return new IOSink(consumer, encoding: encoding);
472 } 472 }
473 473
474 Future<List<int>> readAsBytes() { 474 Future<List<int>> readAsBytes() {
475 _ensureFileService(); 475 _ensureFileService();
476 Completer<List<int>> completer = new Completer<List<int>>(); 476 Completer<List<int>> completer = new Completer<List<int>>();
477 var chunks = new _BufferList(); 477 var chunks = new _BufferList();
478 openRead().listen( 478 openRead().listen(
479 (d) => chunks.add(d), 479 (d) => chunks.add(d),
480 onDone: () { 480 onDone: () {
481 var result = chunks.readBytes(chunks.length); 481 var result = chunks.readBytes();
482 if (result == null) result = <int>[];
483 completer.complete(result); 482 completer.complete(result);
484 }, 483 },
485 onError: (e) { 484 onError: (e) {
486 completer.completeError(e); 485 completer.completeError(e);
487 }, 486 },
488 cancelOnError: true); 487 cancelOnError: true);
489 return completer.future; 488 return completer.future;
490 } 489 }
491 490
492 List<int> readAsBytesSync() { 491 List<int> readAsBytesSync() {
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 new FileIOException("File closed '$_path'")); 1037 new FileIOException("File closed '$_path'"));
1039 }); 1038 });
1040 return completer.future; 1039 return completer.future;
1041 } 1040 }
1042 1041
1043 final String _path; 1042 final String _path;
1044 int _id; 1043 int _id;
1045 1044
1046 SendPort _fileService; 1045 SendPort _fileService;
1047 } 1046 }
OLDNEW
« no previous file with comments | « sdk/lib/io/buffer_list.dart ('k') | sdk/lib/io/websocket_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698