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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 if (m_isDone) | 511 if (m_isDone) |
512 return nullptr; | 512 return nullptr; |
513 m_event->wait(); | 513 m_event->wait(); |
514 m_isDone = true; | 514 m_isDone = true; |
515 return std::move(m_result); | 515 return std::move(m_result); |
516 } | 516 } |
517 | 517 |
518 private: | 518 private: |
519 void start(std::unique_ptr<WebDataConsumerHandle> handle) | 519 void start(std::unique_ptr<WebDataConsumerHandle> handle) |
520 { | 520 { |
521 m_handleReader = wrapUnique(new T(std::move(handle), WTF::bind(&Hand
leReaderRunner::onFinished, this))); | 521 m_handleReader = wrapUnique(new T(std::move(handle), WTF::bind(&Hand
leReaderRunner::onFinished, WTF::unretained(this)))); |
522 } | 522 } |
523 | 523 |
524 void onFinished(std::unique_ptr<HandleReadResult> result) | 524 void onFinished(std::unique_ptr<HandleReadResult> result) |
525 { | 525 { |
526 m_handleReader = nullptr; | 526 m_handleReader = nullptr; |
527 m_result = std::move(result); | 527 m_result = std::move(result); |
528 m_event->signal(); | 528 m_event->signal(); |
529 } | 529 } |
530 | 530 |
531 std::unique_ptr<Thread> m_thread; | 531 std::unique_ptr<Thread> m_thread; |
532 std::unique_ptr<WaitableEvent> m_event; | 532 std::unique_ptr<WaitableEvent> m_event; |
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 |