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

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));
kinuko 2017/01/20 02:56:28 Do you have some stats / numbers how would this af
yhirano 2017/01/20 03:30:50 No. Some justifications: - AsyncResourceHandler h
kinuko 2017/01/20 04:57:35 Thanks, one more question for me to understand...
kinuko 2017/01/20 04:58:53 Also-- do you anticipate we'll have more IO tasks
yhirano 2017/01/20 05:06:10 This function runs on the main thread so I think I
yhirano 2017/01/20 05:06:10 There is no reason. If you are happier with 32k, I
kinuko 2017/01/20 05:12:29 I'm just trying to do a due diligence to see if we
kinuko 2017/01/20 05:12:29 Oops, that's right, sorry. What about the # of mai
yhirano 2017/01/20 06:04:54 Added some comments on the header file.
yhirano 2017/01/20 06:04:54 I expect the number of tasks will be greater than
+ 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