Chromium Code Reviews| Index: sdk/lib/io/secure_socket.dart |
| diff --git a/sdk/lib/io/secure_socket.dart b/sdk/lib/io/secure_socket.dart |
| index 9bfa032d50fceeb4b10bada55177492ca5ce328c..ab3ddb7baa97ffcd452b3e78ad605869b8f1e7f0 100644 |
| --- a/sdk/lib/io/secure_socket.dart |
| +++ b/sdk/lib/io/secure_socket.dart |
| @@ -491,17 +491,17 @@ class _RawSecureSocket extends Stream<RawSocketEvent> |
| } |
| _RawSecureSocket( |
| - InternetAddress this.address, |
| + this.address, |
| int requestedPort, |
| - String this.certificateName, |
| - bool this.is_server, |
| + this.certificateName, |
| + this.is_server, |
| RawSocket socket, |
| - StreamSubscription this._socketSubscription, |
| - List<int> this._bufferedData, |
| - bool this.requestClientCertificate, |
| - bool this.requireClientCertificate, |
| - bool this.sendClientCertificate, |
| - bool this.onBadCertificate(X509Certificate certificate)) { |
| + this._socketSubscription, |
| + this._bufferedData, |
| + this.requestClientCertificate, |
| + this.requireClientCertificate, |
| + this.sendClientCertificate, |
| + this.onBadCertificate(X509Certificate certificate)) { |
| _controller = new StreamController<RawSocketEvent>( |
| sync: true, |
| onListen: _onSubscriptionStateChange, |
| @@ -535,9 +535,10 @@ class _RawSecureSocket extends Stream<RawSocketEvent> |
| onError: _reportError, |
| onDone: _doneHandler); |
| } else { |
| - _socketSubscription.onData(_eventDispatcher); |
| - _socketSubscription.onError(_reportError); |
| - _socketSubscription.onDone(_doneHandler); |
| + _socketSubscription |
| + ..onData(_eventDispatcher) |
| + ..onError(_reportError) |
| + ..onDone(_doneHandler); |
| } |
| _secureFilter.connect(address.host, |
| (address as dynamic)._in_addr, |
| @@ -607,10 +608,9 @@ class _RawSecureSocket extends Stream<RawSocketEvent> |
| int get remotePort => _socket.remotePort; |
| - int available() { |
| - if (_status != CONNECTED) return 0; |
| - return _secureFilter.buffers[READ_PLAINTEXT].length; |
| - } |
| + int available() => _status != CONNECTED ? |
|
Lasse Reichstein Nielsen
2014/01/06 09:29:30
I'd prefer the block-and-return here.
|
| + 0 : |
| + _secureFilter.buffers[READ_PLAINTEXT].length; |
| Future<RawSecureSocket> close() { |
| shutdown(SocketDirection.BOTH); |
| @@ -1068,9 +1068,13 @@ class _RawSecureSocket extends Stream<RawSocketEvent> |
| * and one writing. All updates to start and end are done by Dart code. |
| */ |
| class _ExternalBuffer { |
| + List data; // This will be a ExternalByteArray, backed by C allocated data. |
| + int start; |
| + int end; |
| + final size; |
| + |
| _ExternalBuffer(this.size) { |
| - start = size~/2; |
| - end = size~/2; |
| + start = end = size ~/ 2; |
| } |
| void advanceStart(int bytes) { |
| @@ -1095,20 +1099,17 @@ class _ExternalBuffer { |
| bool get isEmpty => end == start; |
| - int get length { |
| - if (start > end) return size + end - start; |
| - return end - start; |
| - } |
| + int get length => start > end ? |
|
Lasse Reichstein Nielsen
2014/01/06 09:29:30
Use block-and-return for these three too.
|
| + size + end - start : |
| + end - start; |
| - int get linearLength { |
| - if (start > end) return size - start; |
| - return end - start; |
| - } |
| + int get linearLength => start > end ? |
| + size - start : |
| + end - start; |
| - int get free { |
| - if (start > end) return start - end - 1; |
| - return size + start - end - 1; |
| - } |
| + int get free => start > end ? |
| + start - end - 1 : |
| + size + start - end - 1; |
| int get linearFree { |
| if (start > end) return start - end - 1; |
| @@ -1185,11 +1186,6 @@ class _ExternalBuffer { |
| } |
| } |
| } |
| - |
| - List data; // This will be a ExternalByteArray, backed by C allocated data. |
| - int start; |
| - int end; |
| - final size; |
| } |
| @@ -1232,9 +1228,7 @@ class TlsException implements IOException { |
| OSError osError = null]) |
| : this._("TlsException", message, osError); |
| - const TlsException._(String this.type, |
| - String this.message, |
| - OSError this.osError); |
| + const TlsException._(this.type, this.message, this.osError); |
| String toString() { |
| StringBuffer sb = new StringBuffer(); |