Chromium Code Reviews| Index: net/http/http_basic_stream.cc |
| =================================================================== |
| --- net/http/http_basic_stream.cc (revision 88319) |
| +++ net/http/http_basic_stream.cc (working copy) |
| @@ -4,6 +4,7 @@ |
| #include "net/http/http_basic_stream.h" |
| +#include "base/metrics/histogram.h" |
| #include "base/stringprintf.h" |
| #include "net/base/io_buffer.h" |
| #include "net/base/net_errors.h" |
| @@ -13,6 +14,10 @@ |
| #include "net/http/http_util.h" |
| #include "net/socket/client_socket_handle.h" |
| +namespace { |
| +std::string g_warm_connection_field_trial_group; |
|
willchan no longer on Chromium
2011/06/09 15:08:54
This is not allowed by the style guide, see http:/
Gagan
2011/06/09 19:49:26
I was following http://codesearch.google.com/#OAMl
willchan no longer on Chromium
2011/06/10 15:05:55
You misunderstand. It doesn't matter if it's a fil
Gagan
2011/06/10 17:44:17
Ah sorry, missed it completely. Changed to global
|
| +} |
| + |
| namespace net { |
| HttpBasicStream::HttpBasicStream(ClientSocketHandle* connection, |
| @@ -34,6 +39,7 @@ |
| request_info_ = request_info; |
| parser_.reset(new HttpStreamParser(connection_.get(), request_info, |
| read_buf_, net_log)); |
| + bytes_read_offset_ = connection_->socket()->NumBytesRead(); |
| return OK; |
| } |
| @@ -50,6 +56,7 @@ |
| request_line_ = base::StringPrintf("%s %s HTTP/1.1\r\n", |
| request_info_->method.c_str(), |
| path.c_str()); |
| + response_ = response; |
| return parser_->SendRequest(request_line_, headers, request_body, response, |
| callback); |
| } |
| @@ -119,4 +126,33 @@ |
| return false; |
| } |
| +void HttpBasicStream::LogNumRttVsBytesMetrics() const { |
| + int64 total_bytes_read = connection_->socket()->NumBytesRead(); |
| + int64 bytes_received = total_bytes_read - bytes_read_offset_; |
| + int64 num_kb = bytes_received / 1024; |
| + double rtt = connection_->socket()->GetRTTInMs(); |
| + |
| + if (num_kb < 1024 && rtt > 0) { // Ignore responses > 1MB |
| + base::TimeDelta duration = base::Time::Now() - |
| + response_->request_time; |
| + double num_rtt = static_cast<double>(duration.InMilliseconds()) / rtt; |
| + int64 num_rtt_scaled = (4 * num_rtt); |
| + int val = 1024 * num_rtt_scaled + num_kb; // Supports ~500 RTT of 1418 B. |
|
Mike Belshe
2011/06/09 16:08:52
Can you add comments about why you're doing this m
Gagan
2011/06/09 19:49:26
num_rtt is a double, so scaling it by 4 to basical
|
| + |
| + std::string histogram = "Net.RTT_vs_KB_"; |
| + histogram += g_warm_connection_field_trial_group; |
| + HISTOGRAM_CUSTOM_COUNTS(histogram, val, 4096, 3048000, 1000); |
|
Mike Belshe
2011/06/09 16:08:52
bug: This histogram code is incorrect, note that
Gagan
2011/06/09 19:49:26
the counter is static, but its value is the return
|
| + LOG(ERROR) << request_line_ |
| + << "\nrtt = " << rtt << "\tnum_rtt = " << num_rtt |
| + << "\tnum_kb = " << num_kb << "\tval = " << val |
| + << "\ttotal bytes = " << total_bytes_read; |
| + } |
| +} |
| + |
| +// static |
| +void HttpBasicStream::set_warm_connection_field_trial_group( |
| + const std::string& group) { |
| + g_warm_connection_field_trial_group = group; |
| +} |
| + |
| } // namespace net |