OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/base/address_list.h" | 5 #include "net/base/address_list.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 } | 105 } |
106 | 106 |
107 AddressList& AddressList::operator=(const AddressList& addresslist) { | 107 AddressList& AddressList::operator=(const AddressList& addresslist) { |
108 data_ = addresslist.data_; | 108 data_ = addresslist.data_; |
109 return *this; | 109 return *this; |
110 } | 110 } |
111 | 111 |
112 // static | 112 // static |
113 AddressList AddressList::CreateFromIPAddressList( | 113 AddressList AddressList::CreateFromIPAddressList( |
114 const IPAddressList& addresses, | 114 const IPAddressList& addresses, |
115 uint16 port) { | 115 const std::string& canonical_name) { |
cbentzel
2012/02/10 19:51:08
Why were you able to get rid of port here? Was it
szym
2012/02/10 21:49:36
It was only used in AsyncHostResolver, and the use
| |
116 DCHECK(!addresses.empty()); | 116 DCHECK(!addresses.empty()); |
117 struct addrinfo* head = NULL; | 117 struct addrinfo* head = NULL; |
118 struct addrinfo* next = NULL; | 118 struct addrinfo* next = NULL; |
119 | 119 |
120 for (IPAddressList::const_iterator it = addresses.begin(); | 120 for (IPAddressList::const_iterator it = addresses.begin(); |
121 it != addresses.end(); ++it) { | 121 it != addresses.end(); ++it) { |
122 if (head == NULL) { | 122 if (head == NULL) { |
123 head = next = CreateAddrInfo(*it, false); | 123 head = next = CreateAddrInfo(*it, false); |
124 if (!canonical_name.empty()) { | |
125 head->ai_canonname = do_strdup(canonical_name.c_str()); | |
126 } | |
124 } else { | 127 } else { |
125 next->ai_next = CreateAddrInfo(*it, false); | 128 next->ai_next = CreateAddrInfo(*it, false); |
126 next = next->ai_next; | 129 next = next->ai_next; |
127 } | 130 } |
128 } | 131 } |
129 | 132 |
130 SetPortForAllAddrinfos(head, port); | |
131 return AddressList(new Data(head, false)); | 133 return AddressList(new Data(head, false)); |
132 } | 134 } |
133 | 135 |
134 // static | 136 // static |
135 AddressList AddressList::CreateFromIPAddress( | 137 AddressList AddressList::CreateFromIPAddress( |
136 const IPAddressNumber& address, | 138 const IPAddressNumber& address, |
137 uint16 port) { | 139 uint16 port) { |
138 return CreateFromIPAddressWithCname(address, port, false); | 140 return CreateFromIPAddressWithCname(address, port, false); |
139 } | 141 } |
140 | 142 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 AddressList CreateAddressListUsingPort(const AddressList& src, int port) { | 284 AddressList CreateAddressListUsingPort(const AddressList& src, int port) { |
283 if (src.GetPort() == port) | 285 if (src.GetPort() == port) |
284 return src; | 286 return src; |
285 | 287 |
286 AddressList out = src; | 288 AddressList out = src; |
287 out.SetPort(port); | 289 out.SetPort(port); |
288 return out; | 290 return out; |
289 } | 291 } |
290 | 292 |
291 } // namespace net | 293 } // namespace net |
OLD | NEW |