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 #ifndef DataConsumerHandleTestUtil_h | 5 #ifndef DataConsumerHandleTestUtil_h |
6 #define DataConsumerHandleTestUtil_h | 6 #define DataConsumerHandleTestUtil_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "core/testing/NullExecutionContext.h" | 9 #include "core/testing/NullExecutionContext.h" |
10 #include "gin/public/isolate_holder.h" | 10 #include "gin/public/isolate_holder.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 USING_FAST_MALLOC(DataConsumerHandle); | 200 USING_FAST_MALLOC(DataConsumerHandle); |
201 public: | 201 public: |
202 static std::unique_ptr<WebDataConsumerHandle> create(const String& n
ame, PassRefPtr<Context> context) | 202 static std::unique_ptr<WebDataConsumerHandle> create(const String& n
ame, PassRefPtr<Context> context) |
203 { | 203 { |
204 return wrapUnique(new DataConsumerHandle(name, context)); | 204 return wrapUnique(new DataConsumerHandle(name, context)); |
205 } | 205 } |
206 | 206 |
207 private: | 207 private: |
208 DataConsumerHandle(const String& name, PassRefPtr<Context> context)
: m_name(name.isolatedCopy()), m_context(context) { } | 208 DataConsumerHandle(const String& name, PassRefPtr<Context> context)
: m_name(name.isolatedCopy()), m_context(context) { } |
209 | 209 |
210 Reader* obtainReaderInternal(Client*) { return new ReaderImpl(m_name
, m_context); } | 210 std::unique_ptr<Reader> obtainReader(Client*) { return WTF::wrapUniq
ue(new ReaderImpl(m_name, m_context)); } |
211 const char* debugName() const override { return "ThreadingTestBase::
DataConsumerHandle"; } | 211 const char* debugName() const override { return "ThreadingTestBase::
DataConsumerHandle"; } |
212 | 212 |
213 const String m_name; | 213 const String m_name; |
214 RefPtr<Context> m_context; | 214 RefPtr<Context> m_context; |
215 }; | 215 }; |
216 | 216 |
217 void resetReader() { m_reader = nullptr; } | 217 void resetReader() { m_reader = nullptr; } |
218 void signalDone() { m_waitableEvent->signal(); } | 218 void signalDone() { m_waitableEvent->signal(); } |
219 const String& result() { return m_context->result(); } | 219 const String& result() { return m_context->result(); } |
220 void postTaskToReadingThread(const WebTraceLocation& location, std::uniq
ue_ptr<CrossThreadClosure> task) | 220 void postTaskToReadingThread(const WebTraceLocation& location, std::uniq
ue_ptr<CrossThreadClosure> task) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 { | 300 { |
301 ASSERT_NOT_REACHED(); | 301 ASSERT_NOT_REACHED(); |
302 } | 302 } |
303 | 303 |
304 std::unique_ptr<WebDataConsumerHandle> m_handle; | 304 std::unique_ptr<WebDataConsumerHandle> m_handle; |
305 }; | 305 }; |
306 | 306 |
307 class MockFetchDataConsumerHandle : public FetchDataConsumerHandle { | 307 class MockFetchDataConsumerHandle : public FetchDataConsumerHandle { |
308 public: | 308 public: |
309 static std::unique_ptr<::testing::StrictMock<MockFetchDataConsumerHandle
>> create() { return wrapUnique(new ::testing::StrictMock<MockFetchDataConsumerH
andle>); } | 309 static std::unique_ptr<::testing::StrictMock<MockFetchDataConsumerHandle
>> create() { return wrapUnique(new ::testing::StrictMock<MockFetchDataConsumerH
andle>); } |
310 MOCK_METHOD1(obtainReaderInternal, Reader*(Client*)); | 310 MOCK_METHOD1(obtainFetchDataReader, std::unique_ptr<Reader>(Client*)); |
311 | 311 |
312 private: | 312 private: |
313 const char* debugName() const override { return "MockFetchDataConsumerHa
ndle"; } | 313 const char* debugName() const override { return "MockFetchDataConsumerHa
ndle"; } |
314 }; | 314 }; |
315 | 315 |
316 class MockFetchDataConsumerReader : public FetchDataConsumerHandle::Reader { | 316 class MockFetchDataConsumerReader : public FetchDataConsumerHandle::Reader { |
317 public: | 317 public: |
318 static std::unique_ptr<::testing::StrictMock<MockFetchDataConsumerReader
>> create() { return wrapUnique(new ::testing::StrictMock<MockFetchDataConsumerR
eader>); } | 318 static std::unique_ptr<::testing::StrictMock<MockFetchDataConsumerReader
>> create() { return wrapUnique(new ::testing::StrictMock<MockFetchDataConsumerR
eader>); } |
319 | 319 |
320 using Result = WebDataConsumerHandle::Result; | 320 using Result = WebDataConsumerHandle::Result; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 size_t m_offset; | 421 size_t m_offset; |
422 WebThread* m_readerThread; | 422 WebThread* m_readerThread; |
423 Client* m_client; | 423 Client* m_client; |
424 Result m_result; | 424 Result m_result; |
425 bool m_isHandleAttached; | 425 bool m_isHandleAttached; |
426 Mutex m_mutex; | 426 Mutex m_mutex; |
427 std::unique_ptr<WaitableEvent> m_detached; | 427 std::unique_ptr<WaitableEvent> m_detached; |
428 }; | 428 }; |
429 | 429 |
430 Context* getContext() { return m_context.get(); } | 430 Context* getContext() { return m_context.get(); } |
| 431 std::unique_ptr<Reader> obtainReader(Client*) override; |
431 | 432 |
432 private: | 433 private: |
433 class ReaderImpl; | 434 class ReaderImpl; |
434 | 435 |
435 ReplayingHandle(); | 436 ReplayingHandle(); |
436 Reader* obtainReaderInternal(Client*) override; | |
437 const char* debugName() const override { return "ReplayingHandle"; } | 437 const char* debugName() const override { return "ReplayingHandle"; } |
438 | 438 |
439 RefPtr<Context> m_context; | 439 RefPtr<Context> m_context; |
440 }; | 440 }; |
441 | 441 |
442 class HandleReadResult final { | 442 class HandleReadResult final { |
443 USING_FAST_MALLOC(HandleReadResult); | 443 USING_FAST_MALLOC(HandleReadResult); |
444 public: | 444 public: |
445 HandleReadResult(WebDataConsumerHandle::Result result, const Vector<char
>& data) : m_result(result), m_data(data) { } | 445 HandleReadResult(WebDataConsumerHandle::Result result, const Vector<char
>& data) : m_result(result), m_data(data) { } |
446 WebDataConsumerHandle::Result result() const { return m_result; } | 446 WebDataConsumerHandle::Result result() const { return m_result; } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 std::unique_ptr<HandleReadResult> m_result; | 533 std::unique_ptr<HandleReadResult> m_result; |
534 bool m_isDone; | 534 bool m_isDone; |
535 | 535 |
536 std::unique_ptr<T> m_handleReader; | 536 std::unique_ptr<T> m_handleReader; |
537 }; | 537 }; |
538 }; | 538 }; |
539 | 539 |
540 } // namespace blink | 540 } // namespace blink |
541 | 541 |
542 #endif // DataConsumerHandleTestUtil_h | 542 #endif // DataConsumerHandleTestUtil_h |
OLD | NEW |