OLD | NEW |
1 // Copyright (c) 2011 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 // XmppConnectionGenerator does the following algorithm: | 5 // XmppConnectionGenerator does the following algorithm: |
6 // proxy = ResolveProxyInformation(connection_options) | 6 // proxy = ResolveProxyInformation(connection_options) |
7 // for server in server_list | 7 // for server in server_list |
8 // get dns_addresses for server | 8 // get dns_addresses for server |
9 // connection_list = (dns_addresses X connection methods X proxy).shuffle() | 9 // connection_list = (dns_addresses X connection methods X proxy).shuffle() |
10 // for connection in connection_list | 10 // for connection in connection_list |
11 // yield connection | 11 // yield connection |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 first_dns_error_ = status; | 154 first_dns_error_ = status; |
155 return; | 155 return; |
156 } | 156 } |
157 | 157 |
158 // Slurp the addresses into a vector. | 158 // Slurp the addresses into a vector. |
159 std::vector<uint32> ip_list; | 159 std::vector<uint32> ip_list; |
160 for (const addrinfo* addr = address_list_.head(); | 160 for (const addrinfo* addr = address_list_.head(); |
161 addr != NULL; addr = addr->ai_next) { | 161 addr != NULL; addr = addr->ai_next) { |
162 const sockaddr_in& sockaddr = | 162 const sockaddr_in& sockaddr = |
163 *reinterpret_cast<const sockaddr_in*>(addr->ai_addr); | 163 *reinterpret_cast<const sockaddr_in*>(addr->ai_addr); |
164 uint32 ip = ntohl(sockaddr.sin_addr.s_addr); | 164 uint32 ip = talk_base::NetworkToHost32(sockaddr.sin_addr.s_addr); |
165 ip_list.push_back(ip); | 165 ip_list.push_back(ip); |
166 } | 166 } |
167 successfully_resolved_dns_ = !ip_list.empty(); | 167 successfully_resolved_dns_ = !ip_list.empty(); |
168 | 168 |
169 for (int i = 0; i < static_cast<int>(ip_list.size()); ++i) { | 169 for (int i = 0; i < static_cast<int>(ip_list.size()); ++i) { |
170 VLOG(1) << " ip " << i | 170 VLOG(1) << " ip " << i |
171 << " : " << talk_base::SocketAddress::IPToString(ip_list[i]); | 171 << " : " << talk_base::SocketAddress::IPToString(ip_list[i]); |
172 } | 172 } |
173 | 173 |
174 GenerateSettingsForIPList(ip_list); | 174 GenerateSettingsForIPList(ip_list); |
175 } | 175 } |
176 | 176 |
177 void XmppConnectionGenerator::GenerateSettingsForIPList( | 177 void XmppConnectionGenerator::GenerateSettingsForIPList( |
178 const std::vector<uint32>& ip_list) { | 178 const std::vector<uint32>& ip_list) { |
179 // Build the ip list. | 179 // Build the ip list. |
180 DCHECK(settings_list_.get()); | 180 DCHECK(settings_list_.get()); |
181 settings_index_ = -1; | 181 settings_index_ = -1; |
182 settings_list_->ClearPermutations(); | 182 settings_list_->ClearPermutations(); |
183 settings_list_->AddPermutations( | 183 settings_list_->AddPermutations( |
184 current_server_->server.host(), | 184 current_server_->server.host(), |
185 ip_list, | 185 ip_list, |
186 current_server_->server.port(), | 186 current_server_->server.port(), |
187 current_server_->special_port_magic, | 187 current_server_->special_port_magic, |
188 try_ssltcp_first_); | 188 try_ssltcp_first_); |
189 } | 189 } |
190 | 190 |
191 } // namespace notifier | 191 } // namespace notifier |
OLD | NEW |