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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/FetchFormDataConsumerHandleTest.cpp

Issue 2319093004: Revert of [Fetch API] Start reading blob only when the reader wants to read contents. (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/fetch/FetchFormDataConsumerHandle.h" 5 #include "modules/fetch/FetchFormDataConsumerHandle.h"
6 6
7 #include "core/dom/DOMTypedArray.h" 7 #include "core/dom/DOMTypedArray.h"
8 #include "core/html/FormData.h" 8 #include "core/html/FormData.h"
9 #include "core/loader/MockThreadableLoader.h" 9 #include "core/loader/MockThreadableLoader.h"
10 #include "core/loader/ThreadableLoaderClient.h" 10 #include "core/loader/ThreadableLoaderClient.h"
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 TEST_F(FetchFormDataConsumerHandleTest, ZeroByteReadDoesNotAffectDrainingForComp lexFormData) 394 TEST_F(FetchFormDataConsumerHandleTest, ZeroByteReadDoesNotAffectDrainingForComp lexFormData)
395 { 395 {
396 std::unique_ptr<ReplayingHandle> src = ReplayingHandle::create(); 396 std::unique_ptr<ReplayingHandle> src = ReplayingHandle::create();
397 src->add(Command(Command::Data, "bar")); 397 src->add(Command(Command::Data, "bar"));
398 src->add(Command(Command::Done)); 398 src->add(Command(Command::Done));
399 std::unique_ptr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandl e::createForTest(getDocument(), complexFormData(), new LoaderFactory(std::move(s rc))); 399 std::unique_ptr<FetchDataConsumerHandle> handle = FetchFormDataConsumerHandl e::createForTest(getDocument(), complexFormData(), new LoaderFactory(std::move(s rc)));
400 std::unique_ptr<FetchDataConsumerHandle::Reader> reader = handle->obtainFetc hDataReader(nullptr); 400 std::unique_ptr<FetchDataConsumerHandle::Reader> reader = handle->obtainFetc hDataReader(nullptr);
401 size_t readSize; 401 size_t readSize;
402 EXPECT_EQ(kShouldWait, reader->read(nullptr, 0, kNone, &readSize)); 402 EXPECT_EQ(kShouldWait, reader->read(nullptr, 0, kNone, &readSize));
403 testing::runPendingTasks(); 403 testing::runPendingTasks();
404 EXPECT_EQ(kOk, reader->read(nullptr, 0, kNone, &readSize));
404 RefPtr<EncodedFormData> formData = reader->drainAsFormData(); 405 RefPtr<EncodedFormData> formData = reader->drainAsFormData();
405 ASSERT_TRUE(formData); 406 ASSERT_TRUE(formData);
406 EXPECT_TRUE(formData->isSafeToSendToAnotherThread()); 407 EXPECT_TRUE(formData->isSafeToSendToAnotherThread());
407 verifyComplexFormData(formData.get()); 408 verifyComplexFormData(formData.get());
408 } 409 }
409 410
410 TEST_F(FetchFormDataConsumerHandleTest, OneByteReadAffectsDrainingForComplexForm Data) 411 TEST_F(FetchFormDataConsumerHandleTest, OneByteReadAffectsDrainingForComplexForm Data)
411 { 412 {
412 std::unique_ptr<ReplayingHandle> src = ReplayingHandle::create(); 413 std::unique_ptr<ReplayingHandle> src = ReplayingHandle::create();
413 src->add(Command(Command::Data, "bar")); 414 src->add(Command(Command::Data, "bar"));
(...skipping 22 matching lines...) Expand all
436 EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available)); 437 EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available));
437 testing::runPendingTasks(); 438 testing::runPendingTasks();
438 EXPECT_EQ(kOk, reader->beginRead(&buffer, kNone, &available)); 439 EXPECT_EQ(kOk, reader->beginRead(&buffer, kNone, &available));
439 EXPECT_FALSE(reader->drainAsFormData()); 440 EXPECT_FALSE(reader->drainAsFormData());
440 reader->endRead(0); 441 reader->endRead(0);
441 EXPECT_FALSE(reader->drainAsFormData()); 442 EXPECT_FALSE(reader->drainAsFormData());
442 } 443 }
443 444
444 } // namespace 445 } // namespace
445 } // namespace blink 446 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/FetchBlobDataConsumerHandleTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698