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

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

Issue 250453004: Version 1.3.4 (Closed) Base URL: http://dart.googlecode.com/svn/branches/1.3/
Patch Set: Created 6 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 | « no previous file | dart/tests/standalone/io/http_server_test.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 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 int port, 1061 int port,
1062 int backlog, 1062 int backlog,
1063 bool v6Only) { 1063 bool v6Only) {
1064 if (port < 0 || port > 0xFFFF) 1064 if (port < 0 || port > 0xFFFF)
1065 throw new ArgumentError("Invalid port $port"); 1065 throw new ArgumentError("Invalid port $port");
1066 if (backlog < 0) throw new ArgumentError("Invalid backlog $backlog"); 1066 if (backlog < 0) throw new ArgumentError("Invalid backlog $backlog");
1067 return _NativeSocket.bind(address, port, backlog, v6Only) 1067 return _NativeSocket.bind(address, port, backlog, v6Only)
1068 .then((socket) => new _RawServerSocket(socket)); 1068 .then((socket) => new _RawServerSocket(socket));
1069 } 1069 }
1070 1070
1071 _RawServerSocket(this._socket) { 1071 _RawServerSocket(this._socket);
1072
1073 StreamSubscription<RawSocket> listen(void onData(RawSocket event),
1074 {Function onError,
1075 void onDone(),
1076 bool cancelOnError}) {
1077 if (_controller != null) {
1078 throw new StateError("Stream was already listened to");
1079 }
1072 var zone = Zone.current; 1080 var zone = Zone.current;
1073 _controller = new StreamController(sync: true, 1081 _controller = new StreamController(sync: true,
1074 onListen: _onSubscriptionStateChange, 1082 onListen: _onSubscriptionStateChange,
1075 onCancel: _onSubscriptionStateChange, 1083 onCancel: _onSubscriptionStateChange,
1076 onPause: _onPauseStateChange, 1084 onPause: _onPauseStateChange,
1077 onResume: _onPauseStateChange); 1085 onResume: _onPauseStateChange);
1078 _socket.setHandlers( 1086 _socket.setHandlers(
1079 read: zone.bindCallback(() { 1087 read: zone.bindCallback(() {
1080 do { 1088 do {
1081 var socket = _socket.accept(); 1089 var socket = _socket.accept();
1082 if (socket == null) return; 1090 if (socket == null) return;
1083 _controller.add(new _RawSocket(socket)); 1091 _controller.add(new _RawSocket(socket));
1084 } while (!_controller.isPaused); 1092 } while (!_controller.isPaused);
1085 }), 1093 }),
1086 error: zone.bindUnaryCallback((e) { 1094 error: zone.bindUnaryCallback((e) {
1087 _controller.addError(e); 1095 _controller.addError(e);
1088 _controller.close(); 1096 _controller.close();
1089 }), 1097 }),
1090 destroyed: _controller.close 1098 destroyed: _controller.close);
1091 );
1092 }
1093
1094 StreamSubscription<RawSocket> listen(void onData(RawSocket event),
1095 {Function onError,
1096 void onDone(),
1097 bool cancelOnError}) {
1098 return _controller.stream.listen( 1099 return _controller.stream.listen(
1099 onData, 1100 onData,
1100 onError: onError, 1101 onError: onError,
1101 onDone: onDone, 1102 onDone: onDone,
1102 cancelOnError: cancelOnError); 1103 cancelOnError: cancelOnError);
1103 } 1104 }
1104 1105
1105 int get port => _socket.port; 1106 int get port => _socket.port;
1106 1107
1107 InternetAddress get address => _socket.address; 1108 InternetAddress get address => _socket.address;
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1764 String address, 1765 String address,
1765 List<int> in_addr, 1766 List<int> in_addr,
1766 int port) { 1767 int port) {
1767 return new Datagram( 1768 return new Datagram(
1768 data, 1769 data,
1769 new _InternetAddress(address, null, in_addr), 1770 new _InternetAddress(address, null, in_addr),
1770 port); 1771 port);
1771 } 1772 }
1772 1773
1773 String _socketsStats() => _SocketsObservatory.toJSON(); 1774 String _socketsStats() => _SocketsObservatory.toJSON();
OLDNEW
« no previous file with comments | « no previous file | dart/tests/standalone/io/http_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698