Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: net/http/http_basic_stream.cc

Issue 7255002: Revert 90373 - Warmth of a connection (cwnd) is estimated by the amount of data written to the so... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_basic_stream.h ('k') | net/http/http_network_transaction.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
OLDNEW
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"
8 #include "base/metrics/histogram.h"
9 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
10 #include "net/base/io_buffer.h" 8 #include "net/base/io_buffer.h"
11 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
12 #include "net/http/http_request_headers.h" 10 #include "net/http/http_request_headers.h"
13 #include "net/http/http_request_info.h" 11 #include "net/http/http_request_info.h"
14 #include "net/http/http_stream_parser.h" 12 #include "net/http/http_stream_parser.h"
15 #include "net/http/http_util.h" 13 #include "net/http/http_util.h"
16 #include "net/socket/client_socket_handle.h" 14 #include "net/socket/client_socket_handle.h"
17 #include "net/socket/client_socket_pool_base.h"
18 15
19 namespace net { 16 namespace net {
20 17
21 HttpBasicStream::HttpBasicStream(ClientSocketHandle* connection, 18 HttpBasicStream::HttpBasicStream(ClientSocketHandle* connection,
22 HttpStreamParser* parser, 19 HttpStreamParser* parser,
23 bool using_proxy) 20 bool using_proxy)
24 : read_buf_(new GrowableIOBuffer()), 21 : read_buf_(new GrowableIOBuffer()),
25 parser_(parser), 22 parser_(parser),
26 connection_(connection), 23 connection_(connection),
27 using_proxy_(using_proxy), 24 using_proxy_(using_proxy),
28 request_info_(NULL) { 25 request_info_(NULL) {
29 } 26 }
30 27
31 HttpBasicStream::~HttpBasicStream() {} 28 HttpBasicStream::~HttpBasicStream() {}
32 29
33 int HttpBasicStream::InitializeStream(const HttpRequestInfo* request_info, 30 int HttpBasicStream::InitializeStream(const HttpRequestInfo* request_info,
34 const BoundNetLog& net_log, 31 const BoundNetLog& net_log,
35 CompletionCallback* callback) { 32 CompletionCallback* callback) {
36 DCHECK(!parser_.get()); 33 DCHECK(!parser_.get());
37 request_info_ = request_info; 34 request_info_ = request_info;
38 parser_.reset(new HttpStreamParser(connection_.get(), request_info, 35 parser_.reset(new HttpStreamParser(connection_.get(), request_info,
39 read_buf_, net_log)); 36 read_buf_, net_log));
40 bytes_read_offset_ = connection_->socket()->NumBytesRead();
41 return OK; 37 return OK;
42 } 38 }
43 39
44 40
45 int HttpBasicStream::SendRequest(const HttpRequestHeaders& headers, 41 int HttpBasicStream::SendRequest(const HttpRequestHeaders& headers,
46 UploadDataStream* request_body, 42 UploadDataStream* request_body,
47 HttpResponseInfo* response, 43 HttpResponseInfo* response,
48 CompletionCallback* callback) { 44 CompletionCallback* callback) {
49 DCHECK(parser_.get()); 45 DCHECK(parser_.get());
50 DCHECK(request_info_); 46 DCHECK(request_info_);
51 const std::string path = using_proxy_ ? 47 const std::string path = using_proxy_ ?
52 HttpUtil::SpecForRequest(request_info_->url) : 48 HttpUtil::SpecForRequest(request_info_->url) :
53 HttpUtil::PathForRequest(request_info_->url); 49 HttpUtil::PathForRequest(request_info_->url);
54 request_line_ = base::StringPrintf("%s %s HTTP/1.1\r\n", 50 request_line_ = base::StringPrintf("%s %s HTTP/1.1\r\n",
55 request_info_->method.c_str(), 51 request_info_->method.c_str(),
56 path.c_str()); 52 path.c_str());
57 response_ = response;
58 return parser_->SendRequest(request_line_, headers, request_body, response, 53 return parser_->SendRequest(request_line_, headers, request_body, response,
59 callback); 54 callback);
60 } 55 }
61 56
62 uint64 HttpBasicStream::GetUploadProgress() const { 57 uint64 HttpBasicStream::GetUploadProgress() const {
63 return parser_->GetUploadProgress(); 58 return parser_->GetUploadProgress();
64 } 59 }
65 60
66 int HttpBasicStream::ReadResponseHeaders(CompletionCallback* callback) { 61 int HttpBasicStream::ReadResponseHeaders(CompletionCallback* callback) {
67 return parser_->ReadResponseHeaders(callback); 62 return parser_->ReadResponseHeaders(callback);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 112
118 void HttpBasicStream::GetSSLCertRequestInfo( 113 void HttpBasicStream::GetSSLCertRequestInfo(
119 SSLCertRequestInfo* cert_request_info) { 114 SSLCertRequestInfo* cert_request_info) {
120 parser_->GetSSLCertRequestInfo(cert_request_info); 115 parser_->GetSSLCertRequestInfo(cert_request_info);
121 } 116 }
122 117
123 bool HttpBasicStream::IsSpdyHttpStream() const { 118 bool HttpBasicStream::IsSpdyHttpStream() const {
124 return false; 119 return false;
125 } 120 }
126 121
127 void HttpBasicStream::LogNumRttVsBytesMetrics() const {
128 int socket_reuse_policy = GetSocketReusePolicy();
129 if (socket_reuse_policy > 2 || socket_reuse_policy < 0) {
130 LOG(ERROR) << "Invalid socket reuse policy";
131 return;
132 }
133
134 int64 total_bytes_read = connection_->socket()->NumBytesRead();
135 int64 bytes_received = total_bytes_read - bytes_read_offset_;
136 int64 num_kb = bytes_received / 1024;
137 double rtt = connection_->socket()->GetConnectTimeMicros().ToInternalValue();
138 rtt /= 1000.0;
139
140 if (num_kb < 1024 && rtt > 0) { // Ignore responses > 1MB
141 base::TimeDelta duration = base::Time::Now() -
142 response_->request_time;
143 double num_rtt = static_cast<double>(duration.InMilliseconds()) / rtt;
144 int64 num_rtt_scaled = (4 * num_rtt);
145
146 static const char* const kGroups[] = {
147 "warmest_socket", "warm_socket", "last_accessed_socket"
148 };
149 int bucket = (num_kb / 5) * 5;
150 const std::string histogram(StringPrintf("Net.Num_RTT_vs_KB_%s_%dKB",
151 kGroups[socket_reuse_policy],
152 bucket));
153 base::Histogram* counter = base::Histogram::FactoryGet(
154 histogram, 0, 1000, 2, base::Histogram::kUmaTargetedHistogramFlag);
155 DCHECK_EQ(histogram, counter->histogram_name());
156 counter->Add(num_rtt_scaled);
157
158 VLOG(2) << StringPrintf("%s\nrtt = %f\tnum_rtt = %f\t"
159 "num_kb = %" PRId64 "\t"
160 "total bytes = %" PRId64 "\t"
161 "histogram = %s",
162 request_line_.data(),
163 rtt, num_rtt, num_kb, total_bytes_read,
164 histogram.data());
165 }
166 }
167
168 } // namespace net 122 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_basic_stream.h ('k') | net/http/http_network_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698