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

Unified Diff: net/url_request/url_request_job.cc

Issue 1362793003: Notify NetworkDelegate when bytes have been sent over the network. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased on master 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/url_request/url_request_job.h ('k') | net/url_request/url_request_test_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_job.cc
diff --git a/net/url_request/url_request_job.cc b/net/url_request/url_request_job.cc
index 5adda9ae05a46e6ea8048720666092ed531d0483..fd6ed750f0b087b46aa2552bca20174ea60d2c89 100644
--- a/net/url_request/url_request_job.cc
+++ b/net/url_request/url_request_job.cc
@@ -73,6 +73,7 @@ URLRequestJob::URLRequestJob(URLRequest* request,
expected_content_size_(-1),
network_delegate_(network_delegate),
last_notified_total_received_bytes_(0),
+ last_notified_total_sent_bytes_(0),
weak_factory_(this) {
base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
if (power_monitor)
@@ -948,6 +949,7 @@ void URLRequestJob::MaybeNotifyNetworkBytes() {
if (!request_ || !network_delegate_)
return;
+ // Report any new received bytes.
int64_t total_received_bytes = GetTotalReceivedBytes();
DCHECK_GE(total_received_bytes, last_notified_total_received_bytes_);
if (total_received_bytes > last_notified_total_received_bytes_) {
@@ -955,6 +957,15 @@ void URLRequestJob::MaybeNotifyNetworkBytes() {
*request_, total_received_bytes - last_notified_total_received_bytes_);
}
last_notified_total_received_bytes_ = total_received_bytes;
+
+ // Report any new sent bytes.
+ int64_t total_sent_bytes = GetTotalSentBytes();
+ DCHECK_GE(total_sent_bytes, last_notified_total_sent_bytes_);
+ if (total_sent_bytes > last_notified_total_sent_bytes_) {
+ network_delegate_->NotifyNetworkBytesSent(
+ *request_, total_sent_bytes - last_notified_total_sent_bytes_);
+ }
+ last_notified_total_sent_bytes_ = total_sent_bytes;
}
} // namespace net
« no previous file with comments | « net/url_request/url_request_job.h ('k') | net/url_request/url_request_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698