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

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

Issue 12504006: Make IOSink implement StringSink (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Correct rebase Created 7 years, 9 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 patch class RawServerSocket { 5 patch class RawServerSocket {
6 /* patch */ static Future<RawServerSocket> bind([String address = "127.0.0.1", 6 /* patch */ static Future<RawServerSocket> bind([String address = "127.0.0.1",
7 int port = 0, 7 int port = 0,
8 int backlog = 0]) { 8 int backlog = 0]) {
9 return _RawServerSocket.bind(address, port, backlog); 9 return _RawServerSocket.bind(address, port, backlog);
10 } 10 }
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 _SocketStreamConsumer _consumer; 726 _SocketStreamConsumer _consumer;
727 IOSink<Socket> _sink; 727 IOSink<Socket> _sink;
728 Completer _doneCompleter; 728 Completer _doneCompleter;
729 var _subscription; 729 var _subscription;
730 730
731 _Socket(RawSocket this._raw) { 731 _Socket(RawSocket this._raw) {
732 _controller = new StreamController<List<int>>( 732 _controller = new StreamController<List<int>>(
733 onSubscriptionStateChange: _onSubscriptionStateChange, 733 onSubscriptionStateChange: _onSubscriptionStateChange,
734 onPauseStateChange: _onPauseStateChange); 734 onPauseStateChange: _onPauseStateChange);
735 _consumer = new _SocketStreamConsumer(this); 735 _consumer = new _SocketStreamConsumer(this);
736 _sink = new IOSink(_consumer); 736 _sink = new IOSink(_consumer, Encoding.ASCII);
737 737
738 // Disable read events until there is a subscription. 738 // Disable read events until there is a subscription.
739 _raw.readEventsEnabled = false; 739 _raw.readEventsEnabled = false;
740 740
741 // Disable write events until the consumer needs it for pending writes. 741 // Disable write events until the consumer needs it for pending writes.
742 _raw.writeEventsEnabled = false; 742 _raw.writeEventsEnabled = false;
743 } 743 }
744 744
745 factory _Socket._writePipe([int fd]) { 745 factory _Socket._writePipe([int fd]) {
746 return new _Socket(new _RawSocket._writePipe(fd)); 746 return new _Socket(new _RawSocket._writePipe(fd));
747 } 747 }
748 748
749 factory _Socket._readPipe([int fd]) { 749 factory _Socket._readPipe([int fd]) {
750 return new _Socket(new _RawSocket._readPipe(fd)); 750 return new _Socket(new _RawSocket._readPipe(fd));
751 } 751 }
752 752
753 _NativeSocket get _nativeSocket => _raw._socket; 753 _NativeSocket get _nativeSocket => _raw._socket;
754 754
755 StreamSubscription<List<int>> listen(void onData(List<int> event), 755 StreamSubscription<List<int>> listen(void onData(List<int> event),
756 {void onError(AsyncError error), 756 {void onError(AsyncError error),
757 void onDone(), 757 void onDone(),
758 bool unsubscribeOnError}) { 758 bool unsubscribeOnError}) {
759 return _controller.stream.listen( 759 return _controller.stream.listen(
760 onData, 760 onData,
761 onError: onError, 761 onError: onError,
762 onDone: onDone, 762 onDone: onDone,
763 unsubscribeOnError: unsubscribeOnError); 763 unsubscribeOnError: unsubscribeOnError);
764 } 764 }
765 765
766 Encoding get encoding => _sink.encoding;
767 void set encoding(Encoding value) => _sink.encoding = value;
768
769 void write(Object obj) => _sink.write(obj);
770 void writeln(Object obj) => _sink.writeln(obj);
771 void writeCharCode(int charCode) => _sink.writeCharCode(charCode);
772 void writeAll(Iterable objects) => _sink.writeAll(objects);
773
Mads Ager (google) 2013/03/07 07:57:36 Nit: remove the empty line or consistently have on
Søren Gjesse 2013/03/07 16:28:47 Done.
774 void writeBytes(List<int> bytes) => _sink.writeBytes(bytes);
775
766 Future<Socket> consume(Stream<List<int>> stream) { 776 Future<Socket> consume(Stream<List<int>> stream) {
767 return _sink.consume(stream); 777 return _sink.consume(stream);
768 } 778 }
769 779
770 Future<Socket> addStream(Stream<List<int>> stream) { 780 Future<Socket> addStream(Stream<List<int>> stream) {
771 return _sink.addStream(stream); 781 return _sink.addStream(stream);
772 } 782 }
773 783
774 void add(List<int> data) { 784 void add(List<int> data) {
Anders Johnsen 2013/03/07 08:48:44 Remove these?
Søren Gjesse 2013/03/07 16:28:47 Done.
775 return _sink.add(data); 785 return _sink.add(data);
776 } 786 }
777 787
778 void addString(String string, [Encoding encoding = Encoding.UTF_8]) { 788 void addString(String string, [Encoding encoding = Encoding.UTF_8]) {
779 return _sink.addString(string, encoding); 789 return _sink.addString(string, encoding);
780 } 790 }
781 791
782 close() => _sink.close(); 792 close() => _sink.close();
783 793
784 Future<Socket> get done => _sink.done; 794 Future<Socket> get done => _sink.done;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 _raw.onBadCertificate = callback; 932 _raw.onBadCertificate = callback;
923 } 933 }
924 934
925 X509Certificate get peerCertificate { 935 X509Certificate get peerCertificate {
926 if (_raw == null) { 936 if (_raw == null) {
927 throw new StateError("peerCertificate called on destroyed SecureSocket"); 937 throw new StateError("peerCertificate called on destroyed SecureSocket");
928 } 938 }
929 return _raw.peerCertificate; 939 return _raw.peerCertificate;
930 } 940 }
931 } 941 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698