Index: content/browser/loader/mojo_async_resource_handler.cc |
diff --git a/content/browser/loader/mojo_async_resource_handler.cc b/content/browser/loader/mojo_async_resource_handler.cc |
index ea94fad16e296ce6330dcb4afeebdb518dd900e2..23ed6c130a677f749afcd5dd58cd1544773428a2 100644 |
--- a/content/browser/loader/mojo_async_resource_handler.cc |
+++ b/content/browser/loader/mojo_async_resource_handler.cc |
@@ -144,6 +144,7 @@ bool MojoAsyncResourceHandler::OnRequestRedirected( |
NetLogObserver::PopulateResponseInfo(request(), response); |
response->head.encoded_data_length = request()->GetTotalReceivedBytes(); |
+ reported_total_received_bytes_ = 0; |
mmenke
2016/12/13 20:01:25
This isn't doing anything - we don't call OnRespon
yhirano
2016/12/14 16:47:27
Done.
|
response->head.request_start = request()->creation_time(); |
response->head.response_start = base::TimeTicks::Now(); |
// TODO(davidben): Is it necessary to pass the new first party URL for |
@@ -164,6 +165,8 @@ bool MojoAsyncResourceHandler::OnResponseStarted(ResourceResponse* response, |
} |
NetLogObserver::PopulateResponseInfo(request(), response); |
+ response->head.encoded_data_length = request()->raw_header_size(); |
+ reported_total_received_bytes_ = response->head.encoded_data_length; |
mmenke
2016/12/13 20:01:25
Looks like the old API didn't filter these out. I
yhirano
2016/12/14 16:47:27
AsyncResourceHandler has a special handling in OnR
|
response->head.request_start = request()->creation_time(); |
response->head.response_start = base::TimeTicks::Now(); |
@@ -245,6 +248,13 @@ bool MojoAsyncResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { |
if (!bytes_read) |
return true; |
+ const ResourceRequestInfoImpl* info = GetRequestInfo(); |
+ if (info->ShouldReportRawHeaders()) { |
+ auto transfer_size_diff = CalculateTransferSizeDiff(); |
+ if (transfer_size_diff > 0) |
+ url_loader_client_->OnTransferSizeUpdated(transfer_size_diff); |
+ } |
+ |
if (is_using_io_buffer_not_from_writer_) { |
// Couldn't allocate a buffer on the data pipe in OnWillRead. |
DCHECK_EQ(0u, buffer_bytes_read_); |
@@ -272,13 +282,8 @@ bool MojoAsyncResourceHandler::OnReadCompleted(int bytes_read, bool* defer) { |
} |
void MojoAsyncResourceHandler::OnDataDownloaded(int bytes_downloaded) { |
- int64_t total_received_bytes = request()->GetTotalReceivedBytes(); |
- int64_t bytes_to_report = |
- total_received_bytes - reported_total_received_bytes_; |
- reported_total_received_bytes_ = total_received_bytes; |
- DCHECK_LE(0, bytes_to_report); |
- |
- url_loader_client_->OnDataDownloaded(bytes_downloaded, bytes_to_report); |
+ url_loader_client_->OnDataDownloaded(bytes_downloaded, |
+ CalculateTransferSizeDiff()); |
} |
void MojoAsyncResourceHandler::FollowRedirect() { |
@@ -450,6 +455,15 @@ void MojoAsyncResourceHandler::Cancel() { |
GlobalRequestID(info->GetChildID(), info->GetRequestID())); |
} |
+int64_t MojoAsyncResourceHandler::CalculateTransferSizeDiff() { |
+ int64_t total_received_bytes = request()->GetTotalReceivedBytes(); |
+ int64_t bytes_to_report = |
+ total_received_bytes - reported_total_received_bytes_; |
+ reported_total_received_bytes_ = total_received_bytes; |
+ DCHECK_LE(0, bytes_to_report); |
+ return bytes_to_report; |
+} |
+ |
void MojoAsyncResourceHandler::ReportBadMessage(const std::string& error) { |
mojo::ReportBadMessage(error); |
} |