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

Side by Side 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, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/service_object_patch.dart ('k') | runtime/bin/vmservice/client/HACKING.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 patch class RawServerSocket { 5 patch class RawServerSocket {
6 /* patch */ static Future<RawServerSocket> bind(address, 6 /* patch */ static Future<RawServerSocket> bind(address,
7 int port, 7 int port,
8 {int backlog: 0, 8 {int backlog: 0,
9 bool v6Only: false}) { 9 bool v6Only: false}) {
10 return _RawServerSocket.bind(address, port, backlog, v6Only); 10 return _RawServerSocket.bind(address, port, backlog, v6Only);
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 if (port != 0) socket.localPort = port; 605 if (port != 0) socket.localPort = port;
606 return socket; 606 return socket;
607 }); 607 });
608 } 608 }
609 609
610 _NativeSocket.datagram(this.address) 610 _NativeSocket.datagram(this.address)
611 : typeFlags = TYPE_NORMAL_SOCKET | TYPE_UDP_SOCKET; 611 : typeFlags = TYPE_NORMAL_SOCKET | TYPE_UDP_SOCKET;
612 612
613 _NativeSocket.normal() : typeFlags = TYPE_NORMAL_SOCKET | TYPE_TCP_SOCKET; 613 _NativeSocket.normal() : typeFlags = TYPE_NORMAL_SOCKET | TYPE_TCP_SOCKET;
614 614
615 _NativeSocket.listen() : super(), typeFlags = TYPE_LISTENING_SOCKET | TYPE_TCP _SOCKET; 615 _NativeSocket.listen() : typeFlags = TYPE_LISTENING_SOCKET | TYPE_TCP_SOCKET;
616 616
617 _NativeSocket.pipe() : typeFlags = TYPE_PIPE; 617 _NativeSocket.pipe() : typeFlags = TYPE_PIPE;
618 618
619 _NativeSocket.watch(int id) 619 _NativeSocket.watch(int id)
620 : typeFlags = TYPE_NORMAL_SOCKET | TYPE_INTERNAL_SOCKET { 620 : typeFlags = TYPE_NORMAL_SOCKET | TYPE_INTERNAL_SOCKET {
621 isClosedWrite = true; 621 isClosedWrite = true;
622 nativeSetSocketId(id); 622 nativeSetSocketId(id);
623 } 623 }
624 624
625 bool get isListening => (typeFlags & TYPE_LISTENING_SOCKET) != 0; 625 bool get isListening => (typeFlags & TYPE_LISTENING_SOCKET) != 0;
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 var result = nativeLeaveMulticast( 1064 var result = nativeLeaveMulticast(
1065 addr._in_addr, 1065 addr._in_addr,
1066 interfaceAddr == null ? null : interfaceAddr._in_addr, 1066 interfaceAddr == null ? null : interfaceAddr._in_addr,
1067 interfaceIndex); 1067 interfaceIndex);
1068 if (result is OSError) throw result; 1068 if (result is OSError) throw result;
1069 } 1069 }
1070 1070
1071 String get _serviceTypePath => 'io/sockets'; 1071 String get _serviceTypePath => 'io/sockets';
1072 String get _serviceTypeName => 'Socket'; 1072 String get _serviceTypeName => 'Socket';
1073 1073
1074 Map _toJSON(bool ref) { 1074 String _JSONKind() {
1075 return isListening ? "LISTENING" :
1076 isPipe ? "PIPE" :
1077 isInternal ? "INTERNAL" : "NORMAL";
1078 }
1079
1080 Map _toJSONPipe(bool ref) {
1081 var name;
1082 if (isClosed) {
1083 name = 'CLOSED PIPE';
1084 } else if (isClosedWrite) {
1085 name = 'READ PIPE';
1086 } else if (isClosedRead) {
1087 name = 'WRITE PIPE';
1088 } else {
1089 name = 'R/W PIPE';
1090 }
1091 var r = {
1092 'id': _servicePath,
1093 'type': _serviceType(ref),
1094 'name': name,
1095 'user_name': name,
1096 'kind': _JSONKind(),
1097 };
1098 if (ref) {
1099 return r;
1100 }
1101 r['fd'] = nativeGetSocketId();
1102 if (owner != null) {
1103 r['owner'] = owner._toJSON(true);
1104 }
1105 return r;
1106 }
1107
1108 Map _toJSONNetwork(bool ref) {
1075 var name = '${address.host}:$port'; 1109 var name = '${address.host}:$port';
1076 if (isTcp && !isListening) name += " <-> ${remoteAddress.host}:$remotePort"; 1110 if (isTcp && !isListening) name += " <-> ${remoteAddress.host}:$remotePort";
1077 var r = { 1111 var r = {
1078 'id': _servicePath, 1112 'id': _servicePath,
1079 'type': _serviceType(ref), 1113 'type': _serviceType(ref),
1080 'name': name, 1114 'name': name,
1081 'user_name': name, 1115 'user_name': name,
1116 'kind': _JSONKind(),
1082 }; 1117 };
1083 if (ref) { 1118 if (ref) {
1084 return r; 1119 return r;
1085 } 1120 }
1086 r['port'] = port; 1121 r['port'] = port;
1087 r['address'] = address.host; 1122 r['address'] = address.host;
1088 r['fd'] = nativeGetSocketId(); 1123 r['fd'] = nativeGetSocketId();
1089 if (owner != null) { 1124 if (owner != null) {
1090 r['owner'] = owner._toJSON(true); 1125 r['owner'] = owner._toJSON(true);
1091 } 1126 }
1092 return r; 1127 return r;
1093 } 1128 }
1094 1129
1130 Map _toJSON(bool ref) {
1131 if (isPipe) {
1132 return _toJSONPipe(ref);
1133 }
1134 return _toJSONNetwork(ref);
1135 }
1136
1095 void nativeSetSocketId(int id) native "Socket_SetSocketId"; 1137 void nativeSetSocketId(int id) native "Socket_SetSocketId";
1096 nativeAvailable() native "Socket_Available"; 1138 nativeAvailable() native "Socket_Available";
1097 nativeRead(int len) native "Socket_Read"; 1139 nativeRead(int len) native "Socket_Read";
1098 nativeRecvFrom() native "Socket_RecvFrom"; 1140 nativeRecvFrom() native "Socket_RecvFrom";
1099 nativeWrite(List<int> buffer, int offset, int bytes) 1141 nativeWrite(List<int> buffer, int offset, int bytes)
1100 native "Socket_WriteList"; 1142 native "Socket_WriteList";
1101 nativeSendTo(List<int> buffer, int offset, int bytes, 1143 nativeSendTo(List<int> buffer, int offset, int bytes,
1102 List<int> address, int port) 1144 List<int> address, int port)
1103 native "Socket_SendTo"; 1145 native "Socket_SendTo";
1104 nativeCreateConnect(List<int> addr, 1146 nativeCreateConnect(List<int> addr,
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 String address, 1953 String address,
1912 List<int> in_addr, 1954 List<int> in_addr,
1913 int port) { 1955 int port) {
1914 return new Datagram( 1956 return new Datagram(
1915 data, 1957 data,
1916 new _InternetAddress(address, null, in_addr), 1958 new _InternetAddress(address, null, in_addr),
1917 port); 1959 port);
1918 } 1960 }
1919 1961
1920 String _socketsStats() => _SocketsObservatory.toJSON(); 1962 String _socketsStats() => _SocketsObservatory.toJSON();
OLDNEW
« no previous file with comments | « runtime/bin/service_object_patch.dart ('k') | runtime/bin/vmservice/client/HACKING.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698