Chromium Code Reviews| Index: runtime/bin/socket_patch.dart |
| diff --git a/runtime/bin/socket_patch.dart b/runtime/bin/socket_patch.dart |
| index b7cf745e99b69b154b968bbef340d848f39fe701..06d552f78fa3585058ab8a26373913c9b5b1a2fe 100644 |
| --- a/runtime/bin/socket_patch.dart |
| +++ b/runtime/bin/socket_patch.dart |
| @@ -612,7 +612,9 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject { |
| _NativeSocket.normal() : typeFlags = TYPE_NORMAL_SOCKET | TYPE_TCP_SOCKET; |
| - _NativeSocket.listen() : super(), typeFlags = TYPE_LISTENING_SOCKET | TYPE_TCP_SOCKET; |
| + _NativeSocket.listen() |
| + : super(), |
|
Anders Johnsen
2014/05/28 06:53:32
Oh, this super call is not needed. Can you remove
Cutch
2014/05/28 07:07:41
Done.
|
| + typeFlags = TYPE_LISTENING_SOCKET | TYPE_TCP_SOCKET; |
| _NativeSocket.pipe() : typeFlags = TYPE_PIPE; |
| @@ -902,6 +904,7 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject { |
| sendToEventHandler(1 << CLOSE_COMMAND); |
| isClosing = true; |
| } |
| + _sockets.remove(_serviceId); |
|
Anders Johnsen
2014/05/28 06:53:32
This should not be done here. If you have a case w
Cutch
2014/05/28 07:07:41
No, it was left over debugging stuff from yesterda
|
| return closeCompleter.future; |
| } |
| @@ -1071,7 +1074,41 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject { |
| String get _serviceTypePath => 'io/sockets'; |
| String get _serviceTypeName => 'Socket'; |
| - Map _toJSON(bool ref) { |
| + String _JSONKind() { |
| + return isListening ? "LISTENING" : |
| + isPipe ? "PIPE" : |
| + isInternal ? "INTERNAL" : "NORMAL"; |
| + } |
| + |
| + Map _toJSONPipe(bool ref) { |
| + var name; |
| + if (isClosed) { |
| + name = 'CLOSED PIPE'; |
| + } else if (isClosedWrite) { |
| + name = 'READ PIPE'; |
| + } else if (isClosedRead) { |
| + name = 'WRITE PIPE'; |
| + } else { |
| + name = 'R/W PIPE'; |
| + } |
| + var r = { |
| + 'id': _servicePath, |
| + 'type': _serviceType(ref), |
| + 'name': name, |
| + 'user_name': name, |
| + 'kind': _JSONKind(), |
| + }; |
| + if (ref) { |
| + return r; |
| + } |
| + r['fd'] = nativeGetSocketId(); |
| + if (owner != null) { |
| + r['owner'] = owner._toJSON(true); |
| + } |
| + return r; |
| + } |
| + |
| + Map _toJSONNetwork(bool ref) { |
| var name = '${address.host}:$port'; |
| if (isTcp && !isListening) name += " <-> ${remoteAddress.host}:$remotePort"; |
| var r = { |
| @@ -1079,6 +1116,7 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject { |
| 'type': _serviceType(ref), |
| 'name': name, |
| 'user_name': name, |
| + 'kind': _JSONKind(), |
| }; |
| if (ref) { |
| return r; |
| @@ -1092,6 +1130,13 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject { |
| return r; |
| } |
| + Map _toJSON(bool ref) { |
| + if (isPipe) { |
| + return _toJSONPipe(ref); |
| + } |
| + return _toJSONNetwork(ref); |
| + } |
| + |
| void nativeSetSocketId(int id) native "Socket_SetSocketId"; |
| nativeAvailable() native "Socket_Available"; |
| nativeRead(int len) native "Socket_Read"; |