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

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

Issue 879353003: Introduce optional 'bool shared' parameter to ServerSocket.bind() ... (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 5 years, 10 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 * The [SecureServerSocket] is a server socket, providing a stream of high-level 8 * The [SecureServerSocket] is a server socket, providing a stream of high-level
9 * [Socket]s. 9 * [Socket]s.
10 * 10 *
11 * See [SecureSocket] for more info. 11 * See [SecureSocket] for more info.
12 */ 12 */
13 class SecureServerSocket extends Stream<SecureSocket> { 13 class SecureServerSocket extends Stream<SecureSocket> {
14 final RawSecureServerSocket _socket; 14 final RawSecureServerSocket _socket;
15 15
16 SecureServerSocket._(this._socket); 16 /**
17 * Whether the underlying socket of this [SecureServerSocket] might
18 * potentially be shared.
19 */
20 final bool shared;
21
22 SecureServerSocket._(this._socket, this.shared);
17 23
18 /** 24 /**
19 * Returns a future for a [SecureServerSocket]. When the future 25 * Returns a future for a [SecureServerSocket]. When the future
20 * completes the server socket is bound to the given [address] and 26 * completes the server socket is bound to the given [address] and
21 * [port] and has started listening on it. 27 * [port] and has started listening on it.
22 * 28 *
23 * The [address] can either be a [String] or an 29 * The [address] can either be a [String] or an
24 * [InternetAddress]. If [address] is a [String], [bind] will 30 * [InternetAddress]. If [address] is a [String], [bind] will
25 * perform a [InternetAddress.lookup] and use the first value in the 31 * perform a [InternetAddress.lookup] and use the first value in the
26 * list. To listen on the loopback adapter, which will allow only 32 * list. To listen on the loopback adapter, which will allow only
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 * was received, the result will be null. 66 * was received, the result will be null.
61 */ 67 */
62 static Future<SecureServerSocket> bind( 68 static Future<SecureServerSocket> bind(
63 address, 69 address,
64 int port, 70 int port,
65 String certificateName, 71 String certificateName,
66 {int backlog: 0, 72 {int backlog: 0,
67 bool v6Only: false, 73 bool v6Only: false,
68 bool requestClientCertificate: false, 74 bool requestClientCertificate: false,
69 bool requireClientCertificate: false, 75 bool requireClientCertificate: false,
70 List<String> supportedProtocols}) { 76 List<String> supportedProtocols,
77 bool shared: false}) {
71 return RawSecureServerSocket.bind( 78 return RawSecureServerSocket.bind(
72 address, 79 address,
73 port, 80 port,
74 certificateName, 81 certificateName,
75 backlog: backlog, 82 backlog: backlog,
76 v6Only: v6Only, 83 v6Only: v6Only,
77 requestClientCertificate: requestClientCertificate, 84 requestClientCertificate: requestClientCertificate,
78 requireClientCertificate: requireClientCertificate, 85 requireClientCertificate: requireClientCertificate,
79 supportedProtocols: supportedProtocols).then( 86 supportedProtocols: supportedProtocols,
80 (serverSocket) => new SecureServerSocket._(serverSocket)); 87 shared: shared).then(
88 (serverSocket) => new SecureServerSocket._(serverSocket, shared));
81 } 89 }
82 90
83 StreamSubscription<SecureSocket> listen(void onData(SecureSocket socket), 91 StreamSubscription<SecureSocket> listen(void onData(SecureSocket socket),
84 {Function onError, 92 {Function onError,
85 void onDone(), 93 void onDone(),
86 bool cancelOnError}) { 94 bool cancelOnError}) {
87 return _socket.map((rawSocket) => new SecureSocket._(rawSocket)) 95 return _socket.map((rawSocket) => new SecureSocket._(rawSocket))
88 .listen(onData, 96 .listen(onData,
89 onError: onError, 97 onError: onError,
90 onDone: onDone, 98 onDone: onDone,
(...skipping 29 matching lines...) Expand all
120 class RawSecureServerSocket extends Stream<RawSecureSocket> { 128 class RawSecureServerSocket extends Stream<RawSecureSocket> {
121 RawServerSocket _socket; 129 RawServerSocket _socket;
122 StreamController<RawSecureSocket> _controller; 130 StreamController<RawSecureSocket> _controller;
123 StreamSubscription<RawSocket> _subscription; 131 StreamSubscription<RawSocket> _subscription;
124 final String certificateName; 132 final String certificateName;
125 final bool requestClientCertificate; 133 final bool requestClientCertificate;
126 final bool requireClientCertificate; 134 final bool requireClientCertificate;
127 final List<String> supportedProtocols; 135 final List<String> supportedProtocols;
128 bool _closed = false; 136 bool _closed = false;
129 137
138 /**
139 * Whether the underlying socket of this [RawSecureServerSocket] might
140 * potentially be shared.
141 */
142 final bool shared;
143
130 RawSecureServerSocket._(RawServerSocket serverSocket, 144 RawSecureServerSocket._(RawServerSocket serverSocket,
131 this.certificateName, 145 this.certificateName,
132 this.requestClientCertificate, 146 this.requestClientCertificate,
133 this.requireClientCertificate, 147 this.requireClientCertificate,
134 this.supportedProtocols) { 148 this.supportedProtocols,
149 this.shared) {
135 _socket = serverSocket; 150 _socket = serverSocket;
136 _controller = new StreamController<RawSecureSocket>( 151 _controller = new StreamController<RawSecureSocket>(
137 sync: true, 152 sync: true,
138 onListen: _onSubscriptionStateChange, 153 onListen: _onSubscriptionStateChange,
139 onPause: _onPauseStateChange, 154 onPause: _onPauseStateChange,
140 onResume: _onPauseStateChange, 155 onResume: _onPauseStateChange,
141 onCancel: _onSubscriptionStateChange); 156 onCancel: _onSubscriptionStateChange);
142 } 157 }
143 158
144 /** 159 /**
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 * was received, the result will be null. 200 * was received, the result will be null.
186 */ 201 */
187 static Future<RawSecureServerSocket> bind( 202 static Future<RawSecureServerSocket> bind(
188 address, 203 address,
189 int port, 204 int port,
190 String certificateName, 205 String certificateName,
191 {int backlog: 0, 206 {int backlog: 0,
192 bool v6Only: false, 207 bool v6Only: false,
193 bool requestClientCertificate: false, 208 bool requestClientCertificate: false,
194 bool requireClientCertificate: false, 209 bool requireClientCertificate: false,
195 List<String> supportedProtocols}) { 210 List<String> supportedProtocols,
196 return RawServerSocket.bind(address, port, backlog: backlog, v6Only: v6Only) 211 bool shared: false}) {
212 return RawServerSocket.bind(
213 address, port, backlog: backlog, v6Only: v6Only, shared: shared)
197 .then((serverSocket) => new RawSecureServerSocket._( 214 .then((serverSocket) => new RawSecureServerSocket._(
198 serverSocket, 215 serverSocket,
199 certificateName, 216 certificateName,
200 requestClientCertificate, 217 requestClientCertificate,
201 requireClientCertificate, 218 requireClientCertificate,
202 supportedProtocols)); 219 supportedProtocols,
220 shared));
203 } 221 }
204 222
205 StreamSubscription<RawSecureSocket> listen(void onData(RawSecureSocket s), 223 StreamSubscription<RawSecureSocket> listen(void onData(RawSecureSocket s),
206 {Function onError, 224 {Function onError,
207 void onDone(), 225 void onDone(),
208 bool cancelOnError}) { 226 bool cancelOnError}) {
209 return _controller.stream.listen(onData, 227 return _controller.stream.listen(onData,
210 onError: onError, 228 onError: onError,
211 onDone: onDone, 229 onDone: onDone,
212 cancelOnError: cancelOnError); 230 cancelOnError: cancelOnError);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 onError: _onError); 303 onError: _onError);
286 } else { 304 } else {
287 close(); 305 close();
288 } 306 }
289 } 307 }
290 308
291 void set _owner(owner) { (_socket as dynamic)._owner = owner; } 309 void set _owner(owner) { (_socket as dynamic)._owner = owner; }
292 } 310 }
293 311
294 312
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698