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

Unified Diff: net/http/http_auth_handler_mock.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_mock.h ('k') | net/http/http_auth_handler_negotiate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_auth_handler_mock.cc
diff --git a/net/http/http_auth_handler_mock.cc b/net/http/http_auth_handler_mock.cc
index 2f37e93c052af50936b6bb091a64cbb79f813a0c..b26c0610c64604dc55d75eb636f5418ebf1ed84e 100644
--- a/net/http/http_auth_handler_mock.cc
+++ b/net/http/http_auth_handler_mock.cc
@@ -28,17 +28,17 @@ void HttpAuthHandlerMock::SetGenerateExpectation(bool async, int rv) {
}
HttpAuth::AuthorizationResult HttpAuthHandlerMock::HandleAnotherChallenge(
- HttpAuthChallengeTokenizer* challenge) {
+ const HttpAuthChallengeTokenizer& challenge) {
// If we receive a second challenge for a regular scheme, assume it's a
// rejection. Receiving an empty second challenge when expecting multiple
// rounds is also considered a rejection.
- if (!expect_multiple_challenges_ || challenge->base64_param().empty())
+ if (!expect_multiple_challenges_ || challenge.base64_param().empty())
return HttpAuth::AUTHORIZATION_RESULT_REJECT;
- if (!challenge->SchemeIs(auth_scheme_))
+ if (!challenge.SchemeIs(auth_scheme_))
return HttpAuth::AUTHORIZATION_RESULT_INVALID;
auth_token_ = auth_scheme_;
auth_token_.append(" continuation,");
- auth_token_.append(challenge->base64_param());
+ auth_token_.append(challenge.base64_param());
return HttpAuth::AUTHORIZATION_RESULT_ACCEPT;
}
@@ -54,28 +54,28 @@ bool HttpAuthHandlerMock::AllowsExplicitCredentials() {
return allows_explicit_credentials_;
}
-bool HttpAuthHandlerMock::Init(HttpAuthChallengeTokenizer* challenge) {
- EXPECT_TRUE(challenge->SchemeIs(expected_auth_scheme_))
- << "Mismatched scheme for challenge: " << challenge->challenge_text();
+int HttpAuthHandlerMock::Init(const HttpAuthChallengeTokenizer& challenge) {
+ EXPECT_TRUE(challenge.SchemeIs(expected_auth_scheme_))
+ << "Mismatched scheme for challenge: " << challenge.challenge_text();
EXPECT_TRUE(auth_scheme_.empty()) << "Init was already called.";
EXPECT_TRUE(HttpAuth::IsValidNormalizedScheme(expected_auth_scheme_))
<< "Invalid expected auth scheme.";
auth_scheme_ = expected_auth_scheme_;
auth_token_ = expected_auth_scheme_ + " auth_token";
- if (challenge->params_end() != challenge->params_begin()) {
+ if (challenge.params_end() != challenge.params_begin()) {
auth_token_ += ",";
- auth_token_.append(challenge->params_begin(), challenge->params_end());
+ auth_token_.append(challenge.params_begin(), challenge.params_end());
}
- return true;
+ return OK;
}
int HttpAuthHandlerMock::GenerateAuthTokenImpl(
const AuthCredentials* credentials,
- const HttpRequestInfo* request,
+ const HttpRequestInfo& request,
const CompletionCallback& callback,
std::string* auth_token) {
first_round_ = false;
- request_url_ = request->url;
+ request_url_ = request.url;
if (!credentials || credentials->Empty()) {
EXPECT_TRUE(AllowsDefaultCredentials()) << "Credentials must be specified "
@@ -138,7 +138,7 @@ bool HttpAuthHandlerMock::Factory::HaveAuthHandlers(
}
int HttpAuthHandlerMock::Factory::CreateAuthHandler(
- HttpAuthChallengeTokenizer* challenge,
+ const HttpAuthChallengeTokenizer& challenge,
HttpAuth::Target target,
const GURL& origin,
CreateReason reason,
@@ -152,10 +152,11 @@ int HttpAuthHandlerMock::Factory::CreateAuthHandler(
return ERR_UNEXPECTED;
scoped_ptr<HttpAuthHandler> tmp_handler(handler_list.front());
handler_list.weak_erase(handler_list.begin());
- 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_mock.h ('k') | net/http/http_auth_handler_negotiate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698