| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/proxy/ppapi_proxy_test.h" | 5 #include "ppapi/proxy/ppapi_proxy_test.h" |
| 6 | 6 |
| 7 #include <tuple> | 7 #include <tuple> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 TwoWayTest::~TwoWayTest() { | 540 TwoWayTest::~TwoWayTest() { |
| 541 shutdown_event_.Signal(); | 541 shutdown_event_.Signal(); |
| 542 } | 542 } |
| 543 | 543 |
| 544 void TwoWayTest::SetUp() { | 544 void TwoWayTest::SetUp() { |
| 545 base::Thread::Options options; | 545 base::Thread::Options options; |
| 546 options.message_loop_type = base::MessageLoop::TYPE_IO; | 546 options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 547 io_thread_.StartWithOptions(options); | 547 io_thread_.StartWithOptions(options); |
| 548 plugin_thread_.Start(); | 548 plugin_thread_.Start(); |
| 549 | 549 |
| 550 IPC::ChannelHandle local_handle, remote_handle; | 550 mojo::MessagePipe pipe; |
| 551 IPC::Channel::GenerateMojoChannelHandlePair("TwoWayTestChannel", | |
| 552 &local_handle, &remote_handle); | |
| 553 base::WaitableEvent remote_harness_set_up( | 551 base::WaitableEvent remote_harness_set_up( |
| 554 base::WaitableEvent::ResetPolicy::MANUAL, | 552 base::WaitableEvent::ResetPolicy::MANUAL, |
| 555 base::WaitableEvent::InitialState::NOT_SIGNALED); | 553 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 556 plugin_thread_.task_runner()->PostTask( | 554 plugin_thread_.task_runner()->PostTask( |
| 557 FROM_HERE, base::Bind(&SetUpRemoteHarness, remote_harness_, remote_handle, | 555 FROM_HERE, |
| 558 base::RetainedRef(io_thread_.task_runner()), | 556 base::Bind(&SetUpRemoteHarness, remote_harness_, pipe.handle0.release(), |
| 559 &shutdown_event_, &remote_harness_set_up)); | 557 base::RetainedRef(io_thread_.task_runner()), &shutdown_event_, |
| 558 &remote_harness_set_up)); |
| 560 remote_harness_set_up.Wait(); | 559 remote_harness_set_up.Wait(); |
| 561 local_harness_->SetUpHarnessWithChannel( | 560 local_harness_->SetUpHarnessWithChannel( |
| 562 local_handle, io_thread_.task_runner().get(), &shutdown_event_, | 561 pipe.handle1.release(), io_thread_.task_runner().get(), &shutdown_event_, |
| 563 true); // is_client | 562 true); // is_client |
| 564 } | 563 } |
| 565 | 564 |
| 566 void TwoWayTest::TearDown() { | 565 void TwoWayTest::TearDown() { |
| 567 base::WaitableEvent remote_harness_torn_down( | 566 base::WaitableEvent remote_harness_torn_down( |
| 568 base::WaitableEvent::ResetPolicy::MANUAL, | 567 base::WaitableEvent::ResetPolicy::MANUAL, |
| 569 base::WaitableEvent::InitialState::NOT_SIGNALED); | 568 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 570 plugin_thread_.task_runner()->PostTask( | 569 plugin_thread_.task_runner()->PostTask( |
| 571 FROM_HERE, base::Bind(&TearDownRemoteHarness, remote_harness_, | 570 FROM_HERE, base::Bind(&TearDownRemoteHarness, remote_harness_, |
| 572 &remote_harness_torn_down)); | 571 &remote_harness_torn_down)); |
| 573 remote_harness_torn_down.Wait(); | 572 remote_harness_torn_down.Wait(); |
| 574 | 573 |
| 575 local_harness_->TearDownHarness(); | 574 local_harness_->TearDownHarness(); |
| 576 | 575 |
| 577 io_thread_.Stop(); | 576 io_thread_.Stop(); |
| 578 } | 577 } |
| 579 | 578 |
| 580 void TwoWayTest::PostTaskOnRemoteHarness(const base::Closure& task) { | 579 void TwoWayTest::PostTaskOnRemoteHarness(const base::Closure& task) { |
| 581 base::WaitableEvent task_complete( | 580 base::WaitableEvent task_complete( |
| 582 base::WaitableEvent::ResetPolicy::MANUAL, | 581 base::WaitableEvent::ResetPolicy::MANUAL, |
| 583 base::WaitableEvent::InitialState::NOT_SIGNALED); | 582 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 584 plugin_thread_.task_runner()->PostTask( | 583 plugin_thread_.task_runner()->PostTask( |
| 585 FROM_HERE, base::Bind(&RunTaskOnRemoteHarness, task, &task_complete)); | 584 FROM_HERE, base::Bind(&RunTaskOnRemoteHarness, task, &task_complete)); |
| 586 task_complete.Wait(); | 585 task_complete.Wait(); |
| 587 } | 586 } |
| 588 | 587 |
| 589 | 588 |
| 590 } // namespace proxy | 589 } // namespace proxy |
| 591 } // namespace ppapi | 590 } // namespace ppapi |
| OLD | NEW |