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

Side by Side Diff: runtime/bin/stream_util.dart

Issue 10173024: Change the error handling in dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | « runtime/bin/socket_stream_impl.dart ('k') | runtime/bin/string_stream.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) 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 _BaseDataInputStream { 5 class _BaseDataInputStream {
6 abstract int available(); 6 abstract int available();
7 7
8 List<int> read([int len]) { 8 List<int> read([int len]) {
9 if (_closeCallbackCalled) return null; 9 if (_closeCallbackCalled) return null;
10 int bytesToRead = available(); 10 int bytesToRead = available();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 void set onData(void callback()) { 46 void set onData(void callback()) {
47 _clientDataHandler = callback; 47 _clientDataHandler = callback;
48 _checkScheduleCallbacks(); 48 _checkScheduleCallbacks();
49 } 49 }
50 50
51 void set onClosed(void callback()) { 51 void set onClosed(void callback()) {
52 _clientCloseHandler = callback; 52 _clientCloseHandler = callback;
53 _checkScheduleCallbacks(); 53 _checkScheduleCallbacks();
54 } 54 }
55 55
56 void set onError(void callback(Exception e)) { 56 void set onError(void callback(e)) {
57 _clientErrorHandler = callback; 57 _clientErrorHandler = callback;
58 } 58 }
59 59
60 abstract List<int> _read(int bytesToRead); 60 abstract List<int> _read(int bytesToRead);
61 61
62 void _dataReceived() { 62 void _dataReceived() {
63 // More data has been received asynchronously. Perform the data 63 // More data has been received asynchronously. Perform the data
64 // handler callback now. 64 // handler callback now.
65 _cancelScheduledDataCallback(); 65 _cancelScheduledDataCallback();
66 if (_clientDataHandler !== null) { 66 if (_clientDataHandler !== null) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 class _BaseOutputStream { 179 class _BaseOutputStream {
180 bool writeString(String string, [Encoding encoding = Encoding.UTF_8]) { 180 bool writeString(String string, [Encoding encoding = Encoding.UTF_8]) {
181 if (string.length > 0) { 181 if (string.length > 0) {
182 // Encode and write data. 182 // Encode and write data.
183 _StringEncoder encoder = _StringEncoders.encoder(encoding); 183 _StringEncoder encoder = _StringEncoders.encoder(encoding);
184 List<int> data = encoder.encodeString(string); 184 List<int> data = encoder.encodeString(string);
185 return write(data, copyBuffer: false); 185 return write(data, copyBuffer: false);
186 } 186 }
187 return true; 187 return true;
188 } 188 }
189
190 void set onError(void callback(e)) {
191 _onError = callback;
192 }
193
194 void _reportError(e) {
195 if (_onError != null) {
196 _onError(e);
197 } else {
198 throw e;
199 }
200 }
201
202 Function _onError;
189 } 203 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_stream_impl.dart ('k') | runtime/bin/string_stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698