This adds the plumbing needed to take data about completed outbound
network traffic to the task manager for tracking network usage.
There are a number of naming changes to help distinguish between what
is and isn't a "rate" and what is sent vs read vs transferred. Read being
incoming bytes, sent being outgoing bytes and transfered being either
read or sent bytes.
The "rates" are not calculated based on what is live on the network.
It is instead based on when requests are completed so large uploads
will all be registered in one refresh.
This update changes the struct BytesReadParam to BytesTrasferedParam
and stores both bytes read and bytes sent. It updates how the struct is
processed to handle the additional tracking of sent bytes.
Tasks have been changed to store the cumulative_bytes_read_ and
cumulative_bytes_sent_ which are stored on Refresh() to the
last_refresh_cumulative_bytes_sent_ and
last_refresh_cumulative_bytes_read_ . These are used to calculate
network_sent_rate_ and network_read_rate_ which are summed for the
network_usage_rate_.
Tasks no longer store a network usage of -1 to signify that they have
not had any network traffic, the utility of that flag no longer appears
to be used so it was removed. Because of this ReportsNetworkUsage() has been removed.
Tasks and Task Groups can now report their cumulative network usage.
BUG=720773
Review-Url: https://codereview.chromium.org/2905403002
Cr-Commit-Position: refs/heads/master@{#480988}
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
index 11dd8dc..fae150e 100644
--- a/chrome/browser/net/chrome_network_delegate.cc
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -359,6 +359,12 @@
void ChromeNetworkDelegate::OnNetworkBytesSent(net::URLRequest* request,
int64_t bytes_sent) {
+#if !defined(OS_ANDROID)
+ // Note: Currently, OnNetworkBytesSent is only implemented for HTTP jobs,
+ // not FTP or other types, so those kinds of bytes will not be reported here.
+ task_manager::TaskManagerInterface::OnRawBytesSent(*request, bytes_sent);
+#endif // !defined(OS_ANDROID)
+
ReportDataUsageStats(request, bytes_sent, 0 /* rx_bytes */);
}