| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "mojo/edk/embedder/embedder_test_util.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "mojo/edk/embedder/embedder.h" |
| 9 |
| 10 namespace mojo { |
| 11 namespace embedder { |
| 12 |
| 13 ScopedTestChannel::ScopedTestChannel( |
| 14 scoped_refptr<base::TaskRunner> io_thread_task_runner, |
| 15 ScopedPlatformHandle platform_handle) |
| 16 : io_thread_task_runner_(io_thread_task_runner), |
| 17 bootstrap_message_pipe_(MOJO_HANDLE_INVALID), |
| 18 did_create_channel_event_(true, false), |
| 19 channel_info_(nullptr) { |
| 20 bootstrap_message_pipe_ = |
| 21 CreateChannel(platform_handle.Pass(), io_thread_task_runner_, |
| 22 base::Bind(&ScopedTestChannel::DidCreateChannel, |
| 23 base::Unretained(this)), |
| 24 nullptr) |
| 25 .release() |
| 26 .value(); |
| 27 CHECK_NE(bootstrap_message_pipe_, MOJO_HANDLE_INVALID); |
| 28 } |
| 29 |
| 30 ScopedTestChannel::~ScopedTestChannel() { |
| 31 DestroyChannel(channel_info_); |
| 32 } |
| 33 |
| 34 void ScopedTestChannel::WaitForChannelCreationCompletion() { |
| 35 did_create_channel_event_.Wait(); |
| 36 } |
| 37 |
| 38 void ScopedTestChannel::DidCreateChannel(ChannelInfo* channel_info) { |
| 39 CHECK(channel_info); |
| 40 CHECK(!channel_info_); |
| 41 channel_info_ = channel_info; |
| 42 did_create_channel_event_.Signal(); |
| 43 } |
| 44 |
| 45 EmbedderTest::EmbedderTest() : test_io_thread_(base::TestIOThread::kAutoStart) { |
| 46 } |
| 47 |
| 48 EmbedderTest::~EmbedderTest() { |
| 49 } |
| 50 |
| 51 } // namespace embedder |
| 52 } // namespace mojo |
| OLD | NEW |