| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include <string> | 7 #include <string> | 
| 8 | 8 | 
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" | 
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" | 
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 85     event_.Signal(); | 85     event_.Signal(); | 
| 86   } | 86   } | 
| 87 | 87 | 
| 88   virtual int Resolve(const std::string& hostname, | 88   virtual int Resolve(const std::string& hostname, | 
| 89                       AddressFamily address_family, | 89                       AddressFamily address_family, | 
| 90                       HostResolverFlags host_resolver_flags, | 90                       HostResolverFlags host_resolver_flags, | 
| 91                       AddressList* addrlist, | 91                       AddressList* addrlist, | 
| 92                       int* os_error) { | 92                       int* os_error) { | 
| 93     event_.Wait(); | 93     event_.Wait(); | 
| 94     { | 94     { | 
| 95       AutoLock l(lock_); | 95       base::AutoLock l(lock_); | 
| 96       capture_list_.push_back(CaptureEntry(hostname, address_family)); | 96       capture_list_.push_back(CaptureEntry(hostname, address_family)); | 
| 97     } | 97     } | 
| 98     return ResolveUsingPrevious(hostname, address_family, | 98     return ResolveUsingPrevious(hostname, address_family, | 
| 99                                 host_resolver_flags, addrlist, os_error); | 99                                 host_resolver_flags, addrlist, os_error); | 
| 100   } | 100   } | 
| 101 | 101 | 
| 102   CaptureList GetCaptureList() const { | 102   CaptureList GetCaptureList() const { | 
| 103     CaptureList copy; | 103     CaptureList copy; | 
| 104     { | 104     { | 
| 105       AutoLock l(lock_); | 105       base::AutoLock l(lock_); | 
| 106       copy = capture_list_; | 106       copy = capture_list_; | 
| 107     } | 107     } | 
| 108     return copy; | 108     return copy; | 
| 109   } | 109   } | 
| 110 | 110 | 
| 111  private: | 111  private: | 
| 112   ~CapturingHostResolverProc() {} | 112   ~CapturingHostResolverProc() {} | 
| 113 | 113 | 
| 114   CaptureList capture_list_; | 114   CaptureList capture_list_; | 
| 115   mutable Lock lock_; | 115   mutable base::Lock lock_; | 
| 116   base::WaitableEvent event_; | 116   base::WaitableEvent event_; | 
| 117 }; | 117 }; | 
| 118 | 118 | 
| 119 // This resolver function creates an IPv4 address, whose numeral value | 119 // This resolver function creates an IPv4 address, whose numeral value | 
| 120 // describes a hash of the requested hostname, and the value of the requested | 120 // describes a hash of the requested hostname, and the value of the requested | 
| 121 // address_family. | 121 // address_family. | 
| 122 // | 122 // | 
| 123 // The resolved address for (hostname, address_family) will take the form: | 123 // The resolved address for (hostname, address_family) will take the form: | 
| 124 //    192.x.y.z | 124 //    192.x.y.z | 
| 125 // | 125 // | 
| (...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1655   EXPECT_EQ("192.1.98.2", NetAddressToString(addrlist[1].head())); | 1655   EXPECT_EQ("192.1.98.2", NetAddressToString(addrlist[1].head())); | 
| 1656   EXPECT_EQ("192.1.98.1", NetAddressToString(addrlist[2].head())); | 1656   EXPECT_EQ("192.1.98.1", NetAddressToString(addrlist[2].head())); | 
| 1657   EXPECT_EQ("192.1.98.1", NetAddressToString(addrlist[3].head())); | 1657   EXPECT_EQ("192.1.98.1", NetAddressToString(addrlist[3].head())); | 
| 1658 } | 1658 } | 
| 1659 | 1659 | 
| 1660 // TODO(cbentzel): Test a mix of requests with different HostResolverFlags. | 1660 // TODO(cbentzel): Test a mix of requests with different HostResolverFlags. | 
| 1661 | 1661 | 
| 1662 }  // namespace | 1662 }  // namespace | 
| 1663 | 1663 | 
| 1664 }  // namespace net | 1664 }  // namespace net | 
| OLD | NEW | 
|---|