| 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..ecea33f84fff21e876faec9a4d05985dacd527fc 100644
|
| --- a/net/base/net_util_posix.cc
|
| +++ b/net/base/net_util_posix.cc
|
| @@ -9,6 +9,7 @@
|
| #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"
|
| @@ -22,6 +23,10 @@
|
| #include <net/if.h>
|
| #include <netinet/in.h>
|
|
|
| +#if defined(OS_ANDROID)
|
| +#include "net/android/network_library.h"
|
| +#endif
|
| +
|
| namespace net {
|
|
|
| bool FileURLToFilePath(const GURL& url, FilePath* path) {
|
| @@ -60,12 +65,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 network_interfaces(network_list, ";");
|
| + while (network_interfaces.GetNext()) {
|
| + std::string network_item = network_interfaces.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();
|
|
|