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

Unified Diff: net/http/http_auth_controller.cc

Issue 1157333005: [net/http auth] Use strings to identify authentication schemes. Base URL: https://chromium.googlesource.com/chromium/src.git@master
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_controller.h ('k') | net/http/http_auth_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_auth_controller.cc
diff --git a/net/http/http_auth_controller.cc b/net/http/http_auth_controller.cc
index 4d9d6be1f0da308cc26d6f0abef5774f03cbbbe9..0b3d5c09aed8afb092005d18cddf9202e0dd4266 100644
--- a/net/http/http_auth_controller.cc
+++ b/net/http/http_auth_controller.cc
@@ -67,6 +67,41 @@ enum AuthTarget {
AUTH_TARGET_MAX,
};
+// Known authentication schemes.
+enum AuthScheme {
+ AUTH_SCHEME_BASIC = 0,
+ AUTH_SCHEME_DIGEST,
+ AUTH_SCHEME_NTLM,
+ AUTH_SCHEME_NEGOTIATE,
+ AUTH_SCHEME_SPDYPROXY_DEPRECATED,
+ AUTH_SCHEME_MOCK,
+
+ // Add new schemes above this line and don't remove any values. This
+ // enumeration is used for UMA.
+ AUTH_SCHEME_MAX,
+};
+
+AuthScheme AuthSchemeForUMA(const std::string& scheme) {
+ DCHECK(HttpAuth::IsValidNormalizedScheme(scheme));
+
+ if (scheme == "basic")
+ return AUTH_SCHEME_BASIC;
+
+ if (scheme == "digest")
+ return AUTH_SCHEME_DIGEST;
+
+ if (scheme == "ntlm")
+ return AUTH_SCHEME_NTLM;
+
+ if (scheme == "negotiate")
+ return AUTH_SCHEME_NEGOTIATE;
+
+ if (scheme == "mock")
+ return AUTH_SCHEME_MOCK;
+
+ return AUTH_SCHEME_MAX;
+}
+
AuthTarget DetermineAuthTarget(const HttpAuthHandler* handler) {
switch (handler->target()) {
case HttpAuth::AUTH_PROXY:
@@ -98,8 +133,10 @@ void HistogramAuthEvent(HttpAuthHandler* handler, AuthEvent auth_event) {
DCHECK_EQ(first_thread, base::PlatformThread::CurrentId());
#endif
- HttpAuth::Scheme auth_scheme = handler->auth_scheme();
- DCHECK(auth_scheme >= 0 && auth_scheme < HttpAuth::AUTH_SCHEME_MAX);
+ AuthScheme auth_scheme = AuthSchemeForUMA(handler->auth_scheme());
+ // Only measure known auth schemes.
+ if (auth_scheme == AUTH_SCHEME_MAX)
+ return;
// Record start and rejection events for authentication.
//
@@ -112,8 +149,7 @@ void HistogramAuthEvent(HttpAuthHandler* handler, AuthEvent auth_event) {
// NTLM Reject: 5
// Negotiate Start: 6
// Negotiate Reject: 7
- static const int kEventBucketsEnd =
- HttpAuth::AUTH_SCHEME_MAX * AUTH_EVENT_MAX;
+ static const int kEventBucketsEnd = AUTH_SCHEME_MAX * AUTH_EVENT_MAX;
int event_bucket = auth_scheme * AUTH_EVENT_MAX + auth_event;
DCHECK(event_bucket >= 0 && event_bucket < kEventBucketsEnd);
UMA_HISTOGRAM_ENUMERATION("Net.HttpAuthCount", event_bucket,
@@ -140,8 +176,7 @@ void HistogramAuthEvent(HttpAuthHandler* handler, AuthEvent auth_event) {
// Negotiate Secure Server: 15
if (auth_event != AUTH_EVENT_START)
return;
- static const int kTargetBucketsEnd =
- HttpAuth::AUTH_SCHEME_MAX * AUTH_TARGET_MAX;
+ static const int kTargetBucketsEnd = AUTH_SCHEME_MAX * AUTH_TARGET_MAX;
AuthTarget auth_target = DetermineAuthTarget(handler);
int target_bucket = auth_scheme * AUTH_TARGET_MAX + auth_target;
DCHECK(target_bucket >= 0 && target_bucket < kTargetBucketsEnd);
@@ -510,7 +545,7 @@ void HttpAuthController::PopulateAuthChallenge() {
auth_info_ = new AuthChallengeInfo;
auth_info_->is_proxy = (target_ == HttpAuth::AUTH_PROXY);
auth_info_->challenger = HostPortPair::FromURL(auth_origin_);
- auth_info_->scheme = HttpAuth::SchemeToString(handler_->auth_scheme());
+ auth_info_->scheme = handler_->auth_scheme();
auth_info_->realm = handler_->realm();
}
@@ -560,14 +595,14 @@ scoped_refptr<AuthChallengeInfo> HttpAuthController::auth_info() {
return auth_info_;
}
-bool HttpAuthController::IsAuthSchemeDisabled(HttpAuth::Scheme scheme) const {
+bool HttpAuthController::IsAuthSchemeDisabled(const std::string& scheme) const {
DCHECK(CalledOnValidThread());
- return disabled_schemes_.find(scheme) != disabled_schemes_.end();
+ return disabled_schemes_.Contains(scheme);
}
-void HttpAuthController::DisableAuthScheme(HttpAuth::Scheme scheme) {
+void HttpAuthController::DisableAuthScheme(const std::string& scheme) {
DCHECK(CalledOnValidThread());
- disabled_schemes_.insert(scheme);
+ disabled_schemes_.Add(scheme);
}
void HttpAuthController::DisableEmbeddedIdentity() {
« 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