| 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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 { | 506 { |
| 507 wait(); | 507 wait(); |
| 508 } | 508 } |
| 509 | 509 |
| 510 PassOwnPtr<HandleReadResult> wait() | 510 PassOwnPtr<HandleReadResult> wait() |
| 511 { | 511 { |
| 512 if (m_isDone) | 512 if (m_isDone) |
| 513 return nullptr; | 513 return nullptr; |
| 514 m_event->wait(); | 514 m_event->wait(); |
| 515 m_isDone = true; | 515 m_isDone = true; |
| 516 return m_result.release(); | 516 return std::move(m_result); |
| 517 } | 517 } |
| 518 | 518 |
| 519 private: | 519 private: |
| 520 void start(PassOwnPtr<WebDataConsumerHandle> handle) | 520 void start(PassOwnPtr<WebDataConsumerHandle> handle) |
| 521 { | 521 { |
| 522 m_handleReader = adoptPtr(new T(std::move(handle), bind<PassOwnPtr<H
andleReadResult>>(&HandleReaderRunner::onFinished, this))); | 522 m_handleReader = adoptPtr(new T(std::move(handle), bind<PassOwnPtr<H
andleReadResult>>(&HandleReaderRunner::onFinished, this))); |
| 523 } | 523 } |
| 524 | 524 |
| 525 void onFinished(PassOwnPtr<HandleReadResult> result) | 525 void onFinished(PassOwnPtr<HandleReadResult> result) |
| 526 { | 526 { |
| 527 m_handleReader = nullptr; | 527 m_handleReader = nullptr; |
| 528 m_result = std::move(result); | 528 m_result = std::move(result); |
| 529 m_event->signal(); | 529 m_event->signal(); |
| 530 } | 530 } |
| 531 | 531 |
| 532 OwnPtr<Thread> m_thread; | 532 OwnPtr<Thread> m_thread; |
| 533 OwnPtr<WaitableEvent> m_event; | 533 OwnPtr<WaitableEvent> m_event; |
| 534 OwnPtr<HandleReadResult> m_result; | 534 OwnPtr<HandleReadResult> m_result; |
| 535 bool m_isDone; | 535 bool m_isDone; |
| 536 | 536 |
| 537 OwnPtr<T> m_handleReader; | 537 OwnPtr<T> m_handleReader; |
| 538 }; | 538 }; |
| 539 }; | 539 }; |
| 540 | 540 |
| 541 } // namespace blink | 541 } // namespace blink |
| 542 | 542 |
| 543 #endif // DataConsumerHandleTestUtil_h | 543 #endif // DataConsumerHandleTestUtil_h |
| OLD | NEW |