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

Unified Diff: content/browser/loader/mojo_async_resource_handler.cc

Issue 2566943002: Dispatch transfer size update notification on mojo-loading (Closed)
Patch Set: fix Created 4 years 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
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..0d103654468e3923424646aa51031246b07daeef 100644
--- a/content/browser/loader/mojo_async_resource_handler.cc
+++ b/content/browser/loader/mojo_async_resource_handler.cc
@@ -164,6 +164,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;
response->head.request_start = request()->creation_time();
response->head.response_start = base::TimeTicks::Now();
@@ -245,6 +247,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 = CalculateRecentlyReceivedBytes();
+ 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 +281,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,
+ CalculateRecentlyReceivedBytes());
}
void MojoAsyncResourceHandler::FollowRedirect() {
@@ -450,6 +454,15 @@ void MojoAsyncResourceHandler::Cancel() {
GlobalRequestID(info->GetChildID(), info->GetRequestID()));
}
+int64_t MojoAsyncResourceHandler::CalculateRecentlyReceivedBytes() {
+ 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);
}
« no previous file with comments | « content/browser/loader/mojo_async_resource_handler.h ('k') | content/browser/loader/test_url_loader_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698