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

Unified Diff: runtime/bin/socket_patch.dart

Issue 95183002: Add the index information to network interface (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 1 month 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 | « runtime/bin/socket_macos.cc ('k') | runtime/bin/socket_win.cc » ('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 1480f1f97b41ef2331744cca1e9313d799dddfc4..5efbeaff06a50667ff71197a9eab54383381db40 100644
--- a/runtime/bin/socket_patch.dart
+++ b/runtime/bin/socket_patch.dart
@@ -197,9 +197,10 @@ class _InternetAddress implements InternetAddress {
class _NetworkInterface implements NetworkInterface {
final String name;
- final List<InternetAddress> addresses;
+ final int index;
+ final List<InternetAddress> addresses = [];
- _NetworkInterface(String this.name, List<InternetAddress> this.addresses);
+ _NetworkInterface(this.name, this.index);
String toString() {
return "NetworkInterface('$name', $addresses)";
@@ -305,23 +306,21 @@ class _NativeSocket extends NativeFieldWrapperClass1 {
if (isErrorResponse(response)) {
throw createError(response, "Failed listing interfaces");
} else {
- var list = new List<NetworkInterface>();
var map = response.skip(1)
.fold(new Map<String, List<InternetAddress>>(), (map, result) {
var type = new InternetAddressType._from(result[0]);
var name = result[3];
+ var index = result[4];
var address = new _InternetAddress(
type, result[1], "", result[2]);
if (!includeLinkLocal && address.isLinkLocal) return map;
if (!includeLoopback && address.isLoopback) return map;
- map.putIfAbsent(name, () => new List<InternetAddress>());
- map[name].add(address);
+ map.putIfAbsent(
+ name, () => new _NetworkInterface(name, index));
+ map[name].addresses.add(address);
return map;
- })
- .forEach((name, addresses) {
- list.add(new _NetworkInterface(name, addresses));
});
- return list;
+ return map.values.toList();
}
});
}
« no previous file with comments | « runtime/bin/socket_macos.cc ('k') | runtime/bin/socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698