diff options
author | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-01 10:23:38 +0000 |
---|---|---|
committer | cbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-01 10:23:38 +0000 |
commit | cb2825c8499998dfbb015eeead451c1a13886efc (patch) | |
tree | dda2a4f643a639af9f53956a1977e287339741cc /net | |
parent | 8c59a5d3bb7d8b49e6487558dc0d4cfeac7d8a98 (diff) | |
download | chromium_src-cb2825c8499998dfbb015eeead451c1a13886efc.zip chromium_src-cb2825c8499998dfbb015eeead451c1a13886efc.tar.gz chromium_src-cb2825c8499998dfbb015eeead451c1a13886efc.tar.bz2 |
Add histograms for HTTP authentication token generation times.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/2838018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51357 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-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 |