| 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.h" | 5 #include "net/dns/address_sorter.h" |
| 6 | 6 |
| 7 #include <winsock2.h> | 7 #include <winsock2.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 closesocket(sock); | 102 closesocket(sock); |
| 103 } | 103 } |
| 104 | 104 |
| 105 // Executed on the calling thread. | 105 // Executed on the calling thread. |
| 106 void OnComplete() { | 106 void OnComplete() { |
| 107 AddressList list; | 107 AddressList list; |
| 108 if (success_) { | 108 if (success_) { |
| 109 list.reserve(output_buffer_->iAddressCount); | 109 list.reserve(output_buffer_->iAddressCount); |
| 110 for (int i = 0; i < output_buffer_->iAddressCount; ++i) { | 110 for (int i = 0; i < output_buffer_->iAddressCount; ++i) { |
| 111 IPEndPoint ipe; | 111 IPEndPoint ipe; |
| 112 ipe.FromSockAddr(output_buffer_->Address[i].lpSockaddr, | 112 bool result = |
| 113 output_buffer_->Address[i].iSockaddrLength); | 113 ipe.FromSockAddr(output_buffer_->Address[i].lpSockaddr, |
| 114 output_buffer_->Address[i].iSockaddrLength); |
| 115 DCHECK(result) << "Unable to roundtrip between IPEndPoint and " |
| 116 << "SOCKET_ADDRESS!"; |
| 114 // Unmap V4MAPPED IPv6 addresses so that Happy Eyeballs works. | 117 // Unmap V4MAPPED IPv6 addresses so that Happy Eyeballs works. |
| 115 if (IsIPv4Mapped(ipe.address())) { | 118 if (IsIPv4Mapped(ipe.address())) { |
| 116 ipe = IPEndPoint(ConvertIPv4MappedToIPv4(ipe.address()), | 119 ipe = IPEndPoint(ConvertIPv4MappedToIPv4(ipe.address()), |
| 117 ipe.port()); | 120 ipe.port()); |
| 118 } | 121 } |
| 119 list.push_back(ipe); | 122 list.push_back(ipe); |
| 120 } | 123 } |
| 121 } | 124 } |
| 122 callback_.Run(success_, list); | 125 callback_.Run(success_, list); |
| 123 } | 126 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 192 |
| 190 // static | 193 // static |
| 191 scoped_ptr<AddressSorter> AddressSorter::CreateAddressSorter() { | 194 scoped_ptr<AddressSorter> AddressSorter::CreateAddressSorter() { |
| 192 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 195 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
| 193 return scoped_ptr<AddressSorter>(new AddressSorterWinXP()); | 196 return scoped_ptr<AddressSorter>(new AddressSorterWinXP()); |
| 194 return scoped_ptr<AddressSorter>(new AddressSorterWin()); | 197 return scoped_ptr<AddressSorter>(new AddressSorterWin()); |
| 195 } | 198 } |
| 196 | 199 |
| 197 } // namespace net | 200 } // namespace net |
| 198 | 201 |
| OLD | NEW |