OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "mojo/edk/system/message_pipe_test_utils.h" | 5 #include "mojo/edk/system/message_pipe_test_utils.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
| 9 #include "mojo/edk/platform/thread_utils.h" |
9 #include "mojo/edk/system/channel.h" | 10 #include "mojo/edk/system/channel.h" |
10 #include "mojo/edk/system/channel_endpoint.h" | 11 #include "mojo/edk/system/channel_endpoint.h" |
11 #include "mojo/edk/system/message_pipe.h" | 12 #include "mojo/edk/system/message_pipe.h" |
12 #include "mojo/edk/system/test/sleep.h" | |
13 #include "mojo/edk/system/test/timeouts.h" | 13 #include "mojo/edk/system/test/timeouts.h" |
14 #include "mojo/edk/system/waiter.h" | 14 #include "mojo/edk/system/waiter.h" |
15 | 15 |
16 using mojo::platform::ScopedPlatformHandle; | 16 using mojo::platform::ScopedPlatformHandle; |
| 17 using mojo::platform::ThreadSleep; |
17 using mojo::util::MakeRefCounted; | 18 using mojo::util::MakeRefCounted; |
18 using mojo::util::RefPtr; | 19 using mojo::util::RefPtr; |
19 | 20 |
20 namespace mojo { | 21 namespace mojo { |
21 namespace system { | 22 namespace system { |
22 namespace test { | 23 namespace test { |
23 | 24 |
24 MojoResult WaitIfNecessary(MessagePipe* mp, | 25 MojoResult WaitIfNecessary(MessagePipe* mp, |
25 MojoHandleSignals signals, | 26 MojoHandleSignals signals, |
26 HandleSignalsState* signals_state) { | 27 HandleSignalsState* signals_state) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 std::move(channel_endpoint)); | 60 std::move(channel_endpoint)); |
60 }); | 61 }); |
61 } | 62 } |
62 | 63 |
63 void ChannelThread::Stop() { | 64 void ChannelThread::Stop() { |
64 if (channel_) { | 65 if (channel_) { |
65 // Hack to flush write buffers before quitting. | 66 // Hack to flush write buffers before quitting. |
66 // TODO(vtl): Remove this once |Channel| has a | 67 // TODO(vtl): Remove this once |Channel| has a |
67 // |FlushWriteBufferAndShutdown()| (or whatever). | 68 // |FlushWriteBufferAndShutdown()| (or whatever). |
68 while (!channel_->IsWriteBufferEmpty()) | 69 while (!channel_->IsWriteBufferEmpty()) |
69 test::Sleep(test::EpsilonTimeout()); | 70 ThreadSleep(test::EpsilonTimeout()); |
70 | 71 |
71 test_io_thread_.PostTaskAndWait([this] { | 72 test_io_thread_.PostTaskAndWait([this] { |
72 channel_->Shutdown(); | 73 channel_->Shutdown(); |
73 channel_ = nullptr; | 74 channel_ = nullptr; |
74 }); | 75 }); |
75 } | 76 } |
76 test_io_thread_.Stop(); | 77 test_io_thread_.Stop(); |
77 } | 78 } |
78 | 79 |
79 void ChannelThread::InitChannelOnIOThread( | 80 void ChannelThread::InitChannelOnIOThread( |
(...skipping 26 matching lines...) Expand all Loading... |
106 } | 107 } |
107 | 108 |
108 void MultiprocessMessagePipeTestBase::Init(RefPtr<ChannelEndpoint>&& ep) { | 109 void MultiprocessMessagePipeTestBase::Init(RefPtr<ChannelEndpoint>&& ep) { |
109 channel_thread_.Start(helper_.server_platform_handle.Pass(), std::move(ep)); | 110 channel_thread_.Start(helper_.server_platform_handle.Pass(), std::move(ep)); |
110 } | 111 } |
111 #endif // !defined(OS_IOS) | 112 #endif // !defined(OS_IOS) |
112 | 113 |
113 } // namespace test | 114 } // namespace test |
114 } // namespace system | 115 } // namespace system |
115 } // namespace mojo | 116 } // namespace mojo |
OLD | NEW |