diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-12 19:28:37 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-12 19:28:37 +0000 |
commit | 478df55e4d60812e54e84124a94e4d80598f073f (patch) | |
tree | bde05126ca5b9b942e60a2d1a51c87d63c6636e6 /net | |
parent | 293fcfef6c72804e47994fdc1010385365b7bd32 (diff) | |
download | chromium_src-478df55e4d60812e54e84124a94e4d80598f073f.zip chromium_src-478df55e4d60812e54e84124a94e4d80598f073f.tar.gz chromium_src-478df55e4d60812e54e84124a94e4d80598f073f.tar.bz2 |
Http cache: Add a histogram to see how headers related
to automatic resuming of requests are distributed.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/543021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36029 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_cache_transaction.cc | 44 | ||||
-rw-r--r-- | net/http/http_cache_transaction.h | 3 |
2 files changed, 47 insertions, 0 deletions
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc index 32808e8..d8c51ae 100644 --- a/net/http/http_cache_transaction.cc +++ b/net/http/http_cache_transaction.cc @@ -10,6 +10,7 @@ #include <unistd.h> #endif +#include "base/histogram.h" #include "base/ref_counted.h" #include "base/string_util.h" #include "base/time.h" @@ -1550,6 +1551,8 @@ int HttpCache::Transaction::DoSuccessfulSendRequest() { DoneWritingToEntry(false); } + HistogramHeaders(new_response->headers); + new_response_ = new_response; // Are we expecting a response to a conditional query? if (mode_ == READ_WRITE || mode_ == UPDATE) { @@ -1680,6 +1683,47 @@ int HttpCache::Transaction::DoSendRequestComplete(int result) { return result; } +// For a 200 response we'll add a histogram with one bit set per header: +// 0x01 Content-Length +// 0x02 Date +// 0x04 Last-Modified +// 0x08 Etag +// 0x10 Accept-Ranges: bytes +// 0x20 Accept-Ranges: none +// +// TODO(rvargas): remove after having some results. +void HttpCache::Transaction::HistogramHeaders( + const HttpResponseHeaders* headers) { + if (headers->response_code() != 200) + return; + + int64 content_length = headers->GetContentLength(); + int value = 0; + if (content_length > 0) + value = 1; + + Time date; + if (headers->GetDateValue(&date)) + value += 2; + if (headers->GetLastModifiedValue(&date)) + value += 4; + + std::string etag; + headers->EnumerateHeader(NULL, "etag", &etag); + if (!etag.empty()) + value += 8; + + std::string accept_ranges("Accept-Ranges"); + if (headers->HasHeaderValue(accept_ranges, "bytes")) + value += 0x10; + if (headers->HasHeaderValue(accept_ranges, "none")) + value += 0x20; + + // |value| goes from 0 to 63. Actually, the max value should be 47 (0x2f) + // but we'll see. + UMA_HISTOGRAM_ENUMERATION("HttpCache.ResponseHeaders", value, 65); +} + void HttpCache::Transaction::OnIOComplete(int result) { DoLoop(result); } diff --git a/net/http/http_cache_transaction.h b/net/http/http_cache_transaction.h index 14e39c7..0e7e51c 100644 --- a/net/http/http_cache_transaction.h +++ b/net/http/http_cache_transaction.h @@ -274,6 +274,9 @@ class HttpCache::Transaction : public HttpTransaction { // Performs the needed work after writing data to the cache. int DoCacheWriteCompleted(int result); + // Sends a histogram with info about the response headers. + void HistogramHeaders(const HttpResponseHeaders* headers); + // Called to signal completion of asynchronous IO. void OnIOComplete(int result); |