| OLD | NEW |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 String toString(const Vector<char>& data) | 45 String toString(const Vector<char>& data) |
| 46 { | 46 { |
| 47 return String(data.data(), data.size()); | 47 return String(data.data(), data.size()); |
| 48 } | 48 } |
| 49 | 49 |
| 50 class LoaderFactory : public FetchBlobDataConsumerHandle::LoaderFactory { | 50 class LoaderFactory : public FetchBlobDataConsumerHandle::LoaderFactory { |
| 51 public: | 51 public: |
| 52 explicit LoaderFactory(std::unique_ptr<WebDataConsumerHandle> handle) | 52 explicit LoaderFactory(std::unique_ptr<WebDataConsumerHandle> handle) |
| 53 : m_client(nullptr) | 53 : m_client(nullptr) |
| 54 , m_handle(std::move(handle)) {} | 54 , m_handle(std::move(handle)) {} |
| 55 std::unique_ptr<ThreadableLoader> create(ExecutionContext&, ThreadableLoader
Client* client, const ThreadableLoaderOptions&, const ResourceLoaderOptions&) ov
erride | 55 ThreadableLoader* create(ExecutionContext&, ThreadableLoaderClient* client,
const ThreadableLoaderOptions&, const ResourceLoaderOptions&) override |
| 56 { | 56 { |
| 57 m_client = client; | 57 m_client = client; |
| 58 | 58 |
| 59 std::unique_ptr<MockThreadableLoader> loader = MockThreadableLoader::cre
ate(); | 59 MockThreadableLoader* loader = MockThreadableLoader::create(); |
| 60 EXPECT_CALL(*loader, start(_)).WillOnce(InvokeWithoutArgs(this, &LoaderF
actory::handleDidReceiveResponse)); | 60 EXPECT_CALL(*loader, start(_)).WillOnce(InvokeWithoutArgs(this, &LoaderF
actory::handleDidReceiveResponse)); |
| 61 EXPECT_CALL(*loader, cancel()).Times(1); | 61 EXPECT_CALL(*loader, cancel()).Times(1); |
| 62 return std::move(loader); | 62 return loader; |
| 63 } | 63 } |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 void handleDidReceiveResponse() | 66 void handleDidReceiveResponse() |
| 67 { | 67 { |
| 68 m_client->didReceiveResponse(0, ResourceResponse(), std::move(m_handle))
; | 68 m_client->didReceiveResponse(0, ResourceResponse(), std::move(m_handle))
; |
| 69 } | 69 } |
| 70 | 70 |
| 71 ThreadableLoaderClient* m_client; | 71 ThreadableLoaderClient* m_client; |
| 72 std::unique_ptr<WebDataConsumerHandle> m_handle; | 72 std::unique_ptr<WebDataConsumerHandle> m_handle; |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available)); | 437 EXPECT_EQ(kShouldWait, reader->beginRead(&buffer, kNone, &available)); |
| 438 testing::runPendingTasks(); | 438 testing::runPendingTasks(); |
| 439 EXPECT_EQ(kOk, reader->beginRead(&buffer, kNone, &available)); | 439 EXPECT_EQ(kOk, reader->beginRead(&buffer, kNone, &available)); |
| 440 EXPECT_FALSE(reader->drainAsFormData()); | 440 EXPECT_FALSE(reader->drainAsFormData()); |
| 441 reader->endRead(0); | 441 reader->endRead(0); |
| 442 EXPECT_FALSE(reader->drainAsFormData()); | 442 EXPECT_FALSE(reader->drainAsFormData()); |
| 443 } | 443 } |
| 444 | 444 |
| 445 } // namespace | 445 } // namespace |
| 446 } // namespace blink | 446 } // namespace blink |
| OLD | NEW |