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

Unified Diff: net/base/host_resolver_impl.cc

Issue 8549004: base::Bind: Convert HostResolver::Resolve. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: net/base/host_resolver_impl.cc
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc
index c4002e6a57cf33ebbabe84e39bbcaf43d0f3b25e..c7929500b1ebea41d9959cbda349f1619cf374ec 100644
--- a/net/base/host_resolver_impl.cc
+++ b/net/base/host_resolver_impl.cc
@@ -16,6 +16,7 @@
#include "base/basictypes.h"
#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/compiler_specific.h"
#include "base/debug/debugger.h"
#include "base/debug/stack_trace.h"
@@ -263,7 +264,7 @@ class HostResolverImpl::Request {
const BoundNetLog& request_net_log,
int id,
const RequestInfo& info,
- OldCompletionCallback* callback,
+ const CompletionCallback& callback,
AddressList* addresses)
: source_net_log_(source_net_log),
request_net_log_(request_net_log),
@@ -277,12 +278,12 @@ class HostResolverImpl::Request {
// Mark the request as cancelled.
void MarkAsCancelled() {
job_ = NULL;
- callback_ = NULL;
addresses_ = NULL;
+ callback_.Reset();
}
bool was_cancelled() const {
- return callback_ == NULL;
+ return callback_.is_null();
}
void set_job(Job* job) {
@@ -294,9 +295,9 @@ class HostResolverImpl::Request {
void OnComplete(int error, const AddressList& addrlist) {
if (error == OK)
*addresses_ = CreateAddressListUsingPort(addrlist, port());
- OldCompletionCallback* callback = callback_;
+ CompletionCallback callback = callback_;
MarkAsCancelled();
- callback->Run(error);
+ callback.Run(error);
}
int port() const {
@@ -337,7 +338,7 @@ class HostResolverImpl::Request {
Job* job_;
// The user's callback to invoke when the request completes.
- OldCompletionCallback* callback_;
+ CompletionCallback callback_;
// The address list to save result into.
AddressList* addresses_;
@@ -1130,12 +1131,12 @@ void HostResolverImpl::SetPoolConstraints(JobPoolIndex pool_index,
int HostResolverImpl::Resolve(const RequestInfo& info,
AddressList* addresses,
- OldCompletionCallback* callback,
+ const CompletionCallback& callback,
RequestHandle* out_req,
const BoundNetLog& source_net_log) {
DCHECK(addresses);
- DCHECK(callback);
DCHECK(CalledOnValidThread());
+ DCHECK_EQ(false, callback.is_null());
willchan no longer on Chromium 2011/11/14 16:45:12 DCHECK(!callback.is_null())? What you have is fine
// Choose a unique ID number for observers to see.
int request_id = next_request_id_++;
@@ -1159,7 +1160,7 @@ int HostResolverImpl::Resolve(const RequestInfo& info,
return rv;
}
- // Create a handle for this request, and pass it back to the user if they
+ // Create a handle for this request, and pass it back to the user if they
// asked for it (out_req != NULL).
Request* req = new Request(source_net_log, request_net_log, request_id, info,
callback, addresses);

Powered by Google App Engine
This is Rietveld 408576698