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

Unified Diff: net/http/http_network_transaction.cc

Issue 1327763003: Added and implemented URLRequest::GetTotalSentBytes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@spdy_sent_bytes_impl
Patch Set: Addressed nits Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_network_transaction.h ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_network_transaction.cc
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index 29967723d4b1a1b7a6eec19cedb8044247672746..bbe48b2f9aa6ac1a76898aa73556f368e0600bbf 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -149,6 +149,7 @@ HttpNetworkTransaction::HttpNetworkTransaction(RequestPriority priority,
request_headers_(),
read_buf_len_(0),
total_received_bytes_(0),
+ total_sent_bytes_(0),
next_state_(STATE_NONE),
establishing_tunnel_(false),
websocket_handshake_stream_base_create_helper_(NULL) {
@@ -305,6 +306,7 @@ void HttpNetworkTransaction::DidDrainBodyForAuthRestart(bool keep_alive) {
if (stream_.get()) {
total_received_bytes_ += stream_->GetTotalReceivedBytes();
+ total_sent_bytes_ += stream_->GetTotalSentBytes();
HttpStream* new_stream = NULL;
if (keep_alive && stream_->CanReuseConnection()) {
// We should call connection_->set_idle_time(), but this doesn't occur
@@ -320,8 +322,9 @@ void HttpNetworkTransaction::DidDrainBodyForAuthRestart(bool keep_alive) {
stream_->Close(true);
next_state_ = STATE_CREATE_STREAM;
} else {
- // Renewed streams shouldn't carry over received bytes.
+ // Renewed streams shouldn't carry over sent or received bytes.
DCHECK_EQ(0, new_stream->GetTotalReceivedBytes());
+ DCHECK_EQ(0, new_stream->GetTotalSentBytes());
next_state_ = STATE_INIT_STREAM;
}
stream_.reset(new_stream);
@@ -391,6 +394,13 @@ int64 HttpNetworkTransaction::GetTotalReceivedBytes() const {
return total_received_bytes;
}
+int64_t HttpNetworkTransaction::GetTotalSentBytes() const {
+ int64_t total_sent_bytes = total_sent_bytes_;
+ if (stream_)
+ total_sent_bytes += stream_->GetTotalSentBytes();
+ return total_sent_bytes;
+}
+
void HttpNetworkTransaction::DoneReading() {}
const HttpResponseInfo* HttpNetworkTransaction::GetResponseInfo() const {
@@ -475,8 +485,10 @@ void HttpNetworkTransaction::OnStreamReady(const SSLConfig& used_ssl_config,
DCHECK_EQ(STATE_CREATE_STREAM_COMPLETE, next_state_);
DCHECK(stream_request_.get());
- if (stream_)
+ if (stream_) {
total_received_bytes_ += stream_->GetTotalReceivedBytes();
+ total_sent_bytes_ += stream_->GetTotalSentBytes();
+ }
stream_.reset(stream);
server_ssl_config_ = used_ssl_config;
proxy_info_ = used_proxy_info;
@@ -575,8 +587,10 @@ void HttpNetworkTransaction::OnHttpsProxyTunnelResponse(
response_ = response_info;
server_ssl_config_ = used_ssl_config;
proxy_info_ = used_proxy_info;
- if (stream_)
+ if (stream_) {
total_received_bytes_ += stream_->GetTotalReceivedBytes();
+ total_sent_bytes_ += stream_->GetTotalSentBytes();
+ }
stream_.reset(stream);
stream_request_.reset(); // we're done with the stream request
OnIOComplete(ERR_HTTPS_PROXY_TUNNEL_RESPONSE);
@@ -810,8 +824,10 @@ int HttpNetworkTransaction::DoInitStreamComplete(int result) {
result = HandleIOError(result);
// The stream initialization failed, so this stream will never be useful.
- if (stream_)
- total_received_bytes_ += stream_->GetTotalReceivedBytes();
+ if (stream_) {
+ total_received_bytes_ += stream_->GetTotalReceivedBytes();
+ total_sent_bytes_ += stream_->GetTotalSentBytes();
+ }
stream_.reset();
}
@@ -1185,6 +1201,7 @@ int HttpNetworkTransaction::HandleCertificateRequest(int error) {
// renegotiation.
DCHECK(!stream_request_.get());
total_received_bytes_ += stream_->GetTotalReceivedBytes();
+ total_sent_bytes_ += stream_->GetTotalSentBytes();
stream_->Close(true);
stream_.reset();
}
@@ -1408,8 +1425,10 @@ int HttpNetworkTransaction::HandleIOError(int error) {
void HttpNetworkTransaction::ResetStateForRestart() {
ResetStateForAuthRestart();
- if (stream_)
+ if (stream_) {
total_received_bytes_ += stream_->GetTotalReceivedBytes();
+ total_sent_bytes_ += stream_->GetTotalSentBytes();
+ }
stream_.reset();
}
« no previous file with comments | « net/http/http_network_transaction.h ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698