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

Unified Diff: runtime/bin/socket_patch.dart

Issue 304513004: Add 'owner' field to sockets, that point to a potential IO resource using that Socket. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix. 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
« no previous file with comments | « no previous file | runtime/bin/vmservice/client/lib/src/elements/io_view.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_patch.dart
diff --git a/runtime/bin/socket_patch.dart b/runtime/bin/socket_patch.dart
index 3a69255d6149f1602155c55222c7b3e933dc42f0..b7cf745e99b69b154b968bbef340d848f39fe701 100644
--- a/runtime/bin/socket_patch.dart
+++ b/runtime/bin/socket_patch.dart
@@ -436,6 +436,10 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
int totalRead = 0;
int totalWritten = 0;
+ // The owner object is the object that the Socket is being used by, e.g.
+ // a HttpServer, a WebSocket connection, a process pipe, etc.
+ Object owner;
+
static Future<List<InternetAddress>> lookup(
String host, {InternetAddressType type: InternetAddressType.ANY}) {
return _IOService.dispatch(_SOCKET_LOOKUP, [host, type._value])
@@ -960,6 +964,9 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
eventPort.close();
eventPort = null;
_sockets.remove(_serviceId);
+ // Now that we don't track this Socket anymore, we can clear the owner
+ // field.
+ owner = null;
}
// Check whether this is an error response from a native port call.
@@ -1079,6 +1086,9 @@ class _NativeSocket extends _NativeSocketNativeWrapper with _ServiceObject {
r['port'] = port;
r['address'] = address.host;
r['fd'] = nativeGetSocketId();
+ if (owner != null) {
+ r['owner'] = owner._toJSON(true);
+ }
return r;
}
@@ -1216,6 +1226,7 @@ class _RawServerSocket extends Stream<RawSocket>
}
Map _toJSON(bool ref) => _socket._toJSON(ref);
+ void set _owner(owner) { _socket.owner = owner; }
}
@@ -1391,6 +1402,7 @@ class _RawSocket extends Stream<RawSocketEvent>
}
Map _toJSON(bool ref) => _socket._toJSON(ref);
+ void set _owner(owner) { _socket.owner = owner; }
}
@@ -1451,6 +1463,7 @@ class _ServerSocket extends Stream<Socket>
}
Map _toJSON(bool ref) => _socket._toJSON(ref);
+ void set _owner(owner) { _socket._owner = owner; }
}
@@ -1749,6 +1762,7 @@ class _Socket extends Stream<List<int>> implements Socket {
}
Map _toJSON(bool ref) => _raw._toJSON(ref);
+ void set _owner(owner) { _raw._owner = owner; }
}
« no previous file with comments | « no previous file | runtime/bin/vmservice/client/lib/src/elements/io_view.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698