| OLD | NEW |
| 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 |
| 11 // EVENT flags indicate the events that actually happened. The | 11 // EVENT flags indicate the events that actually happened. The |
| 12 // COMMAND flags are used to send commands from dart to the | 12 // COMMAND flags are used to send commands from dart to the |
| 13 // eventhandler. COMMAND flags are never received from the | 13 // eventhandler. COMMAND flags are never received from the |
| 14 // eventhandler. Additional flags are used to communicate other | 14 // eventhandler. Additional flags are used to communicate other |
| 15 // information. | 15 // information. |
| 16 static final int _IN_EVENT = 0; | 16 static const int _IN_EVENT = 0; |
| 17 static final int _OUT_EVENT = 1; | 17 static const int _OUT_EVENT = 1; |
| 18 static final int _ERROR_EVENT = 2; | 18 static const int _ERROR_EVENT = 2; |
| 19 static final int _CLOSE_EVENT = 3; | 19 static const int _CLOSE_EVENT = 3; |
| 20 | 20 |
| 21 static final int _CLOSE_COMMAND = 8; | 21 static const int _CLOSE_COMMAND = 8; |
| 22 static final int _SHUTDOWN_READ_COMMAND = 9; | 22 static const int _SHUTDOWN_READ_COMMAND = 9; |
| 23 static final int _SHUTDOWN_WRITE_COMMAND = 10; | 23 static const int _SHUTDOWN_WRITE_COMMAND = 10; |
| 24 | 24 |
| 25 // Flag send to the eventhandler providing additional information on | 25 // Flag send to the eventhandler providing additional information on |
| 26 // the type of the file descriptor. | 26 // the type of the file descriptor. |
| 27 static final int _LISTENING_SOCKET = 16; | 27 static const int _LISTENING_SOCKET = 16; |
| 28 static final int _PIPE = 17; | 28 static const int _PIPE = 17; |
| 29 | 29 |
| 30 static final int _FIRST_EVENT = _IN_EVENT; | 30 static const int _FIRST_EVENT = _IN_EVENT; |
| 31 static final int _LAST_EVENT = _CLOSE_EVENT; | 31 static const int _LAST_EVENT = _CLOSE_EVENT; |
| 32 | 32 |
| 33 static final int _FIRST_COMMAND = _CLOSE_COMMAND; | 33 static const int _FIRST_COMMAND = _CLOSE_COMMAND; |
| 34 static final int _LAST_COMMAND = _SHUTDOWN_WRITE_COMMAND; | 34 static const int _LAST_COMMAND = _SHUTDOWN_WRITE_COMMAND; |
| 35 | 35 |
| 36 _SocketBase () { | 36 _SocketBase () { |
| 37 _handlerMap = new List(_LAST_EVENT + 1); | 37 _handlerMap = new List(_LAST_EVENT + 1); |
| 38 _handlerMask = 0; | 38 _handlerMask = 0; |
| 39 _canActivateHandlers = true; | 39 _canActivateHandlers = true; |
| 40 _id = -1; | 40 _id = -1; |
| 41 _EventHandler._start(); | 41 _EventHandler._start(); |
| 42 _hashCode = _nextHashCode; | 42 _hashCode = _nextHashCode; |
| 43 _nextHashCode = (_nextHashCode + 1) & 0xFFFFFFF; | 43 _nextHashCode = (_nextHashCode + 1) & 0xFFFFFFF; |
| 44 } | 44 } |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 } | 306 } |
| 307 | 307 |
| 308 bool _isListenSocket() => true; | 308 bool _isListenSocket() => true; |
| 309 bool _isPipe() => false; | 309 bool _isPipe() => false; |
| 310 | 310 |
| 311 var _clientConnectionHandler; | 311 var _clientConnectionHandler; |
| 312 } | 312 } |
| 313 | 313 |
| 314 | 314 |
| 315 class _Socket extends _SocketBase implements Socket { | 315 class _Socket extends _SocketBase implements Socket { |
| 316 static final HOST_NAME_LOOKUP = 0; | 316 static const HOST_NAME_LOOKUP = 0; |
| 317 | 317 |
| 318 // Constructs a new socket. During the construction an asynchronous | 318 // Constructs a new socket. During the construction an asynchronous |
| 319 // host name lookup is initiated. The returned socket is not yet | 319 // host name lookup is initiated. The returned socket is not yet |
| 320 // connected but ready for registration of callbacks. | 320 // connected but ready for registration of callbacks. |
| 321 factory _Socket(String host, int port) { | 321 factory _Socket(String host, int port) { |
| 322 Socket socket = new _Socket._internal(); | 322 Socket socket = new _Socket._internal(); |
| 323 _ensureSocketService(); | 323 _ensureSocketService(); |
| 324 List request = new List(2); | 324 List request = new List(2); |
| 325 request[0] = HOST_NAME_LOOKUP; | 325 request[0] = HOST_NAME_LOOKUP; |
| 326 request[1] = host; | 326 request[1] = host; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 bool _seenFirstOutEvent = false; | 585 bool _seenFirstOutEvent = false; |
| 586 bool _pipe = false; | 586 bool _pipe = false; |
| 587 Function _clientConnectHandler; | 587 Function _clientConnectHandler; |
| 588 Function _clientWriteHandler; | 588 Function _clientWriteHandler; |
| 589 SocketInputStream _inputStream; | 589 SocketInputStream _inputStream; |
| 590 SocketOutputStream _outputStream; | 590 SocketOutputStream _outputStream; |
| 591 String _remoteHost; | 591 String _remoteHost; |
| 592 int _remotePort; | 592 int _remotePort; |
| 593 static SendPort _socketService; | 593 static SendPort _socketService; |
| 594 } | 594 } |
| OLD | NEW |