Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: net/base/address_list.cc

Issue 9369045: [net] HostResolverImpl + DnsTransaction + DnsConfigService = Asynchronous DNS ready for experiments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Denitted. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/address_list.h ('k') | net/base/address_list_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #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"
11 #include "net/base/sys_addrinfo.h" 11 #include "net/base/sys_addrinfo.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
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
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
OLDNEW
« no previous file with comments | « net/base/address_list.h ('k') | net/base/address_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698