| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/http/http_basic_stream.h" | 5 #include "net/http/http_basic_stream.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 void HttpBasicStream::GetSSLCertRequestInfo( | 120 void HttpBasicStream::GetSSLCertRequestInfo( |
| 121 SSLCertRequestInfo* cert_request_info) { | 121 SSLCertRequestInfo* cert_request_info) { |
| 122 parser_->GetSSLCertRequestInfo(cert_request_info); | 122 parser_->GetSSLCertRequestInfo(cert_request_info); |
| 123 } | 123 } |
| 124 | 124 |
| 125 bool HttpBasicStream::IsSpdyHttpStream() const { | 125 bool HttpBasicStream::IsSpdyHttpStream() const { |
| 126 return false; | 126 return false; |
| 127 } | 127 } |
| 128 | 128 |
| 129 void HttpBasicStream::LogNumRttVsBytesMetrics() const { | 129 void HttpBasicStream::LogNumRttVsBytesMetrics() const { |
| 130 int socket_reuse_policy = GetSocketReusePolicy(); | 130 // Log rtt metrics here. |
| 131 if (socket_reuse_policy > 2 || socket_reuse_policy < 0) { | |
| 132 return; | |
| 133 } | |
| 134 | |
| 135 int64 total_bytes_read = connection_->socket()->NumBytesRead(); | |
| 136 int64 bytes_received = total_bytes_read - bytes_read_offset_; | |
| 137 int64 num_kb = bytes_received / 1024; | |
| 138 double rtt = connection_->socket()->GetConnectTimeMicros().ToInternalValue(); | |
| 139 rtt /= 1000.0; | |
| 140 | |
| 141 if (num_kb < 1024 && rtt > 0) { // Ignore responses > 1MB | |
| 142 base::TimeDelta duration = base::Time::Now() - | |
| 143 response_->request_time; | |
| 144 double num_rtt = static_cast<double>(duration.InMilliseconds()) / rtt; | |
| 145 int64 num_rtt_scaled = (4 * num_rtt); | |
| 146 | |
| 147 static const char* const kGroups[] = { | |
| 148 "warmest_socket", "warm_socket", "last_accessed_socket" | |
| 149 }; | |
| 150 int bucket = (num_kb / 5) * 5; | |
| 151 const std::string histogram(StringPrintf("Net.Num_RTT_vs_KB_%s_%dKB", | |
| 152 kGroups[socket_reuse_policy], | |
| 153 bucket)); | |
| 154 base::Histogram* counter = base::Histogram::FactoryGet( | |
| 155 histogram, 0, 1000, 2, base::Histogram::kUmaTargetedHistogramFlag); | |
| 156 DCHECK_EQ(histogram, counter->histogram_name()); | |
| 157 counter->Add(num_rtt_scaled); | |
| 158 | |
| 159 VLOG(2) << StringPrintf("%s\nrtt = %f\tnum_rtt = %f\t" | |
| 160 "num_kb = %" PRId64 "\t" | |
| 161 "total bytes = %" PRId64 "\t" | |
| 162 "histogram = %s", | |
| 163 request_line_.data(), | |
| 164 rtt, num_rtt, num_kb, total_bytes_read, | |
| 165 histogram.data()); | |
| 166 } | |
| 167 } | 131 } |
| 168 | 132 |
| 169 } // namespace net | 133 } // namespace net |
| OLD | NEW |