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

Unified Diff: sdk/lib/io/io_sink.dart

Issue 14150002: Remove StreamSink(replaced by EventSink) and make IOSink extend EventSink. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | sdk/lib/io/stdio.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/io_sink.dart
diff --git a/sdk/lib/io/io_sink.dart b/sdk/lib/io/io_sink.dart
index 685024cd09715f2e00d026502865cae1b76c73cb..794095e68d56132899f2b13816857e86a9b77cbc 100644
--- a/sdk/lib/io/io_sink.dart
+++ b/sdk/lib/io/io_sink.dart
@@ -8,14 +8,15 @@ part of dart.io;
* Helper class to wrap a [StreamConsumer<List<int>, T>] and provide
* utility functions for writing to the StreamConsumer directly. The
* [IOSink] buffers the input given by [write], [writeAll], [writeln],
- * [writeCharCode] and [writeBytes] and will delay a [consume] or
+ * [writeCharCode] and [add] and will delay a [consume] or
* [writeStream] until the buffer is flushed.
*
* When the [IOSink] is bound to a stream (through either [consume]
* or [writeStream]) any call to the [IOSink] will throw a
* [StateError].
*/
-abstract class IOSink<T> implements StreamConsumer<List<int>, T>, StringSink {
+abstract class IOSink<T>
+ implements StreamConsumer<List<int>, T>, StringSink, EventSink<List<int>> {
factory IOSink(StreamConsumer<List<int>, T> target,
{Encoding encoding: Encoding.UTF_8})
=> new _IOSinkImpl(target, encoding);
@@ -29,7 +30,12 @@ abstract class IOSink<T> implements StreamConsumer<List<int>, T>, StringSink {
/**
* Writes the bytes uninterpreted to the consumer.
*/
- void writeBytes(List<int> data);
+ void add(List<int> data);
+
+ /**
+ * Writes an error to the consumer.
+ */
+ void addError(AsyncError error);
/**
* Provide functionality for piping to the [IOSink].
@@ -100,7 +106,7 @@ class _IOSinkImpl<T> implements IOSink<T> {
}
}
if (string.isEmpty) return;
- writeBytes(_encodeString(string, _encoding));
+ add(_encodeString(string, _encoding));
}
void writeAll(Iterable objects, [String separator = ""]) {
@@ -128,13 +134,20 @@ class _IOSinkImpl<T> implements IOSink<T> {
write(new String.fromCharCode(charCode));
}
- void writeBytes(List<int> data) {
+ void add(List<int> data) {
if (_isBound) {
throw new StateError("IOSink is already bound to a stream");
}
_controller.add(data);
}
+ void addError(AsyncError error) {
+ if (_isBound) {
+ throw new StateError("IOSink is already bound to a stream");
+ }
+ _controller.addError(error);
+ }
+
Future<T> consume(Stream<List<int>> stream) {
if (_isBound) {
throw new StateError("IOSink is already bound to a stream");
« no previous file with comments | « sdk/lib/io/http_impl.dart ('k') | sdk/lib/io/stdio.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698