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

Unified Diff: runtime/bin/socket_patch.dart

Issue 300883002: Add Proces owner of socket and fix printing of non-network sockets (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
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(),
+ 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);
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";

Powered by Google App Engine
This is Rietveld 408576698