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 #include <utility> |
8 | 9 |
9 #if defined(OS_MACOSX) || defined(OS_BSD) | 10 #if defined(OS_MACOSX) || defined(OS_BSD) |
10 #include <sys/socket.h> // Must be included before ifaddrs.h. | 11 #include <sys/socket.h> // Must be included before ifaddrs.h. |
11 #include <ifaddrs.h> | 12 #include <ifaddrs.h> |
12 #include <net/if.h> | 13 #include <net/if.h> |
13 #include <netinet/in_var.h> | 14 #include <netinet/in_var.h> |
14 #include <string.h> | 15 #include <string.h> |
15 #include <sys/ioctl.h> | 16 #include <sys/ioctl.h> |
16 #endif | 17 #endif |
17 | 18 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 // want to sort, even though the HostCache will be cleared soon. | 299 // want to sort, even though the HostCache will be cleared soon. |
299 FillPolicy(src.address(), &src_info); | 300 FillPolicy(src.address(), &src_info); |
300 } | 301 } |
301 info->src = &src_info; | 302 info->src = &src_info; |
302 | 303 |
303 if (info->address.size() == src.address().size()) { | 304 if (info->address.size() == src.address().size()) { |
304 info->common_prefix_length = std::min( | 305 info->common_prefix_length = std::min( |
305 CommonPrefixLength(info->address, src.address()), | 306 CommonPrefixLength(info->address, src.address()), |
306 info->src->prefix_length); | 307 info->src->prefix_length); |
307 } | 308 } |
308 sort_list.push_back(info.Pass()); | 309 sort_list.push_back(std::move(info)); |
309 } | 310 } |
310 | 311 |
311 std::stable_sort(sort_list.begin(), sort_list.end(), CompareDestinations); | 312 std::stable_sort(sort_list.begin(), sort_list.end(), CompareDestinations); |
312 | 313 |
313 AddressList result; | 314 AddressList result; |
314 for (size_t i = 0; i < sort_list.size(); ++i) | 315 for (size_t i = 0; i < sort_list.size(); ++i) |
315 result.push_back(IPEndPoint(sort_list[i]->address, 0 /* port */)); | 316 result.push_back(IPEndPoint(sort_list[i]->address, 0 /* port */)); |
316 | 317 |
317 callback.Run(true, result); | 318 callback.Run(true, result); |
318 } | 319 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 } | 395 } |
395 | 396 |
396 // static | 397 // static |
397 scoped_ptr<AddressSorter> AddressSorter::CreateAddressSorter() { | 398 scoped_ptr<AddressSorter> AddressSorter::CreateAddressSorter() { |
398 return scoped_ptr<AddressSorter>( | 399 return scoped_ptr<AddressSorter>( |
399 new AddressSorterPosix(ClientSocketFactory::GetDefaultFactory())); | 400 new AddressSorterPosix(ClientSocketFactory::GetDefaultFactory())); |
400 } | 401 } |
401 | 402 |
402 } // namespace net | 403 } // namespace net |
403 | 404 |
OLD | NEW |