Commit 2cbd2420 authored by lushnikov's avatar lushnikov Committed by Commit bot

Revert of [Fetch API] Start reading blob only when the reader wants to read...

Revert of [Fetch API] Start reading blob only when the reader wants to read contents. (patchset #3 id:40001 of https://codereview.chromium.org/2303753003/ )

Reason for revert:
Speculative revert: this patch is a suspect to cause Linux MSAN failures:

https://uberchromegw.corp.google.com/i/chromium.webkit/builders/WebKit%20Linux%20MSAN/builds/12091

The other suspected patch, the only one related to canvas, was reverted and didn't help.

Original issue's description:
> [Fetch API] Start reading blob only when the reader wants to read contents.
>
> BUG=643174
>
> Committed: https://crrev.com/f1ca96c413912ff1768e4274b8b7ac78eb41de64
> Cr-Commit-Position: refs/heads/master@{#416923}

TBR=hiroshige@chromium.org,jkarlin@chromium.org,yhirano@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=643174

Review-Url: https://codereview.chromium.org/2319093004
Cr-Commit-Position: refs/heads/master@{#417338}
parent a43953b7
......@@ -194,12 +194,12 @@ public:
{
if (m_readerContext->drained())
return Done;
m_readerContext->ensureStartLoader();
Result r = m_reader->read(data, size, flags, readSize);
if (!(size == 0 && (r == Ok || r == ShouldWait))) {
// We read non-empty data, so we cannot use the blob data
// handle which represents the whole data.
m_readerContext->clearBlobDataHandleForDrain();
m_readerContext->ensureStartLoader();
}
return r;
}
......
......@@ -112,9 +112,8 @@ TEST_F(FetchBlobDataConsumerHandleTest, CreateLoader)
= FetchBlobDataConsumerHandle::create(&document(), blobDataHandle, factory);
testing::runPendingTasks();
char buffer[1];
size_t size = 0;
ASSERT_EQ(kShouldWait, handle->obtainReader(nullptr)->read(buffer, sizeof(buffer), kNone, &size));
handle->obtainReader(nullptr)->read(nullptr, 0, kNone, &size);
checkpoint.Call(1);
testing::runPendingTasks();
checkpoint.Call(2);
......@@ -135,27 +134,6 @@ TEST_F(FetchBlobDataConsumerHandleTest, CreateLoader)
EXPECT_EQ(NotCORSEnabled, resourceLoaderOptions.corsEnabled);
}
TEST_F(FetchBlobDataConsumerHandleTest, ZeroByteReadDoesNotCreateLoader)
{
auto factory = new StrictMock<MockLoaderFactory>;
Checkpoint checkpoint;
InSequence s;
EXPECT_CALL(checkpoint, Call(1));
EXPECT_CALL(checkpoint, Call(2));
RefPtr<BlobDataHandle> blobDataHandle = createBlobDataHandle("Once upon a time");
std::unique_ptr<WebDataConsumerHandle> handle
= FetchBlobDataConsumerHandle::create(&document(), blobDataHandle, factory);
testing::runPendingTasks();
size_t size = 0;
ASSERT_EQ(kShouldWait, handle->obtainReader(nullptr)->read(nullptr, 0, kNone, &size));
checkpoint.Call(1);
testing::runPendingTasks();
checkpoint.Call(2);
}
TEST_F(FetchBlobDataConsumerHandleTest, CancelLoaderWhenStopped)
{
auto factory = new StrictMock<MockLoaderFactory>;
......@@ -176,9 +154,8 @@ TEST_F(FetchBlobDataConsumerHandleTest, CancelLoaderWhenStopped)
= FetchBlobDataConsumerHandle::create(&document(), blobDataHandle, factory);
testing::runPendingTasks();
char buffer[1];
size_t size = 0;
ASSERT_EQ(kShouldWait, handle->obtainReader(nullptr)->read(buffer, sizeof(buffer), kNone, &size));
handle->obtainReader(nullptr)->read(nullptr, 0, kNone, &size);
checkpoint.Call(1);
testing::runPendingTasks();
checkpoint.Call(2);
......@@ -208,9 +185,8 @@ TEST_F(FetchBlobDataConsumerHandleTest, CancelLoaderWhenDestinationDetached)
std::unique_ptr<WebDataConsumerHandle::Reader> reader = handle->obtainReader(nullptr);
testing::runPendingTasks();
char buffer[1];
size_t size = 0;
ASSERT_EQ(kShouldWait, reader->read(buffer, sizeof(buffer), kNone, &size));
reader->read(nullptr, 0, kNone, &size);
checkpoint.Call(1);
testing::runPendingTasks();
checkpoint.Call(2);
......@@ -247,9 +223,8 @@ TEST_F(FetchBlobDataConsumerHandleTest, ReadTest)
src->add(Command(Command::Wait));
src->add(Command(Command::Done));
char buffer[1];
size_t size = 0;
ASSERT_EQ(kShouldWait, handle->obtainReader(nullptr)->read(buffer, sizeof(buffer), kNone, &size));
handle->obtainReader(nullptr)->read(nullptr, 0, kNone, &size);
checkpoint.Call(1);
testing::runPendingTasks();
checkpoint.Call(2);
......@@ -286,9 +261,8 @@ TEST_F(FetchBlobDataConsumerHandleTest, TwoPhaseReadTest)
src->add(Command(Command::Wait));
src->add(Command(Command::Done));
char buffer[1];
size_t size = 0;
ASSERT_EQ(kShouldWait, handle->obtainReader(nullptr)->read(buffer, sizeof(buffer), kNone, &size));
handle->obtainReader(nullptr)->read(nullptr, 0, kNone, &size);
checkpoint.Call(1);
testing::runPendingTasks();
checkpoint.Call(2);
......@@ -317,9 +291,8 @@ TEST_F(FetchBlobDataConsumerHandleTest, LoadErrorTest)
std::unique_ptr<WebDataConsumerHandle> handle
= FetchBlobDataConsumerHandle::create(&document(), blobDataHandle, factory);
char buffer[1];
size_t size = 0;
ASSERT_EQ(kShouldWait, handle->obtainReader(nullptr)->read(buffer, sizeof(buffer), kNone, &size));
handle->obtainReader(nullptr)->read(nullptr, 0, kNone, &size);
checkpoint.Call(1);
testing::runPendingTasks();
checkpoint.Call(2);
......@@ -353,9 +326,8 @@ TEST_F(FetchBlobDataConsumerHandleTest, BodyLoadErrorTest)
src->add(Command(Command::Data, "hello, "));
src->add(Command(Command::Error));
char buffer[1];
size_t size = 0;
ASSERT_EQ(kShouldWait, handle->obtainReader(nullptr)->read(buffer, sizeof(buffer), kNone, &size));
handle->obtainReader(nullptr)->read(nullptr, 0, kNone, &size);
checkpoint.Call(1);
testing::runPendingTasks();
checkpoint.Call(2);
......
......@@ -401,6 +401,7 @@ TEST_F(FetchFormDataConsumerHandleTest, ZeroByteReadDoesNotAffectDrainingForComp
size_t readSize;
EXPECT_EQ(kShouldWait, reader->read(nullptr, 0, kNone, &readSize));
testing::runPendingTasks();
EXPECT_EQ(kOk, reader->read(nullptr, 0, kNone, &readSize));
RefPtr<EncodedFormData> formData = reader->drainAsFormData();
ASSERT_TRUE(formData);
EXPECT_TRUE(formData->isSafeToSendToAnotherThread());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment