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

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

Issue 1629005: Revert 43826 - HostResolver now adds AI_CANONNAME to the hint flags if a requ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 8 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/sys_addrinfo.h" 10 #include "net/base/sys_addrinfo.h"
11 11
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 127
128 int AddressList::GetPort() const { 128 int AddressList::GetPort() const {
129 uint16* port_field = GetPortField(data_->head); 129 uint16* port_field = GetPortField(data_->head);
130 if (!port_field) 130 if (!port_field)
131 return -1; 131 return -1;
132 132
133 return ntohs(*port_field); 133 return ntohs(*port_field);
134 } 134 }
135 135
136 bool AddressList::GetCanonicalName(std::string* canonical_name) const {
137 DCHECK(canonical_name);
138 if (!data_->head || !data_->head->ai_canonname)
139 return false;
140 canonical_name->assign(data_->head->ai_canonname);
141 return true;
142 }
143
144 void AddressList::SetFrom(const AddressList& src, int port) { 136 void AddressList::SetFrom(const AddressList& src, int port) {
145 if (src.GetPort() == port) { 137 if (src.GetPort() == port) {
146 // We can reference the data from |src| directly. 138 // We can reference the data from |src| directly.
147 *this = src; 139 *this = src;
148 } else { 140 } else {
149 // Otherwise we need to make a copy in order to change the port number. 141 // Otherwise we need to make a copy in order to change the port number.
150 Copy(src.head(), true); 142 Copy(src.head(), true);
151 SetPort(port); 143 SetPort(port);
152 } 144 }
153 } 145 }
(...skipping 25 matching lines...) Expand all
179 AddressList::Data::~Data() { 171 AddressList::Data::~Data() {
180 // Call either freeaddrinfo(head), or FreeMyAddrinfo(head), depending who 172 // Call either freeaddrinfo(head), or FreeMyAddrinfo(head), depending who
181 // created the data. 173 // created the data.
182 if (is_system_created) 174 if (is_system_created)
183 freeaddrinfo(head); 175 freeaddrinfo(head);
184 else 176 else
185 FreeMyAddrinfo(head); 177 FreeMyAddrinfo(head);
186 } 178 }
187 179
188 } // namespace net 180 } // 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