diff options
author | wtc@google.com <wtc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-28 23:45:23 +0000 |
---|---|---|
committer | wtc@google.com <wtc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-28 23:45:23 +0000 |
commit | 1b66f31cbe79793c038c5afe09bb24dd2f25b8ad (patch) | |
tree | d4b9c2c0b8662a1b94bb66b8c096ebde76cc54ff /net | |
parent | 236ef33ebbb7aae61d5f36d8dc4570674819c810 (diff) | |
download | chromium_src-1b66f31cbe79793c038c5afe09bb24dd2f25b8ad.zip chromium_src-1b66f31cbe79793c038c5afe09bb24dd2f25b8ad.tar.gz chromium_src-1b66f31cbe79793c038c5afe09bb24dd2f25b8ad.tar.bz2 |
Create a constructor to construct an AddressList::Data
object with a struct addrinfo*.
Fix the comment for the port parameter of
HostResolver::Resolve.
Make some changes suggested by cpplint.
R=darin
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/address_list.cc | 3 | ||||
-rw-r--r-- | net/base/address_list.h | 3 | ||||
-rw-r--r-- | net/base/host_resolver.cc | 7 | ||||
-rw-r--r-- | net/base/host_resolver.h | 16 |
4 files changed, 17 insertions, 12 deletions
diff --git a/net/base/address_list.cc b/net/base/address_list.cc index 4281a7e..f365fb6 100644 --- a/net/base/address_list.cc +++ b/net/base/address_list.cc @@ -35,8 +35,7 @@ namespace net { void AddressList::Adopt(struct addrinfo* head) { - data_ = new Data(); - data_->head = head; + data_ = new Data(head); } AddressList::Data::~Data() { diff --git a/net/base/address_list.h b/net/base/address_list.h index d91137f..612ba6b 100644 --- a/net/base/address_list.h +++ b/net/base/address_list.h @@ -50,8 +50,11 @@ class AddressList { private: struct Data : public base::RefCountedThreadSafe<Data> { + explicit Data(struct addrinfo* ai) : head(ai) {} ~Data(); struct addrinfo* head; + private: + Data(); }; scoped_refptr<Data> data_; }; diff --git a/net/base/host_resolver.cc b/net/base/host_resolver.cc index f3091a6..101c5ec 100644 --- a/net/base/host_resolver.cc +++ b/net/base/host_resolver.cc @@ -84,8 +84,8 @@ struct HostResolver::Request : Request* r = reinterpret_cast<Request*>(param); // The HostResolver may have gone away. if (r->addresses) { - DCHECK(r->addresses); - r->addresses->Adopt(r->results); + if (r->error == OK) + r->addresses->Adopt(r->results); if (r->callback) r->callback->Run(r->error); } else if (r->results) { @@ -94,7 +94,7 @@ struct HostResolver::Request : r->Release(); } - static DWORD CALLBACK DoLookup(void* param) { + static DWORD WINAPI DoLookup(void* param) { Request* r = static_cast<Request*>(param); r->error = ResolveAddrInfo(r->host, r->port, &r->results); @@ -118,6 +118,7 @@ HostResolver::HostResolver() { HostResolver::~HostResolver() { if (request_) { + // Prevent the thread pool from running the callback. request_->addresses = NULL; request_->callback = NULL; } diff --git a/net/base/host_resolver.h b/net/base/host_resolver.h index 327e019..2ef7b86 100644 --- a/net/base/host_resolver.h +++ b/net/base/host_resolver.h @@ -27,8 +27,10 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef NET_BASE_HOST_RESOLVER_H__ -#define NET_BASE_HOST_RESOLVER_H__ +#ifndef NET_BASE_HOST_RESOLVER_H_ +#define NET_BASE_HOST_RESOLVER_H_ + +#include <string> #include "base/basictypes.h" #include "base/ref_counted.h" @@ -50,9 +52,9 @@ class HostResolver { ~HostResolver(); // Resolves the given hostname, filling out the |addresses| object upon - // success. The |port| parameter is optional (will be set as the sin_port - // field of the sockaddr_in{6} struct). Returns OK if successful or an error - // code upon failure. + // success. The |port| parameter will be set as the sin(6)_port field of + // the sockaddr_in{6} struct. Returns OK if successful or an error code + // upon failure. // // When callback is non-null, ERR_IO_PENDING is returned if the operation // could not be completed synchronously, in which case the result code will @@ -62,11 +64,11 @@ class HostResolver { AddressList* addresses, CompletionCallback* callback); private: - DISALLOW_EVIL_CONSTRUCTORS(HostResolver); struct Request; scoped_refptr<Request> request_; + DISALLOW_EVIL_CONSTRUCTORS(HostResolver); }; } // namespace net -#endif // NET_BASE_HOST_RESOLVER_H__ +#endif // NET_BASE_HOST_RESOLVER_H_ |