OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 class _FileInputStream extends _BaseDataInputStream implements InputStream { | 5 class _FileInputStream extends _BaseDataInputStream implements InputStream { |
6 _FileInputStream(String name) { | 6 _FileInputStream(String name) { |
7 _file = new File(name); | 7 _file = new File(name); |
8 _data = []; | 8 _data = []; |
9 _position = 0; | 9 _position = 0; |
10 _file.onError = (String s) { | 10 _file.onError = (String s) { |
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 | 1014 |
1015 String get name() => _name; | 1015 String get name() => _name; |
1016 | 1016 |
1017 void set onError(void handler(String error)) { | 1017 void set onError(void handler(String error)) { |
1018 _onError = handler; | 1018 _onError = handler; |
1019 } | 1019 } |
1020 | 1020 |
1021 void set onNoPendingWrites(void handler()) { | 1021 void set onNoPendingWrites(void handler()) { |
1022 _onNoPendingWrites = handler; | 1022 _onNoPendingWrites = handler; |
1023 if (_pendingWrites == 0) { | 1023 if (_pendingWrites == 0) { |
1024 _noPendingWriteTimer = new Timer((t) { | 1024 _noPendingWriteTimer = new Timer(0, (t) { |
1025 if (_onNoPendingWrites != null) _onNoPendingWrites(); | 1025 if (_onNoPendingWrites != null) _onNoPendingWrites(); |
1026 }, 0); | 1026 }); |
1027 } | 1027 } |
1028 } | 1028 } |
1029 | 1029 |
1030 void _ensureFileService() { | 1030 void _ensureFileService() { |
1031 if (_fileService == null) { | 1031 if (_fileService == null) { |
1032 _fileService = _FileUtils.newServicePort(); | 1032 _fileService = _FileUtils.newServicePort(); |
1033 } | 1033 } |
1034 } | 1034 } |
1035 | 1035 |
1036 void _writeEnqueued() { | 1036 void _writeEnqueued() { |
(...skipping 17 matching lines...) Expand all Loading... |
1054 bool _asyncUsed; | 1054 bool _asyncUsed; |
1055 int _pendingWrites = 0; | 1055 int _pendingWrites = 0; |
1056 | 1056 |
1057 SendPort _fileService; | 1057 SendPort _fileService; |
1058 | 1058 |
1059 Timer _noPendingWriteTimer; | 1059 Timer _noPendingWriteTimer; |
1060 | 1060 |
1061 Function _onNoPendingWrites; | 1061 Function _onNoPendingWrites; |
1062 Function _onError; | 1062 Function _onError; |
1063 } | 1063 } |
OLD | NEW |