| 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/host_resolver_impl.h" | 5 #include "net/base/host_resolver_impl.h" | 
| 6 | 6 | 
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) | 
| 8 #include <Winsock2.h> | 8 #include <Winsock2.h> | 
| 9 #elif defined(OS_POSIX) | 9 #elif defined(OS_POSIX) | 
| 10 #include <netdb.h> | 10 #include <netdb.h> | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 37 #include "net/base/net_util.h" | 37 #include "net/base/net_util.h" | 
| 38 | 38 | 
| 39 #if defined(OS_WIN) | 39 #if defined(OS_WIN) | 
| 40 #include "net/base/winsock_init.h" | 40 #include "net/base/winsock_init.h" | 
| 41 #endif | 41 #endif | 
| 42 | 42 | 
| 43 namespace net { | 43 namespace net { | 
| 44 | 44 | 
| 45 namespace { | 45 namespace { | 
| 46 | 46 | 
| 47 // Helper to create an AddressList that has a particular port. It has an |  | 
| 48 // optimization to avoid allocating a new address linked list when the |  | 
| 49 // port is already what we want. |  | 
| 50 AddressList CreateAddressListUsingPort(const AddressList& src, int port) { |  | 
| 51   if (src.GetPort() == port) |  | 
| 52     return src; |  | 
| 53 |  | 
| 54   AddressList out = src; |  | 
| 55   out.SetPort(port); |  | 
| 56   return out; |  | 
| 57 } |  | 
| 58 |  | 
| 59 // Helper to mutate the linked list contained by AddressList to the given | 47 // Helper to mutate the linked list contained by AddressList to the given | 
| 60 // port. Note that in general this is dangerous since the AddressList's | 48 // port. Note that in general this is dangerous since the AddressList's | 
| 61 // data might be shared (and you should use AddressList::SetPort). | 49 // data might be shared (and you should use AddressList::SetPort). | 
| 62 // | 50 // | 
| 63 // However since we allocated the AddressList ourselves we can safely | 51 // However since we allocated the AddressList ourselves we can safely | 
| 64 // do this optimization and avoid reallocating the list. | 52 // do this optimization and avoid reallocating the list. | 
| 65 void MutableSetPort(int port, AddressList* addrlist) { | 53 void MutableSetPort(int port, AddressList* addrlist) { | 
| 66   struct addrinfo* mutable_head = | 54   struct addrinfo* mutable_head = | 
| 67       const_cast<struct addrinfo*>(addrlist->head()); | 55       const_cast<struct addrinfo*>(addrlist->head()); | 
| 68   SetPortForAllAddrinfos(mutable_head, port); | 56   SetPortForAllAddrinfos(mutable_head, port); | 
| (...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1627     additional_resolver_flags_ |= HOST_RESOLVER_LOOPBACK_ONLY; | 1615     additional_resolver_flags_ |= HOST_RESOLVER_LOOPBACK_ONLY; | 
| 1628   } else { | 1616   } else { | 
| 1629     additional_resolver_flags_ &= ~HOST_RESOLVER_LOOPBACK_ONLY; | 1617     additional_resolver_flags_ &= ~HOST_RESOLVER_LOOPBACK_ONLY; | 
| 1630   } | 1618   } | 
| 1631 #endif | 1619 #endif | 
| 1632   AbortAllInProgressJobs(); | 1620   AbortAllInProgressJobs(); | 
| 1633   // |this| may be deleted inside AbortAllInProgressJobs(). | 1621   // |this| may be deleted inside AbortAllInProgressJobs(). | 
| 1634 } | 1622 } | 
| 1635 | 1623 | 
| 1636 }  // namespace net | 1624 }  // namespace net | 
| OLD | NEW | 
|---|