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

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

Issue 124753002: Code cleanup (mostly io lib and some http lib). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head. Created 6 years, 11 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
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 /** 7 /**
8 * Helper class to wrap a [StreamConsumer<List<int>>] and provide 8 * Helper class to wrap a [StreamConsumer<List<int>>] and provide
9 * utility functions for writing to the StreamConsumer directly. The 9 * utility functions for writing to the StreamConsumer directly. The
10 * [IOSink] buffers the input given by all [StringSink] methods and will delay 10 * [IOSink] buffers the input given by all [StringSink] methods and will delay
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 class _StreamSinkImpl<T> implements StreamSink<T> { 71 class _StreamSinkImpl<T> implements StreamSink<T> {
72 final StreamConsumer<T> _target; 72 final StreamConsumer<T> _target;
73 Completer _doneCompleter = new Completer(); 73 Completer _doneCompleter = new Completer();
74 Future _doneFuture; 74 Future _doneFuture;
75 StreamController<T> _controllerInstance; 75 StreamController<T> _controllerInstance;
76 Completer _controllerCompleter; 76 Completer _controllerCompleter;
77 bool _isClosed = false; 77 bool _isClosed = false;
78 bool _isBound = false; 78 bool _isBound = false;
79 bool _hasError = false; 79 bool _hasError = false;
80 80
81 _StreamSinkImpl(StreamConsumer<T> this._target) { 81 _StreamSinkImpl(this._target) {
82 _doneFuture = _doneCompleter.future; 82 _doneFuture = _doneCompleter.future;
83 } 83 }
84 84
85 void add(T data) { 85 void add(T data) {
86 if (_isClosed) return; 86 if (_isClosed) return;
87 _controller.add(data); 87 _controller.add(data);
88 } 88 }
89 89
90 void addError(error, [StackTrace stackTrace]) { 90 void addError(error, [StackTrace stackTrace]) =>
91 _controller.addError(error, stackTrace); 91 _controller.addError(error, stackTrace);
92 }
93 92
94 Future addStream(Stream<T> stream) { 93 Future addStream(Stream<T> stream) {
95 if (_isBound) { 94 if (_isBound) {
96 throw new StateError("StreamSink is already bound to a stream"); 95 throw new StateError("StreamSink is already bound to a stream");
97 } 96 }
98 _isBound = true; 97 _isBound = true;
99 if (_hasError) return done; 98 if (_hasError) return done;
100 // Wait for any sync operations to complete. 99 // Wait for any sync operations to complete.
101 Future targetAddStream() { 100 Future targetAddStream() {
102 return _target.addStream(stream) 101 return _target.addStream(stream)
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 242
244 void writeln([Object obj = ""]) { 243 void writeln([Object obj = ""]) {
245 write(obj); 244 write(obj);
246 write("\n"); 245 write("\n");
247 } 246 }
248 247
249 void writeCharCode(int charCode) { 248 void writeCharCode(int charCode) {
250 write(new String.fromCharCode(charCode)); 249 write(new String.fromCharCode(charCode));
251 } 250 }
252 } 251 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698