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

Side by Side Diff: net/http/http_auth.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 unified diff | Download patch
« no previous file with comments | « no previous file | net/http/http_auth_cache_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_auth.h" 5 #include "net/http/http_auth.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // of equal priority, then the handler based on the earlier challenge wins. 101 // of equal priority, then the handler based on the earlier challenge wins.
102 int cur_priority = GetSchemePriority(cur_auth_scheme); 102 int cur_priority = GetSchemePriority(cur_auth_scheme);
103 if (best.get() && best_priority >= cur_priority) 103 if (best.get() && best_priority >= cur_priority)
104 continue; 104 continue;
105 105
106 // Immediately trying to create a handler may be wasteful because we may see 106 // Immediately trying to create a handler may be wasteful because we may see
107 // a higher ranking challenge later on in the headers. However, this is 107 // a higher ranking challenge later on in the headers. However, this is
108 // rare. Servers typically specify higher priority schemes before lower 108 // rare. Servers typically specify higher priority schemes before lower
109 // priority schemes. 109 // priority schemes.
110 scoped_ptr<HttpAuthHandler> current_handler; 110 scoped_ptr<HttpAuthHandler> current_handler;
111 int rv = http_auth_handler_factory->CreateAuthHandler( 111 current_handler = http_auth_handler_factory->CreateAuthHandlerForScheme(
112 challenge_tokenizer, target, origin, 112 challenge_tokenizer.NormalizedScheme());
113 HttpAuthHandlerFactory::CREATE_CHALLENGE, 1, net_log, &current_handler); 113 if (!current_handler) {
114 net_log.AddEvent(NetLog::TYPE_AUTH_HANDLER_CREATION_FAILURE,
115 base::Bind(&AuthHandlerCreationFailureParams,
116 &cur_challenge, ERR_UNSUPPORTED_AUTH_SCHEME));
117 continue;
118 }
119 int rv = current_handler->HandleInitialChallenge(challenge_tokenizer,
120 target, origin, net_log);
114 if (rv != OK) { 121 if (rv != OK) {
115 net_log.AddEvent( 122 net_log.AddEvent(
116 NetLog::TYPE_AUTH_HANDLER_CREATION_FAILURE, 123 NetLog::TYPE_AUTH_HANDLER_CREATION_FAILURE,
117 base::Bind(&AuthHandlerCreationFailureParams, &cur_challenge, rv)); 124 base::Bind(&AuthHandlerCreationFailureParams, &cur_challenge, rv));
118 continue; 125 continue;
119 } 126 }
120 DCHECK(current_handler.get()); 127 DCHECK(current_handler.get());
121 DCHECK_EQ(cur_auth_scheme, current_handler->auth_scheme()); 128 DCHECK_EQ(cur_auth_scheme, current_handler->auth_scheme());
122 best.swap(current_handler); 129 best.swap(current_handler);
123 best_priority = cur_priority; 130 best_priority = cur_priority;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 204 }
198 } 205 }
199 206
200 // static 207 // static
201 bool HttpAuth::IsValidNormalizedScheme(const std::string& scheme) { 208 bool HttpAuth::IsValidNormalizedScheme(const std::string& scheme) {
202 return HttpUtil::IsToken(scheme.begin(), scheme.end()) && 209 return HttpUtil::IsToken(scheme.begin(), scheme.end()) &&
203 base::ToLowerASCII(scheme) == scheme; 210 base::ToLowerASCII(scheme) == scheme;
204 } 211 }
205 212
206 } // namespace net 213 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_auth_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698