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

Side by Side Diff: net/http/http_auth_controller.cc

Issue 10916272: Remove HttpAuth::Scheme enum in favor of a string. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_auth_controller.h ('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.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // Note: The on-same-thread check is intentionally not using a lock 91 // Note: The on-same-thread check is intentionally not using a lock
92 // to protect access to first_thread. This method is meant to be only 92 // to protect access to first_thread. This method is meant to be only
93 // used on the same thread, in which case there are no race conditions. If 93 // used on the same thread, in which case there are no race conditions. If
94 // there are race conditions (say, a read completes during a partial write), 94 // there are race conditions (say, a read completes during a partial write),
95 // the DCHECK will correctly fail. 95 // the DCHECK will correctly fail.
96 static base::PlatformThreadId first_thread = 96 static base::PlatformThreadId first_thread =
97 base::PlatformThread::CurrentId(); 97 base::PlatformThread::CurrentId();
98 DCHECK_EQ(first_thread, base::PlatformThread::CurrentId()); 98 DCHECK_EQ(first_thread, base::PlatformThread::CurrentId());
99 #endif 99 #endif
100 100
101 HttpAuth::Scheme auth_scheme = handler->auth_scheme(); 101 std::string auth_scheme = handler->auth_scheme();
102 DCHECK(auth_scheme >= 0 && auth_scheme < HttpAuth::AUTH_SCHEME_MAX); 102
103 #if 0
104 // TODO(cbentzel): This would need to convert to string -> bucket conversion.
103 105
104 // Record start and rejection events for authentication. 106 // Record start and rejection events for authentication.
105 // 107 //
106 // The results map to: 108 // The results map to:
107 // Basic Start: 0 109 // Basic Start: 0
108 // Basic Reject: 1 110 // Basic Reject: 1
109 // Digest Start: 2 111 // Digest Start: 2
110 // Digest Reject: 3 112 // Digest Reject: 3
111 // NTLM Start: 4 113 // NTLM Start: 4
112 // NTLM Reject: 5 114 // NTLM Reject: 5
(...skipping 27 matching lines...) Expand all
140 // Negotiate Secure Server: 15 142 // Negotiate Secure Server: 15
141 if (auth_event != AUTH_EVENT_START) 143 if (auth_event != AUTH_EVENT_START)
142 return; 144 return;
143 static const int kTargetBucketsEnd = 145 static const int kTargetBucketsEnd =
144 HttpAuth::AUTH_SCHEME_MAX * AUTH_TARGET_MAX; 146 HttpAuth::AUTH_SCHEME_MAX * AUTH_TARGET_MAX;
145 AuthTarget auth_target = DetermineAuthTarget(handler); 147 AuthTarget auth_target = DetermineAuthTarget(handler);
146 int target_bucket = auth_scheme * AUTH_TARGET_MAX + auth_target; 148 int target_bucket = auth_scheme * AUTH_TARGET_MAX + auth_target;
147 DCHECK(target_bucket >= 0 && target_bucket < kTargetBucketsEnd); 149 DCHECK(target_bucket >= 0 && target_bucket < kTargetBucketsEnd);
148 UMA_HISTOGRAM_ENUMERATION("Net.HttpAuthTarget", target_bucket, 150 UMA_HISTOGRAM_ENUMERATION("Net.HttpAuthTarget", target_bucket,
149 kTargetBucketsEnd); 151 kTargetBucketsEnd);
152 #endif
150 } 153 }
151 154
152 } // namespace 155 } // namespace
153 156
154 HttpAuthController::HttpAuthController( 157 HttpAuthController::HttpAuthController(
155 HttpAuth::Target target, 158 HttpAuth::Target target,
156 const GURL& auth_url, 159 const GURL& auth_url,
157 HttpAuthCache* http_auth_cache, 160 HttpAuthCache* http_auth_cache,
158 HttpAuthHandlerFactory* http_auth_handler_factory) 161 HttpAuthHandlerFactory* http_auth_handler_factory)
159 : target_(target), 162 : target_(target),
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 499
497 void HttpAuthController::PopulateAuthChallenge() { 500 void HttpAuthController::PopulateAuthChallenge() {
498 DCHECK(CalledOnValidThread()); 501 DCHECK(CalledOnValidThread());
499 502
500 // Populates response_.auth_challenge with the authentication challenge info. 503 // Populates response_.auth_challenge with the authentication challenge info.
501 // This info is consumed by URLRequestHttpJob::GetAuthChallengeInfo(). 504 // This info is consumed by URLRequestHttpJob::GetAuthChallengeInfo().
502 505
503 auth_info_ = new AuthChallengeInfo; 506 auth_info_ = new AuthChallengeInfo;
504 auth_info_->is_proxy = (target_ == HttpAuth::AUTH_PROXY); 507 auth_info_->is_proxy = (target_ == HttpAuth::AUTH_PROXY);
505 auth_info_->challenger = HostPortPair::FromURL(auth_origin_); 508 auth_info_->challenger = HostPortPair::FromURL(auth_origin_);
506 auth_info_->scheme = HttpAuth::SchemeToString(handler_->auth_scheme()); 509 auth_info_->scheme = handler_->auth_scheme();
507 auth_info_->realm = handler_->realm(); 510 auth_info_->realm = handler_->realm();
508 } 511 }
509 512
510 bool HttpAuthController::DisableOnAuthHandlerResult(int result) { 513 bool HttpAuthController::DisableOnAuthHandlerResult(int result) {
511 DCHECK(CalledOnValidThread()); 514 DCHECK(CalledOnValidThread());
512 515
513 switch (result) { 516 switch (result) {
514 // Occurs with GSSAPI, if the user has not already logged in. 517 // Occurs with GSSAPI, if the user has not already logged in.
515 case ERR_MISSING_AUTH_CREDENTIALS: 518 case ERR_MISSING_AUTH_CREDENTIALS:
516 519
(...skipping 29 matching lines...) Expand all
546 callback_.Reset(); 549 callback_.Reset();
547 c.Run(result); 550 c.Run(result);
548 } 551 }
549 } 552 }
550 553
551 scoped_refptr<AuthChallengeInfo> HttpAuthController::auth_info() { 554 scoped_refptr<AuthChallengeInfo> HttpAuthController::auth_info() {
552 DCHECK(CalledOnValidThread()); 555 DCHECK(CalledOnValidThread());
553 return auth_info_; 556 return auth_info_;
554 } 557 }
555 558
556 bool HttpAuthController::IsAuthSchemeDisabled(HttpAuth::Scheme scheme) const { 559 bool HttpAuthController::IsAuthSchemeDisabled(const std::string& scheme) const {
557 DCHECK(CalledOnValidThread()); 560 DCHECK(CalledOnValidThread());
558 return disabled_schemes_.find(scheme) != disabled_schemes_.end(); 561 // TODO(cbentzel): Needed?
562 std::string lower_scheme = StringToLowerASCII(scheme);
563 return disabled_schemes_.find(lower_scheme) != disabled_schemes_.end();
559 } 564 }
560 565
561 void HttpAuthController::DisableAuthScheme(HttpAuth::Scheme scheme) { 566 void HttpAuthController::DisableAuthScheme(const std::string& scheme) {
562 DCHECK(CalledOnValidThread()); 567 DCHECK(CalledOnValidThread());
563 disabled_schemes_.insert(scheme); 568 // TODO(cbentzel): Needed?
569 std::string lower_scheme = StringToLowerASCII(scheme);
570 disabled_schemes_.insert(lower_scheme);
564 } 571 }
565 572
566 } // namespace net 573 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_controller.h ('k') | net/http/http_auth_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698