| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/dns/address_sorter_posix.h" | 5 #include "net/dns/address_sorter_posix.h" |
| 6 | 6 |
| 7 #include <netinet/in.h> | 7 #include <netinet/in.h> |
| 8 | 8 |
| 9 #if defined(OS_MACOSX) || defined(OS_BSD) | 9 #if defined(OS_MACOSX) || defined(OS_BSD) |
| 10 #include <sys/socket.h> // Must be included before ifaddrs.h. | 10 #include <sys/socket.h> // Must be included before ifaddrs.h. |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 // want to sort, even though the HostCache will be cleared soon. | 296 // want to sort, even though the HostCache will be cleared soon. |
| 297 FillPolicy(src.address(), &src_info); | 297 FillPolicy(src.address(), &src_info); |
| 298 } | 298 } |
| 299 info->src = &src_info; | 299 info->src = &src_info; |
| 300 | 300 |
| 301 if (info->address.size() == src.address().size()) { | 301 if (info->address.size() == src.address().size()) { |
| 302 info->common_prefix_length = std::min( | 302 info->common_prefix_length = std::min( |
| 303 CommonPrefixLength(info->address, src.address()), | 303 CommonPrefixLength(info->address, src.address()), |
| 304 info->src->prefix_length); | 304 info->src->prefix_length); |
| 305 } | 305 } |
| 306 sort_list.push_back(info.release()); | 306 sort_list.push_back(info.Pass()); |
| 307 } | 307 } |
| 308 | 308 |
| 309 std::stable_sort(sort_list.begin(), sort_list.end(), CompareDestinations); | 309 std::stable_sort(sort_list.begin(), sort_list.end(), CompareDestinations); |
| 310 | 310 |
| 311 AddressList result; | 311 AddressList result; |
| 312 for (size_t i = 0; i < sort_list.size(); ++i) | 312 for (size_t i = 0; i < sort_list.size(); ++i) |
| 313 result.push_back(IPEndPoint(sort_list[i]->address, 0 /* port */)); | 313 result.push_back(IPEndPoint(sort_list[i]->address, 0 /* port */)); |
| 314 | 314 |
| 315 callback.Run(true, result); | 315 callback.Run(true, result); |
| 316 } | 316 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 } | 392 } |
| 393 | 393 |
| 394 // static | 394 // static |
| 395 scoped_ptr<AddressSorter> AddressSorter::CreateAddressSorter() { | 395 scoped_ptr<AddressSorter> AddressSorter::CreateAddressSorter() { |
| 396 return scoped_ptr<AddressSorter>( | 396 return scoped_ptr<AddressSorter>( |
| 397 new AddressSorterPosix(ClientSocketFactory::GetDefaultFactory())); | 397 new AddressSorterPosix(ClientSocketFactory::GetDefaultFactory())); |
| 398 } | 398 } |
| 399 | 399 |
| 400 } // namespace net | 400 } // namespace net |
| 401 | 401 |
| OLD | NEW |