Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(739)

Side by Side Diff: ppapi/proxy/ppapi_proxy_test.cc

Issue 2360173002: Use ChannelMojo in ppapi_unittests. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <sstream>
8 #include <tuple> 7 #include <tuple>
9 8
10 #include "base/bind.h" 9 #include "base/bind.h"
11 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
12 #include "base/location.h" 11 #include "base/location.h"
13 #include "base/observer_list.h" 12 #include "base/observer_list.h"
14 #include "base/process/process_handle.h" 13 #include "base/process/process_handle.h"
15 #include "base/run_loop.h" 14 #include "base/run_loop.h"
16 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
17 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 TwoWayTest::~TwoWayTest() { 542 TwoWayTest::~TwoWayTest() {
544 shutdown_event_.Signal(); 543 shutdown_event_.Signal();
545 } 544 }
546 545
547 void TwoWayTest::SetUp() { 546 void TwoWayTest::SetUp() {
548 base::Thread::Options options; 547 base::Thread::Options options;
549 options.message_loop_type = base::MessageLoop::TYPE_IO; 548 options.message_loop_type = base::MessageLoop::TYPE_IO;
550 io_thread_.StartWithOptions(options); 549 io_thread_.StartWithOptions(options);
551 plugin_thread_.Start(); 550 plugin_thread_.Start();
552 551
553 // Construct the IPC handle name using the process ID so we can safely run 552 IPC::ChannelHandle local_handle, remote_handle;
554 // multiple |TwoWayTest|s concurrently. 553 IPC::Channel::GenerateMojoChannelHandlePair("TwoWayTestChannel",
555 std::ostringstream handle_name; 554 &local_handle, &remote_handle);
556 handle_name << "TwoWayTestChannel" << base::GetCurrentProcId();
557 IPC::ChannelHandle handle(handle_name.str());
558 base::WaitableEvent remote_harness_set_up( 555 base::WaitableEvent remote_harness_set_up(
559 base::WaitableEvent::ResetPolicy::MANUAL, 556 base::WaitableEvent::ResetPolicy::MANUAL,
560 base::WaitableEvent::InitialState::NOT_SIGNALED); 557 base::WaitableEvent::InitialState::NOT_SIGNALED);
561 plugin_thread_.task_runner()->PostTask( 558 plugin_thread_.task_runner()->PostTask(
562 FROM_HERE, base::Bind(&SetUpRemoteHarness, remote_harness_, handle, 559 FROM_HERE, base::Bind(&SetUpRemoteHarness, remote_harness_, remote_handle,
563 base::RetainedRef(io_thread_.task_runner()), 560 base::RetainedRef(io_thread_.task_runner()),
564 &shutdown_event_, &remote_harness_set_up)); 561 &shutdown_event_, &remote_harness_set_up));
565 remote_harness_set_up.Wait(); 562 remote_harness_set_up.Wait();
566 local_harness_->SetUpHarnessWithChannel( 563 local_harness_->SetUpHarnessWithChannel(
567 handle, io_thread_.task_runner().get(), &shutdown_event_, 564 local_handle, io_thread_.task_runner().get(), &shutdown_event_,
568 true); // is_client 565 true); // is_client
569 } 566 }
570 567
571 void TwoWayTest::TearDown() { 568 void TwoWayTest::TearDown() {
572 base::WaitableEvent remote_harness_torn_down( 569 base::WaitableEvent remote_harness_torn_down(
573 base::WaitableEvent::ResetPolicy::MANUAL, 570 base::WaitableEvent::ResetPolicy::MANUAL,
574 base::WaitableEvent::InitialState::NOT_SIGNALED); 571 base::WaitableEvent::InitialState::NOT_SIGNALED);
575 plugin_thread_.task_runner()->PostTask( 572 plugin_thread_.task_runner()->PostTask(
576 FROM_HERE, base::Bind(&TearDownRemoteHarness, remote_harness_, 573 FROM_HERE, base::Bind(&TearDownRemoteHarness, remote_harness_,
577 &remote_harness_torn_down)); 574 &remote_harness_torn_down));
578 remote_harness_torn_down.Wait(); 575 remote_harness_torn_down.Wait();
579 576
580 local_harness_->TearDownHarness(); 577 local_harness_->TearDownHarness();
581 578
582 io_thread_.Stop(); 579 io_thread_.Stop();
583 } 580 }
584 581
585 void TwoWayTest::PostTaskOnRemoteHarness(const base::Closure& task) { 582 void TwoWayTest::PostTaskOnRemoteHarness(const base::Closure& task) {
586 base::WaitableEvent task_complete( 583 base::WaitableEvent task_complete(
587 base::WaitableEvent::ResetPolicy::MANUAL, 584 base::WaitableEvent::ResetPolicy::MANUAL,
588 base::WaitableEvent::InitialState::NOT_SIGNALED); 585 base::WaitableEvent::InitialState::NOT_SIGNALED);
589 plugin_thread_.task_runner()->PostTask( 586 plugin_thread_.task_runner()->PostTask(
590 FROM_HERE, base::Bind(&RunTaskOnRemoteHarness, task, &task_complete)); 587 FROM_HERE, base::Bind(&RunTaskOnRemoteHarness, task, &task_complete));
591 task_complete.Wait(); 588 task_complete.Wait();
592 } 589 }
593 590
594 591
595 } // namespace proxy 592 } // namespace proxy
596 } // namespace ppapi 593 } // namespace ppapi
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698