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

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

Issue 9285017: Comment and white-space cleanup in IO libraries. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More of the same. Created 8 years, 11 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 | « runtime/bin/socket.dart ('k') | runtime/bin/timer.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) 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 5
6 class _SocketBase { 6 class _SocketBase {
7 // Bit flags used when communicating between the eventhandler and 7 // Bit flags used when communicating between the eventhandler and
8 // dart code. The EVENT flags are used to indicate events of 8 // dart code. The EVENT flags are used to indicate events of
9 // interest when sending a message from dart code to the 9 // interest when sending a message from dart code to the
10 // eventhandler. When receiving a message from the eventhandler the 10 // eventhandler. When receiving a message from the eventhandler the
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 if (_handler === null) { 162 if (_handler === null) {
163 _handler = new ReceivePort(); 163 _handler = new ReceivePort();
164 _handler.receive((var message, ignored) { _multiplex(message); }); 164 _handler.receive((var message, ignored) { _multiplex(message); });
165 } 165 }
166 EventHandler._sendData(_id, _handler, data); 166 EventHandler._sendData(_id, _handler, data);
167 } 167 }
168 168
169 abstract bool _isListenSocket(); 169 abstract bool _isListenSocket();
170 abstract bool _isPipe(); 170 abstract bool _isPipe();
171 171
172 /* 172 // Socket id is set from native. -1 indicates that the socket was closed.
173 * Socket id is set from native. -1 indicates that the socket was closed.
174 */
175 int _id; 173 int _id;
176 174
177 /* 175 // Dedicated ReceivePort for socket events.
178 * Dedicated ReceivePort for socket events.
179 */
180 ReceivePort _handler; 176 ReceivePort _handler;
181 177
182 /* 178 // Poll event to handler map.
183 * Poll event to handler map.
184 */
185 List _handlerMap; 179 List _handlerMap;
186 180
187 /* 181 // Indicates for which poll events the socket registered handlers.
188 * Indicates for which poll events the socket registered handlers.
189 */
190 int _handlerMask; 182 int _handlerMask;
191 183
192 /* 184 // Indicates if native interrupts can be activated.
193 * Indicates if native interrupts can be activated.
194 */
195 bool _canActivateHandlers; 185 bool _canActivateHandlers;
196 186
197 /* 187 // Holds the port of the socket, null if not known.
198 * Holds the port of the socket, null if not known.
199 */
200 int _port; 188 int _port;
201 } 189 }
202 190
203 191
204 class _ServerSocket extends _SocketBase implements ServerSocket { 192 class _ServerSocket extends _SocketBase implements ServerSocket {
205 /* 193 // Constructor for server socket. First a socket object is allocated
206 * Constructor for server socket. First a socket object is allocated 194 // in which the native socket is stored. After that _createBind
207 * in which the native socket is stored. After that _createBind 195 // is called which creates a file descriptor and binds the given address
208 * is called which creates a file descriptor and binds the given address 196 // and port to the socket. Null is returned if file descriptor creation or
209 * and port to the socket. Null is returned if file descriptor creation or 197 // bind failed.
210 * bind failed.
211 */
212 factory _ServerSocket(String bindAddress, int port, int backlog) { 198 factory _ServerSocket(String bindAddress, int port, int backlog) {
213 ServerSocket socket = new _ServerSocket._internal(); 199 ServerSocket socket = new _ServerSocket._internal();
214 if (!socket._createBindListen(bindAddress, port, backlog)) { 200 if (!socket._createBindListen(bindAddress, port, backlog)) {
215 socket.close(); 201 socket.close();
216 return null; 202 return null;
217 } 203 }
218 if (port != 0) { 204 if (port != 0) {
219 socket._port = port; 205 socket._port = port;
220 } 206 }
221 return socket; 207 return socket;
(...skipping 20 matching lines...) Expand all
242 } 228 }
243 229
244 bool _isListenSocket() => true; 230 bool _isListenSocket() => true;
245 bool _isPipe() => false; 231 bool _isPipe() => false;
246 232
247 var _clientConnectionHandler; 233 var _clientConnectionHandler;
248 } 234 }
249 235
250 236
251 class _Socket extends _SocketBase implements Socket { 237 class _Socket extends _SocketBase implements Socket {
252 /* 238 // Constructor for socket. First a socket object is allocated
253 * Constructor for socket. First a socket object is allocated 239 // in which the native socket is stored. After that _createConnect is
254 * in which the native socket is stored. After that _createConnect is 240 // called which creates a file discriptor and connects to the given
255 * called which creates a file discriptor and connects to the given 241 // host on the given port. Null is returned if file descriptor creation
256 * host on the given port. Null is returned if file descriptor creation 242 // or connect failed.
257 * or connect failed.
258 */
259 factory _Socket(String host, int port) { 243 factory _Socket(String host, int port) {
260 Socket socket = new _Socket._internal(); 244 Socket socket = new _Socket._internal();
261 if (!socket._createConnect(host, port)) { 245 if (!socket._createConnect(host, port)) {
262 socket.close(); 246 socket.close();
263 return null; 247 return null;
264 } 248 }
265 return socket; 249 return socket;
266 } 250 }
267 251
268 _Socket._internal(); 252 _Socket._internal();
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 bool _seenFirstOutEvent = false; 455 bool _seenFirstOutEvent = false;
472 bool _closedRead = false; 456 bool _closedRead = false;
473 bool _closedWrite = false; 457 bool _closedWrite = false;
474 bool _pipe = false; 458 bool _pipe = false;
475 Function _clientConnectHandler; 459 Function _clientConnectHandler;
476 Function _clientWriteHandler; 460 Function _clientWriteHandler;
477 SocketInputStream _inputStream; 461 SocketInputStream _inputStream;
478 SocketOutputStream _outputStream; 462 SocketOutputStream _outputStream;
479 } 463 }
480 464
OLDNEW
« no previous file with comments | « runtime/bin/socket.dart ('k') | runtime/bin/timer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698