diff options
-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); |