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

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

Issue 16125005: Make new StreamController be async by default. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments Created 7 years, 6 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 | « pkg/scheduled_test/lib/src/utils.dart ('k') | samples/swarm/swarm_ui_lib/touch/Scroller.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) 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(address, 6 /* patch */ static Future<RawServerSocket> bind(address,
7 int port, 7 int port,
8 {int backlog: 0, 8 {int backlog: 0,
9 bool v6Only: false}) { 9 bool v6Only: false}) {
10 return _RawServerSocket.bind(address, port, backlog, v6Only); 10 return _RawServerSocket.bind(address, port, backlog, v6Only);
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 int backlog, 551 int backlog,
552 bool v6Only) { 552 bool v6Only) {
553 if (port < 0 || port > 0xFFFF) 553 if (port < 0 || port > 0xFFFF)
554 throw new ArgumentError("Invalid port $port"); 554 throw new ArgumentError("Invalid port $port");
555 if (backlog < 0) throw new ArgumentError("Invalid backlog $backlog"); 555 if (backlog < 0) throw new ArgumentError("Invalid backlog $backlog");
556 return _NativeSocket.bind(address, port, backlog, v6Only) 556 return _NativeSocket.bind(address, port, backlog, v6Only)
557 .then((socket) => new _RawServerSocket(socket)); 557 .then((socket) => new _RawServerSocket(socket));
558 } 558 }
559 559
560 _RawServerSocket(this._socket) { 560 _RawServerSocket(this._socket) {
561 _controller = new StreamController( 561 _controller = new StreamController(sync: true,
562 onListen: _onSubscriptionStateChange, 562 onListen: _onSubscriptionStateChange,
563 onCancel: _onSubscriptionStateChange, 563 onCancel: _onSubscriptionStateChange,
564 onPause: _onPauseStateChange, 564 onPause: _onPauseStateChange,
565 onResume: _onPauseStateChange); 565 onResume: _onPauseStateChange);
566 _socket.closeFuture.then((_) => _controller.close()); 566 _socket.closeFuture.then((_) => _controller.close());
567 _socket.setHandlers( 567 _socket.setHandlers(
568 read: () { 568 read: () {
569 var socket = _socket.accept(); 569 var socket = _socket.accept();
570 if (socket != null) _controller.add(new _RawSocket(socket)); 570 if (socket != null) _controller.add(new _RawSocket(socket));
571 }, 571 },
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 StreamController<RawSocketEvent> _controller; 623 StreamController<RawSocketEvent> _controller;
624 bool _readEventsEnabled = true; 624 bool _readEventsEnabled = true;
625 bool _writeEventsEnabled = true; 625 bool _writeEventsEnabled = true;
626 626
627 static Future<RawSocket> connect(host, int port) { 627 static Future<RawSocket> connect(host, int port) {
628 return _NativeSocket.connect(host, port) 628 return _NativeSocket.connect(host, port)
629 .then((socket) => new _RawSocket(socket)); 629 .then((socket) => new _RawSocket(socket));
630 } 630 }
631 631
632 _RawSocket(this._socket) { 632 _RawSocket(this._socket) {
633 _controller = new StreamController( 633 _controller = new StreamController(sync: true,
634 onListen: _onSubscriptionStateChange, 634 onListen: _onSubscriptionStateChange,
635 onCancel: _onSubscriptionStateChange, 635 onCancel: _onSubscriptionStateChange,
636 onPause: _onPauseStateChange, 636 onPause: _onPauseStateChange,
637 onResume: _onPauseStateChange); 637 onResume: _onPauseStateChange);
638 _socket.closeFuture.then((_) => _controller.close()); 638 _socket.closeFuture.then((_) => _controller.close());
639 _socket.setHandlers( 639 _socket.setHandlers(
640 read: () => _controller.add(RawSocketEvent.READ), 640 read: () => _controller.add(RawSocketEvent.READ),
641 write: () { 641 write: () {
642 // The write event handler is automatically disabled by the 642 // The write event handler is automatically disabled by the
643 // event handler when it fires. 643 // event handler when it fires.
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 RawSocket _raw; // Set to null when the raw socket is closed. 879 RawSocket _raw; // Set to null when the raw socket is closed.
880 bool _closed = false; // Set to true when the raw socket is closed. 880 bool _closed = false; // Set to true when the raw socket is closed.
881 StreamController _controller; 881 StreamController _controller;
882 bool _controllerClosed = false; 882 bool _controllerClosed = false;
883 _SocketStreamConsumer _consumer; 883 _SocketStreamConsumer _consumer;
884 IOSink _sink; 884 IOSink _sink;
885 var _subscription; 885 var _subscription;
886 var _detachReady; 886 var _detachReady;
887 887
888 _Socket(RawSocket this._raw) { 888 _Socket(RawSocket this._raw) {
889 _controller = new StreamController<List<int>>( 889 _controller = new StreamController<List<int>>(sync: true,
890 onListen: _onSubscriptionStateChange, 890 onListen: _onSubscriptionStateChange,
891 onCancel: _onSubscriptionStateChange, 891 onCancel: _onSubscriptionStateChange,
892 onPause: _onPauseStateChange, 892 onPause: _onPauseStateChange,
893 onResume: _onPauseStateChange); 893 onResume: _onPauseStateChange);
894 _consumer = new _SocketStreamConsumer(this); 894 _consumer = new _SocketStreamConsumer(this);
895 _sink = new IOSink(_consumer); 895 _sink = new IOSink(_consumer);
896 896
897 // Disable read events until there is a subscription. 897 // Disable read events until there is a subscription.
898 _raw.readEventsEnabled = false; 898 _raw.readEventsEnabled = false;
899 899
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 if (_detachReady != null) { 1065 if (_detachReady != null) {
1066 _detachReady.complete(null); 1066 _detachReady.complete(null);
1067 } else { 1067 } else {
1068 if (_raw != null) { 1068 if (_raw != null) {
1069 _raw.shutdown(SocketDirection.SEND); 1069 _raw.shutdown(SocketDirection.SEND);
1070 _disableWriteEvent(); 1070 _disableWriteEvent();
1071 } 1071 }
1072 } 1072 }
1073 } 1073 }
1074 } 1074 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/lib/src/utils.dart ('k') | samples/swarm/swarm_ui_lib/touch/Scroller.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698