Commit e56f0e67 authored by Jianfeng Wang's avatar Jianfeng Wang Committed by Commit Bot

Refactor APIs To Report Total Read Bytes

URLRequest job tracks the running total of raw network bytes that have
been read for each request. This is useful when determining the total
number of bytes that are still inflight.

Refactor related APIs to export this information to NQE.

Change-Id: I1209ca81429a22aa216c726c4381392d7f2e0e33
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1688356Reviewed-by: default avatarRyan Hamilton <rch@chromium.org>
Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Commit-Queue: Jianfeng Wang <jfwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678055}
parent 4c7bf0db
......@@ -330,7 +330,9 @@ bool NetworkQualityEstimator::IsHangingRequest(
return true;
}
void NetworkQualityEstimator::NotifyHeadersReceived(const URLRequest& request) {
void NetworkQualityEstimator::NotifyHeadersReceived(
const URLRequest& request,
int64_t prefilter_total_bytes_read) {
TRACE_EVENT0(NetTracingCategory(),
"NetworkQualityEstimator::NotifyHeadersReceived");
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......@@ -377,7 +379,9 @@ void NetworkQualityEstimator::NotifyHeadersReceived(const URLRequest& request) {
request, request.GetExpectedContentSize());
}
void NetworkQualityEstimator::NotifyBytesRead(const URLRequest& request) {
void NetworkQualityEstimator::NotifyBytesRead(
const URLRequest& request,
int64_t prefilter_total_bytes_read) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
throughput_analyzer_->NotifyBytesRead(request);
}
......
......@@ -179,12 +179,16 @@ class NET_EXPORT_PRIVATE NetworkQualityEstimator
RTTAndThroughputEstimatesObserver* observer);
// Notifies NetworkQualityEstimator that the response header of |request| has
// been received.
void NotifyHeadersReceived(const URLRequest& request);
// been received. Reports the total prefilter network bytes that have been
// read for the response of |request|.
void NotifyHeadersReceived(const URLRequest& request,
int64_t prefilter_total_bytes_read);
// Notifies NetworkQualityEstimator that unfiltered bytes have been read for
// |request|.
void NotifyBytesRead(const URLRequest& request);
// |request|. Reports the total prefilter network bytes that have been read
// for the response of |request|.
void NotifyBytesRead(const URLRequest& request,
int64_t prefilter_total_bytes_read);
// Notifies NetworkQualityEstimator that the headers of |request| are about to
// be sent.
......
......@@ -721,10 +721,10 @@ void URLRequestJob::RecordBytesRead(int bytes_read) {
if (request_->context()->network_quality_estimator()) {
if (prefilter_bytes_read() == bytes_read) {
request_->context()->network_quality_estimator()->NotifyHeadersReceived(
*request_);
*request_, prefilter_bytes_read());
} else {
request_->context()->network_quality_estimator()->NotifyBytesRead(
*request_);
*request_, prefilter_bytes_read());
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment