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

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

Issue 10309002: Reimplements net::AddressList without struct addrinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing NET_EXPORT to *PortOnAddressList. Created 8 years, 7 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
OLDNEW
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/base/host_resolver_proc.h" 5 #include "net/base/host_resolver_proc.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/sys_byteorder.h" 10 #include "base/sys_byteorder.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 NOTREACHED(); 49 NOTREACHED();
50 return false; 50 return false;
51 } 51 }
52 } 52 }
53 53
54 return saw_v4_localhost != saw_v6_localhost; 54 return saw_v4_localhost != saw_v6_localhost;
55 } 55 }
56 56
57 } // namespace 57 } // namespace
58 58
59 void SetPortOnAddressList(uint16 port, AddressList* list) {
60 DCHECK(list);
61 for (AddressList::iterator it = list->begin(); it != list->end(); ++it) {
62 *it = IPEndPoint(it->address(), port);
63 }
64 }
65
66 void EnsurePortOnAddressList(uint16 port, AddressList* list) {
67 DCHECK(list);
68 if (list->empty() || list->front().port() == port)
69 return;
70 SetPortOnAddressList(port, list);
71 }
72
59 HostResolverProc* HostResolverProc::default_proc_ = NULL; 73 HostResolverProc* HostResolverProc::default_proc_ = NULL;
60 74
61 HostResolverProc::HostResolverProc(HostResolverProc* previous) { 75 HostResolverProc::HostResolverProc(HostResolverProc* previous) {
62 SetPreviousProc(previous); 76 SetPreviousProc(previous);
63 77
64 // Implicitly fall-back to the global default procedure. 78 // Implicitly fall-back to the global default procedure.
65 if (!previous) 79 if (!previous)
66 SetPreviousProc(default_proc_); 80 SetPreviousProc(default_proc_);
67 } 81 }
68 82
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 if (err != WSAHOST_NOT_FOUND && err != WSANO_DATA) 243 if (err != WSAHOST_NOT_FOUND && err != WSANO_DATA)
230 return ERR_NAME_RESOLUTION_FAILED; 244 return ERR_NAME_RESOLUTION_FAILED;
231 #elif defined(OS_POSIX) && !defined(OS_FREEBSD) 245 #elif defined(OS_POSIX) && !defined(OS_FREEBSD)
232 if (err != EAI_NONAME && err != EAI_NODATA) 246 if (err != EAI_NONAME && err != EAI_NODATA)
233 return ERR_NAME_RESOLUTION_FAILED; 247 return ERR_NAME_RESOLUTION_FAILED;
234 #endif 248 #endif
235 249
236 return ERR_NAME_NOT_RESOLVED; 250 return ERR_NAME_NOT_RESOLVED;
237 } 251 }
238 252
239 *addrlist = AddressList::CreateByAdoptingFromSystem(ai); 253 *addrlist = AddressList::CreateFromAddrinfo(ai);
240 return OK; 254 return OK;
241 } 255 }
242 256
243 } // namespace net 257 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698