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

Side by Side Diff: net/http/http_auth_controller.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 | « net/http/http_auth_cache_unittest.cc ('k') | net/http/http_auth_controller_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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_controller.h" 5 #include "net/http/http_auth_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
13 #include "net/base/auth.h" 13 #include "net/base/auth.h"
14 #include "net/base/net_util.h" 14 #include "net/base/net_util.h"
15 #include "net/dns/host_resolver.h" 15 #include "net/dns/host_resolver.h"
16 #include "net/http/http_auth_challenge_tokenizer.h"
16 #include "net/http/http_auth_handler.h" 17 #include "net/http/http_auth_handler.h"
17 #include "net/http/http_auth_handler_factory.h" 18 #include "net/http/http_auth_handler_factory.h"
18 #include "net/http/http_network_session.h" 19 #include "net/http/http_network_session.h"
19 #include "net/http/http_request_headers.h" 20 #include "net/http/http_request_headers.h"
20 #include "net/http/http_request_info.h" 21 #include "net/http/http_request_info.h"
21 #include "net/http/http_response_headers.h" 22 #include "net/http/http_response_headers.h"
22 23
23 namespace net { 24 namespace net {
24 25
25 namespace { 26 namespace {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // SelectPreemptiveAuth() is on the critical path for each request, so it 245 // SelectPreemptiveAuth() is on the critical path for each request, so it
245 // is expected to be fast. LookupByPath() is fast in the common case, since 246 // is expected to be fast. LookupByPath() is fast in the common case, since
246 // the number of http auth cache entries is expected to be very small. 247 // the number of http auth cache entries is expected to be very small.
247 // (For most users in fact, it will be 0.) 248 // (For most users in fact, it will be 0.)
248 HttpAuthCache::Entry* entry = http_auth_cache_->LookupByPath( 249 HttpAuthCache::Entry* entry = http_auth_cache_->LookupByPath(
249 auth_origin_, auth_path_); 250 auth_origin_, auth_path_);
250 if (!entry) 251 if (!entry)
251 return false; 252 return false;
252 253
253 // Try to create a handler using the previous auth challenge. 254 // Try to create a handler using the previous auth challenge.
254 scoped_ptr<HttpAuthHandler> handler_preemptive; 255 std::string challenge = entry->auth_challenge();
255 int rv_create = http_auth_handler_factory_-> 256 HttpAuthChallengeTokenizer tokenizer(challenge.begin(), challenge.end());
256 CreatePreemptiveAuthHandlerFromString(entry->auth_challenge(), target_, 257 scoped_ptr<HttpAuthHandler> handler_preemptive =
257 auth_origin_, 258 http_auth_handler_factory_->CreateAndInitPreemptiveAuthHandler(
258 entry->IncrementNonceCount(), 259 entry, tokenizer, target_, net_log);
259 net_log, &handler_preemptive); 260 if (!handler_preemptive)
260 if (rv_create != OK)
261 return false; 261 return false;
262 262
263 // Set the state 263 // Set the state
264 identity_.source = HttpAuth::IDENT_SRC_PATH_LOOKUP; 264 identity_.source = HttpAuth::IDENT_SRC_PATH_LOOKUP;
265 identity_.invalid = false; 265 identity_.invalid = false;
266 identity_.credentials = entry->credentials(); 266 identity_.credentials = entry->credentials();
267 handler_.swap(handler_preemptive); 267 handler_.swap(handler_preemptive);
268 return true; 268 return true;
269 } 269 }
270 270
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 DCHECK(CalledOnValidThread()); 605 DCHECK(CalledOnValidThread());
606 disabled_schemes_.Add(scheme); 606 disabled_schemes_.Add(scheme);
607 } 607 }
608 608
609 void HttpAuthController::DisableEmbeddedIdentity() { 609 void HttpAuthController::DisableEmbeddedIdentity() {
610 DCHECK(CalledOnValidThread()); 610 DCHECK(CalledOnValidThread());
611 embedded_identity_used_ = true; 611 embedded_identity_used_ = true;
612 } 612 }
613 613
614 } // namespace net 614 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_cache_unittest.cc ('k') | net/http/http_auth_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698