Chromium Code Reviews| Index: net/base/net_util_posix.cc |
| diff --git a/net/base/net_util_posix.cc b/net/base/net_util_posix.cc |
| index 8ff720f3e43d0e47e4707eecde5a5a36a25892ea..4de1d7b4c8103fc2a3000bb934807d0f4eacff6d 100644 |
| --- a/net/base/net_util_posix.cc |
| +++ b/net/base/net_util_posix.cc |
| @@ -9,9 +9,13 @@ |
| #include "base/eintr_wrapper.h" |
| #include "base/file_path.h" |
| #include "base/logging.h" |
| +#include "base/string_tokenizer.h" |
| #include "base/string_util.h" |
| #include "base/threading/thread_restrictions.h" |
| #include "googleurl/src/gurl.h" |
| +#if defined(OS_ANDROID) |
| +#include "net/android/network_library.h" |
| +#endif |
| #include "net/base/escape.h" |
| #include "net/base/ip_endpoint.h" |
| #include "net/base/net_errors.h" |
| @@ -60,12 +64,27 @@ bool FileURLToFilePath(const GURL& url, FilePath* path) { |
| bool GetNetworkList(NetworkInterfaceList* networks) { |
| #if defined(OS_ANDROID) |
| - // TODO: Android API doesn't support ifaddrs. This method was only used by |
| - // P2PMessage. Consider to implement it until really needed. The possible |
| - // approach is implementing the similar feature by |
| - // java.net.NetworkInterface through JNI. |
| - NOTIMPLEMENTED(); |
| - return false; |
| + std::string network_list = android::GetNetworkList(); |
| + StringTokenizer t(network_list, ";"); |
|
bulach
2012/09/11 10:16:36
nit: s/t/network_interfaces/
|
| + while(t.GetNext()) { |
|
bulach
2012/09/11 10:16:36
nit: space before first parens, "while (network_in
|
| + std::string network_item = t.token(); |
| + StringTokenizer network_tokenizer(network_item, ","); |
| + std::string name; |
| + if (!network_tokenizer.GetNext()) |
| + continue; |
| + name = network_tokenizer.token(); |
| + |
| + std::string literal_address; |
| + if (!network_tokenizer.GetNext()) |
| + continue; |
| + literal_address = network_tokenizer.token(); |
| + |
| + IPAddressNumber address; |
| + if (!ParseIPLiteralToNumber(literal_address, &address)) |
| + continue; |
| + networks->push_back(NetworkInterface(name, address)); |
| + } |
| + return true; |
| #else |
| // getifaddrs() may require IO operations. |
| base::ThreadRestrictions::AssertIOAllowed(); |