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

Unified Diff: net/http/http_auth_handler_basic.cc

Issue 1383613002: [net/http auth] Cleanup. Method names, and constness. Base URL: https://chromium.googlesource.com/chromium/src.git@mock-auth-handler-generalization
Patch Set: Created 5 years, 2 months 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
« no previous file with comments | « net/http/http_auth_handler_basic.h ('k') | net/http/http_auth_handler_basic_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_auth_handler_basic.cc
diff --git a/net/http/http_auth_handler_basic.cc b/net/http/http_auth_handler_basic.cc
index 4c509f46bb2d7b2e42bd7f4511575258adc567a3..7525cb982e1d6beeab8e15ddb6ded009d6765838 100644
--- a/net/http/http_auth_handler_basic.cc
+++ b/net/http/http_auth_handler_basic.cc
@@ -54,32 +54,32 @@ bool ParseRealm(const HttpAuthChallengeTokenizer& tokenizer,
} // namespace
-bool HttpAuthHandlerBasic::Init(HttpAuthChallengeTokenizer* challenge) {
+int HttpAuthHandlerBasic::Init(const HttpAuthChallengeTokenizer& challenge) {
auth_scheme_ = kBasicSchemeName;
return ParseChallenge(challenge);
}
-bool HttpAuthHandlerBasic::ParseChallenge(
- HttpAuthChallengeTokenizer* challenge) {
+int HttpAuthHandlerBasic::ParseChallenge(
+ const HttpAuthChallengeTokenizer& challenge) {
// Verify the challenge's auth-scheme.
- if (!challenge->SchemeIs(kBasicSchemeName))
- return false;
+ if (!challenge.SchemeIs(kBasicSchemeName))
+ return ERR_INVALID_RESPONSE;
std::string realm;
- if (!ParseRealm(*challenge, &realm))
- return false;
+ if (!ParseRealm(challenge, &realm))
+ return ERR_INVALID_RESPONSE;
realm_ = realm;
- return true;
+ return OK;
}
HttpAuth::AuthorizationResult HttpAuthHandlerBasic::HandleAnotherChallenge(
- HttpAuthChallengeTokenizer* challenge) {
+ const HttpAuthChallengeTokenizer& challenge) {
// Basic authentication is always a single round, so any responses
// should be treated as a rejection. However, if the new challenge
// is for a different realm, then indicate the realm change.
std::string realm;
- if (!ParseRealm(*challenge, &realm))
+ if (!ParseRealm(challenge, &realm))
return HttpAuth::AUTHORIZATION_RESULT_INVALID;
return (realm_ != realm)?
HttpAuth::AUTHORIZATION_RESULT_DIFFERENT_REALM:
@@ -87,8 +87,10 @@ HttpAuth::AuthorizationResult HttpAuthHandlerBasic::HandleAnotherChallenge(
}
int HttpAuthHandlerBasic::GenerateAuthTokenImpl(
- const AuthCredentials* credentials, const HttpRequestInfo*,
- const CompletionCallback&, std::string* auth_token) {
+ const AuthCredentials* credentials,
+ const HttpRequestInfo&,
+ const CompletionCallback&,
+ std::string* auth_token) {
DCHECK(credentials);
// TODO(eroman): is this the right encoding of username/password?
std::string base64_username_password;
@@ -106,7 +108,7 @@ HttpAuthHandlerBasic::Factory::~Factory() {
}
int HttpAuthHandlerBasic::Factory::CreateAuthHandler(
- HttpAuthChallengeTokenizer* challenge,
+ const HttpAuthChallengeTokenizer& challenge,
HttpAuth::Target target,
const GURL& origin,
CreateReason reason,
@@ -116,10 +118,11 @@ int HttpAuthHandlerBasic::Factory::CreateAuthHandler(
// TODO(cbentzel): Move towards model of parsing in the factory
// method and only constructing when valid.
scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerBasic());
- if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log))
- return ERR_INVALID_RESPONSE;
- handler->swap(tmp_handler);
- return OK;
+ int result =
+ tmp_handler->HandleInitialChallenge(challenge, target, origin, net_log);
+ if (result == OK)
+ handler->swap(tmp_handler);
+ return result;
}
} // namespace net
« no previous file with comments | « net/http/http_auth_handler_basic.h ('k') | net/http/http_auth_handler_basic_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698