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

Unified Diff: net/http/http_auth_handler.cc

Issue 8990001: base::Bind: Convert most of net/http. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clang. Created 9 years 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/http/http_auth_handler.cc
diff --git a/net/http/http_auth_handler.cc b/net/http/http_auth_handler.cc
index c196b852cfb748e05da799b9ca1bd463ae20656b..0aad82920d4c1545177a8cbf2ab813b4a709e12c 100644
--- a/net/http/http_auth_handler.cc
+++ b/net/http/http_auth_handler.cc
@@ -4,6 +4,8 @@
#include "net/http/http_auth_handler.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/logging.h"
#include "net/base/net_errors.h"
@@ -13,11 +15,7 @@ HttpAuthHandler::HttpAuthHandler()
: auth_scheme_(HttpAuth::AUTH_SCHEME_MAX),
score_(-1),
target_(HttpAuth::AUTH_NONE),
- properties_(-1),
- original_callback_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- wrapper_callback_(
- this, &HttpAuthHandler::OnGenerateAuthTokenComplete)) {
+ properties_(-1) {
}
HttpAuthHandler::~HttpAuthHandler() {
@@ -62,19 +60,21 @@ NetLog::EventType EventTypeFromAuthTarget(HttpAuth::Target target) {
} // namespace
-int HttpAuthHandler::GenerateAuthToken(const AuthCredentials* credentials,
- const HttpRequestInfo* request,
- OldCompletionCallback* callback,
- std::string* auth_token) {
+int HttpAuthHandler::GenerateAuthToken(
+ const AuthCredentials* credentials, const HttpRequestInfo* request,
+ const CompletionCallback& callback, std::string* auth_token) {
// TODO(cbentzel): Enforce non-NULL callback after cleaning up SocketStream.
DCHECK(request);
DCHECK(credentials != NULL || AllowsDefaultCredentials());
DCHECK(auth_token != NULL);
- DCHECK(original_callback_ == NULL);
- original_callback_ = callback;
+ DCHECK(callback_.is_null());
+ callback_ = callback;
net_log_.BeginEvent(EventTypeFromAuthTarget(target_), NULL);
- int rv = GenerateAuthTokenImpl(credentials, request,
- &wrapper_callback_, auth_token);
+ int rv = GenerateAuthTokenImpl(
+ credentials, request,
+ base::Bind(&HttpAuthHandler::OnGenerateAuthTokenComplete,
+ base::Unretained(this)),
+ auth_token);
if (rv != ERR_IO_PENDING)
FinishGenerateAuthToken();
return rv;
@@ -93,16 +93,16 @@ bool HttpAuthHandler::AllowsExplicitCredentials() {
}
void HttpAuthHandler::OnGenerateAuthTokenComplete(int rv) {
- OldCompletionCallback* callback = original_callback_;
+ CompletionCallback callback = callback_;
FinishGenerateAuthToken();
- if (callback)
- callback->Run(rv);
+ if (!callback.is_null())
+ callback.Run(rv);
}
void HttpAuthHandler::FinishGenerateAuthToken() {
// TOOD(cbentzel): Should this be done in OK case only?
net_log_.EndEvent(EventTypeFromAuthTarget(target_), NULL);
- original_callback_ = NULL;
+ callback_.Reset();
}
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698