Chromium Code Reviews| Index: runtime/bin/socket_patch.dart |
| diff --git a/runtime/bin/socket_patch.dart b/runtime/bin/socket_patch.dart |
| index daa59c6448fc629f34fc8e14f99d17e80099c26a..3566fa076f84069c9a060b77b020282fcc19c47c 100644 |
| --- a/runtime/bin/socket_patch.dart |
| +++ b/runtime/bin/socket_patch.dart |
| @@ -19,13 +19,43 @@ patch class RawSocket { |
| patch class InternetAddress { |
| + /* patch */ static InternetAddress get LOOPBACK_IP_V4 { |
| + return _InternetAddress.LOOPBACK_IP_V4; |
| + } |
| + |
| + /* patch */ static InternetAddress get LOOPBACK_IP_V6 { |
| + return _InternetAddress.LOOPBACK_IP_V6; |
| + } |
| + |
| + /* patch */ static InternetAddress get ANY_IP_V4 { |
| + return _InternetAddress.ANY_IP_V4; |
| + } |
| + |
| + /* patch */ static InternetAddress get ANY_IP_V6 { |
| + return _InternetAddress.ANY_IP_V6; |
| + } |
| + |
| /* patch */ static Future<List<InternetAddress>> lookup( |
| - String host, {InternetAddressType type: InternetAddressType.IPv4}) { |
| + String host, {InternetAddressType type: InternetAddressType.IP_V4}) { |
| return _NativeSocket.lookup(host, type: type); |
| } |
| } |
| class _InternetAddress implements InternetAddress { |
| + static const int _ADDRESS_LOOPBACK_IP_V4 = 0; |
| + static const int _ADDRESS_LOOPBACK_IP_V6 = 1; |
| + static const int _ADDRESS_ANY_IP_V4 = 2; |
| + static const int _ADDRESS_ANY_IP_V6 = 3; |
| + |
| + static _InternetAddress LOOPBACK_IP_V4 = |
| + new _InternetAddress.fixed(_ADDRESS_LOOPBACK_IP_V4); |
| + static _InternetAddress LOOPBACK_IP_V6 = |
| + new _InternetAddress.fixed(_ADDRESS_LOOPBACK_IP_V6); |
| + static _InternetAddress ANY_IP_V4 = |
| + new _InternetAddress.fixed(_ADDRESS_ANY_IP_V4); |
| + static _InternetAddress ANY_IP_V6 = |
| + new _InternetAddress.fixed(_ADDRESS_ANY_IP_V6); |
| + |
| final InternetAddressType type; |
| final String address; |
| final String host; |
| @@ -36,9 +66,30 @@ class _InternetAddress implements InternetAddress { |
| String this.host, |
| List<int> this._sockaddr_storage); |
| + factory _InternetAddress.fixed(int id) { |
| + switch (id) { |
|
Bill Hesse
2013/04/30 10:50:22
Maybe put var sockaddr = _fixed(id)
before the swi
Søren Gjesse
2013/04/30 11:28:41
Done.
|
| + case _ADDRESS_LOOPBACK_IP_V4: |
| + return new _InternetAddress( |
| + InternetAddressType.IP_V4, "127.0.0.1", "localhost", _fixed(id)); |
| + case _ADDRESS_LOOPBACK_IP_V6: |
| + return new _InternetAddress( |
| + InternetAddressType.IP_V6, "::1", "ip6-localhost", _fixed(id)); |
| + case _ADDRESS_ANY_IP_V4: |
| + return new _InternetAddress( |
| + InternetAddressType.IP_V4, "0.0.0.0", "0.0.0.0", _fixed(id)); |
| + case _ADDRESS_ANY_IP_V6: |
| + return new _InternetAddress( |
| + InternetAddressType.IP_V6, "::", "::", _fixed(id)); |
| + default: |
| + assert(false); |
|
Bill Hesse
2013/04/30 10:50:22
There is no return value for the function in the d
Søren Gjesse
2013/04/30 11:28:41
Done.
|
| + } |
| + } |
| + |
| String toString() { |
| return "InternetAddress('$address', ${type.name})"; |
| } |
| + |
| + static Uint8List _fixed(int id) native "InternetAddress_Fixed"; |
| } |
| @@ -105,7 +156,7 @@ class _NativeSocket extends NativeFieldWrapperClass1 { |
| static SendPort socketService; |
| static Future<List<InternetAddress>> lookup( |
| - String host, {InternetAddressType type: InternetAddressType.IPv4}) { |
| + String host, {InternetAddressType type: InternetAddressType.IP_V4}) { |
| ensureSocketService(); |
| return socketService.call([HOST_NAME_LOOKUP, host, type._value]) |
| .then((response) { |