diff options
Diffstat (limited to 'net/http')
-rw-r--r-- | net/http/http_auth_handler.cc | 25 | ||||
-rw-r--r-- | net/http/http_auth_handler.h | 8 |
2 files changed, 32 insertions, 1 deletions
diff --git a/net/http/http_auth_handler.cc b/net/http/http_auth_handler.cc index a1e6c39..207232b 100644 --- a/net/http/http_auth_handler.cc +++ b/net/http/http_auth_handler.cc @@ -4,7 +4,9 @@ #include "net/http/http_auth_handler.h" +#include "base/histogram.h" #include "base/logging.h" +#include "base/string_util.h" #include "net/base/net_errors.h" namespace net { @@ -19,6 +21,15 @@ HttpAuthHandler::HttpAuthHandler() this, &HttpAuthHandler::OnGenerateAuthTokenComplete)) { } +HttpAuthHandler::~HttpAuthHandler() { +} + +//static +std::string HttpAuthHandler::GenerateHistogramNameFromScheme( + const std::string& scheme) { + return StringPrintf("Net.AuthGenerateToken_%s", scheme.c_str()); +} + bool HttpAuthHandler::InitFromChallenge( HttpAuth::ChallengeTokenizer* challenge, HttpAuth::Target target, @@ -39,6 +50,13 @@ bool HttpAuthHandler::InitFromChallenge( DCHECK(!ok || score_ != -1); DCHECK(!ok || properties_ != -1); + if (ok) + histogram_ = Histogram::FactoryTimeGet( + GenerateHistogramNameFromScheme(scheme()), + base::TimeDelta::FromMilliseconds(1), + base::TimeDelta::FromSeconds(10), 50, + Histogram::kUmaTargetedHistogramFlag); + return ok; } @@ -69,8 +87,10 @@ int HttpAuthHandler::GenerateAuthToken(const std::wstring* username, DCHECK(username != NULL || AllowsDefaultCredentials()); DCHECK(auth_token != NULL); DCHECK(original_callback_ == NULL); + DCHECK(histogram_.get()); original_callback_ = callback; net_log_.BeginEvent(EventTypeFromAuthTarget(target_), NULL); + generate_auth_token_start_ = base::TimeTicks::Now(); int rv = GenerateAuthTokenImpl(username, password, request, &wrapper_callback_, auth_token); if (rv != ERR_IO_PENDING) @@ -86,6 +106,11 @@ void HttpAuthHandler::OnGenerateAuthTokenComplete(int rv) { } void HttpAuthHandler::FinishGenerateAuthToken() { + // TOOD(cbentzel): Should this be done in OK case only? + DCHECK(histogram_.get()); + base::TimeDelta generate_auth_token_duration = + base::TimeTicks::Now() - generate_auth_token_start_; + histogram_->AddTime(generate_auth_token_duration); net_log_.EndEvent(EventTypeFromAuthTarget(target_), NULL); original_callback_ = NULL; } diff --git a/net/http/http_auth_handler.h b/net/http/http_auth_handler.h index 787877f..a6faebe 100644 --- a/net/http/http_auth_handler.h +++ b/net/http/http_auth_handler.h @@ -11,6 +11,8 @@ #include "net/base/net_log.h" #include "net/http/http_auth.h" +class Histogram; + namespace net { class HostResolver; @@ -23,7 +25,7 @@ struct HttpRequestInfo; class HttpAuthHandler { public: HttpAuthHandler(); - virtual ~HttpAuthHandler() {} + virtual ~HttpAuthHandler(); // Initializes the handler using a challenge issued by a server. // |challenge| must be non-NULL and have already tokenized the @@ -179,9 +181,13 @@ class HttpAuthHandler { private: void OnGenerateAuthTokenComplete(int rv); void FinishGenerateAuthToken(); + static std::string GenerateHistogramNameFromScheme(const std::string& scheme); CompletionCallback* original_callback_; CompletionCallbackImpl<HttpAuthHandler> wrapper_callback_; + // When GenerateAuthToken was called. + base::TimeTicks generate_auth_token_start_; + scoped_refptr<Histogram> histogram_; }; } // namespace net |