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

Unified Diff: content/child/url_response_body_consumer_unittest.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.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/url_response_body_consumer_unittest.cc
diff --git a/content/child/url_response_body_consumer_unittest.cc b/content/child/url_response_body_consumer_unittest.cc
index c77ba15508df52112c227c65faff7f6e1231a06c..37d93ed173d2ea14e8d57b013bc482658ef6e7ac 100644
--- a/content/child/url_response_body_consumer_unittest.cc
+++ b/content/child/url_response_body_consumer_unittest.cc
@@ -265,6 +265,45 @@ TEST_F(URLResponseBodyConsumerTest, CloseThenOnComplete) {
EXPECT_EQ("", context.data);
}
+TEST_F(URLResponseBodyConsumerTest, TooBigChunkShouldBeSplit) {
+ constexpr auto kMaxNumConsumedBytesInTask =
+ URLResponseBodyConsumer::kMaxNumConsumedBytesInTask;
+ TestRequestPeer::Context context;
+ std::unique_ptr<ResourceRequest> request(CreateResourceRequest());
+ int request_id = SetUpRequestPeer(std::move(request), &context);
+ auto options = CreateDataPipeOptions();
+ options.capacity_num_bytes = 2 * kMaxNumConsumedBytesInTask;
+ mojo::DataPipe data_pipe(options);
+
+ mojo::ScopedDataPipeProducerHandle writer =
+ std::move(data_pipe.producer_handle);
+ void* buffer = nullptr;
+ uint32_t size = 0;
+ MojoResult result =
+ mojo::BeginWriteDataRaw(writer.get(), &buffer, &size, kNone);
+
+ ASSERT_EQ(MOJO_RESULT_OK, result);
+ ASSERT_EQ(options.capacity_num_bytes, size);
+
+ memset(buffer, 'a', kMaxNumConsumedBytesInTask);
+ memset(static_cast<char*>(buffer) + kMaxNumConsumedBytesInTask, 'b',
+ kMaxNumConsumedBytesInTask);
+
+ result = mojo::EndWriteDataRaw(writer.get(), size);
+ ASSERT_EQ(MOJO_RESULT_OK, result);
+
+ scoped_refptr<URLResponseBodyConsumer> consumer(new URLResponseBodyConsumer(
+ request_id, dispatcher_.get(), std::move(data_pipe.consumer_handle),
+ message_loop_.task_runner()));
+
+ Run(&context);
+ EXPECT_EQ(std::string(kMaxNumConsumedBytesInTask, 'a'), context.data);
+ context.data.clear();
+
+ Run(&context);
+ EXPECT_EQ(std::string(kMaxNumConsumedBytesInTask, 'b'), context.data);
+}
+
} // namespace
} // namespace content
« no previous file with comments | « content/child/url_response_body_consumer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698