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

Unified Diff: net/http/http_auth_handler_basic.cc

Issue 1393693002: [net/http auth] Split HttpAuthHandler creation from initialization. Base URL: https://chromium.googlesource.com/chromium/src.git@rename-auth-handler-methods
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 7525cb982e1d6beeab8e15ddb6ded009d6765838..fd900a42512cfd95ba2ece01156f9b5ba921d5a5 100644
--- a/net/http/http_auth_handler_basic.cc
+++ b/net/http/http_auth_handler_basic.cc
@@ -18,7 +18,7 @@ namespace net {
namespace {
-const char* const kBasicSchemeName = "basic";
+const char kBasicSchemeName[] = "basic";
// Parses a realm from an auth challenge, and converts to UTF8-encoding.
// Returns whether the realm is invalid or the parameters are invalid.
@@ -55,10 +55,12 @@ bool ParseRealm(const HttpAuthChallengeTokenizer& tokenizer,
} // namespace
int HttpAuthHandlerBasic::Init(const HttpAuthChallengeTokenizer& challenge) {
- auth_scheme_ = kBasicSchemeName;
return ParseChallenge(challenge);
}
+HttpAuthHandlerBasic::HttpAuthHandlerBasic()
+ : HttpAuthHandler(kBasicSchemeName) {}
+
int HttpAuthHandlerBasic::ParseChallenge(
const HttpAuthChallengeTokenizer& challenge) {
// Verify the challenge's auth-scheme.
@@ -107,22 +109,29 @@ HttpAuthHandlerBasic::Factory::Factory() {
HttpAuthHandlerBasic::Factory::~Factory() {
}
-int HttpAuthHandlerBasic::Factory::CreateAuthHandler(
- const HttpAuthChallengeTokenizer& challenge,
+scoped_ptr<HttpAuthHandler>
+HttpAuthHandlerBasic::Factory::CreateAuthHandlerForScheme(
+ const std::string& scheme) {
+ DCHECK(HttpAuth::IsValidNormalizedScheme(scheme));
+ if (scheme == kBasicSchemeName)
+ return make_scoped_ptr(new HttpAuthHandlerBasic());
+ return scoped_ptr<HttpAuthHandler>();
+}
+
+scoped_ptr<HttpAuthHandler>
+HttpAuthHandlerBasic::Factory::CreateAndInitPreemptiveAuthHandler(
+ HttpAuthCache::Entry* cache_entry,
+ const HttpAuthChallengeTokenizer& tokenizer,
HttpAuth::Target target,
- const GURL& origin,
- CreateReason reason,
- int digest_nonce_count,
- const BoundNetLog& net_log,
- scoped_ptr<HttpAuthHandler>* handler) {
- // TODO(cbentzel): Move towards model of parsing in the factory
- // method and only constructing when valid.
- scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerBasic());
- int result =
- tmp_handler->HandleInitialChallenge(challenge, target, origin, net_log);
- if (result == OK)
- handler->swap(tmp_handler);
- return result;
+ const BoundNetLog& net_log) {
+ if (cache_entry->scheme() != kBasicSchemeName)
+ return scoped_ptr<HttpAuthHandler>();
+ scoped_ptr<HttpAuthHandler> handler(new HttpAuthHandlerBasic());
+ int rv = handler->HandleInitialChallenge(tokenizer, target,
+ cache_entry->origin(), net_log);
+ if (rv == OK)
+ return handler;
+ return scoped_ptr<HttpAuthHandler>();
}
} // 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