| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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/host_resolver.h" | 5 #include "net/base/host_resolver.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <ws2tcpip.h> | 8 #include <ws2tcpip.h> |
| 9 #include <wspiapi.h> // Needed for Win2k compat. | 9 #include <wspiapi.h> // Needed for Win2k compat. |
| 10 #elif defined(OS_POSIX) | 10 #elif defined(OS_POSIX) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 // Restrict result set to only this socket type to avoid duplicates. | 46 // Restrict result set to only this socket type to avoid duplicates. |
| 47 hints.ai_socktype = SOCK_STREAM; | 47 hints.ai_socktype = SOCK_STREAM; |
| 48 | 48 |
| 49 int err = getaddrinfo(host.c_str(), port.c_str(), &hints, out); | 49 int err = getaddrinfo(host.c_str(), port.c_str(), &hints, out); |
| 50 return err ? ERR_NAME_NOT_RESOLVED : OK; | 50 return err ? ERR_NAME_NOT_RESOLVED : OK; |
| 51 } | 51 } |
| 52 | 52 |
| 53 static int ResolveAddrInfo(HostMapper* mapper, const std::string& host, | 53 static int ResolveAddrInfo(HostMapper* mapper, const std::string& host, |
| 54 const std::string& port, struct addrinfo** out) { | 54 const std::string& port, struct addrinfo** out) { |
| 55 int rv; | |
| 56 if (mapper) { | 55 if (mapper) { |
| 57 rv = HostResolverProc(mapper->Map(host), port, out); | 56 std::string mapped_host = mapper->Map(host); |
| 57 |
| 58 if (mapped_host.empty()) |
| 59 return ERR_NAME_NOT_RESOLVED; |
| 60 |
| 61 return HostResolverProc(mapped_host, port, out); |
| 58 } else { | 62 } else { |
| 59 rv = HostResolverProc(host, port, out); | 63 return HostResolverProc(host, port, out); |
| 60 } | 64 } |
| 61 return rv; | |
| 62 } | 65 } |
| 63 | 66 |
| 64 //----------------------------------------------------------------------------- | 67 //----------------------------------------------------------------------------- |
| 65 | 68 |
| 66 class HostResolver::Request : | 69 class HostResolver::Request : |
| 67 public base::RefCountedThreadSafe<HostResolver::Request> { | 70 public base::RefCountedThreadSafe<HostResolver::Request> { |
| 68 public: | 71 public: |
| 69 Request(HostResolver* resolver, | 72 Request(HostResolver* resolver, |
| 70 const std::string& host, | 73 const std::string& host, |
| 71 const std::string& port, | 74 const std::string& port, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 NewRunnableMethod(request_.get(), &Request::DoLookup), true)) { | 199 NewRunnableMethod(request_.get(), &Request::DoLookup), true)) { |
| 197 NOTREACHED(); | 200 NOTREACHED(); |
| 198 request_ = NULL; | 201 request_ = NULL; |
| 199 return ERR_FAILED; | 202 return ERR_FAILED; |
| 200 } | 203 } |
| 201 | 204 |
| 202 return ERR_IO_PENDING; | 205 return ERR_IO_PENDING; |
| 203 } | 206 } |
| 204 | 207 |
| 205 } // namespace net | 208 } // namespace net |
| OLD | NEW |