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

Unified Diff: content/child/url_response_body_consumer.cc

Issue 2644053002: [Mojo-Loading] Split too large data chunk in renderer (Closed)
Patch Set: fix Created 3 years, 11 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 | « content/child/url_response_body_consumer.h ('k') | content/child/url_response_body_consumer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/url_response_body_consumer.cc
diff --git a/content/child/url_response_body_consumer.cc b/content/child/url_response_body_consumer.cc
index 398ea85b19dd0b8a7abee23d5cd06dd880dfc261..fddd7768a3c7a60127b1a4d436a449e13d25f4bc 100644
--- a/content/child/url_response_body_consumer.cc
+++ b/content/child/url_response_body_consumer.cc
@@ -15,6 +15,8 @@
namespace content {
+constexpr uint32_t URLResponseBodyConsumer::kMaxNumConsumedBytesInTask;
+
class URLResponseBodyConsumer::ReceivedData final
: public RequestPeer::ReceivedData {
public:
@@ -98,6 +100,7 @@ void URLResponseBodyConsumer::OnReadable(MojoResult unused) {
return;
DCHECK(!is_in_on_readable_);
+ uint32_t num_bytes_consumed = 0;
// Protect |this| as RequestPeer::OnReceivedData may call deref.
scoped_refptr<URLResponseBodyConsumer> protect(this);
@@ -122,6 +125,20 @@ void URLResponseBodyConsumer::OnReadable(MojoResult unused) {
NotifyCompletionIfAppropriate();
return;
}
+ DCHECK_LE(num_bytes_consumed, kMaxNumConsumedBytesInTask);
+ available =
+ std::min(available, kMaxNumConsumedBytesInTask - num_bytes_consumed);
+ if (available == 0) {
+ // We've already consumed many bytes in this task. Defer the remaining
+ // to the next task.
+ result = mojo::EndReadDataRaw(handle_.get(), 0);
+ DCHECK_EQ(result, MOJO_RESULT_OK);
+ task_runner_->PostTask(FROM_HERE,
+ base::Bind(&URLResponseBodyConsumer::OnReadable,
+ AsWeakPtr(), MOJO_RESULT_OK));
+ return;
+ }
+ num_bytes_consumed += available;
ResourceDispatcher::PendingRequestInfo* request_info =
resource_dispatcher_->GetPendingRequestInfo(request_id_);
DCHECK(request_info);
« no previous file with comments | « content/child/url_response_body_consumer.h ('k') | content/child/url_response_body_consumer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698