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 #include "mojo/edk/system/ipc_support.h" | 5 #include "mojo/edk/system/ipc_support.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 69 matching lines...) Loading... |
80 // from |read_mp| (it should be the next message, i.e., there should be no other | 80 // from |read_mp| (it should be the next message, i.e., there should be no other |
81 // other messages already enqueued in that direction). | 81 // other messages already enqueued in that direction). |
82 // TODO(vtl): Probably |mp_to_send| should be a |Handle|, and so should the | 82 // TODO(vtl): Probably |mp_to_send| should be a |Handle|, and so should the |
83 // return value. | 83 // return value. |
84 RefPtr<MessagePipeDispatcher> SendMessagePipeDispatcher( | 84 RefPtr<MessagePipeDispatcher> SendMessagePipeDispatcher( |
85 MessagePipeDispatcher* write_mp, | 85 MessagePipeDispatcher* write_mp, |
86 MessagePipeDispatcher* read_mp, | 86 MessagePipeDispatcher* read_mp, |
87 RefPtr<MessagePipeDispatcher>&& mp_to_send) { | 87 RefPtr<MessagePipeDispatcher>&& mp_to_send) { |
88 CHECK_NE(mp_to_send.get(), write_mp); | 88 CHECK_NE(mp_to_send.get(), write_mp); |
89 CHECK_NE(mp_to_send.get(), read_mp); | 89 CHECK_NE(mp_to_send.get(), read_mp); |
90 Handle mp_handle_to_send(std::move(mp_to_send), MOJO_HANDLE_RIGHT_TRANSFER | | 90 Handle mp_handle_to_send(std::move(mp_to_send), |
91 MOJO_HANDLE_RIGHT_READ | | 91 MessagePipeDispatcher::kDefaultHandleRights); |
92 MOJO_HANDLE_RIGHT_WRITE); | |
93 | 92 |
94 // Set up waiting on the read end first (to avoid racing). | 93 // Set up waiting on the read end first (to avoid racing). |
95 Waiter waiter; | 94 Waiter waiter; |
96 waiter.Init(); | 95 waiter.Init(); |
97 CHECK_EQ( | 96 CHECK_EQ( |
98 read_mp->AddAwakable(&waiter, MOJO_HANDLE_SIGNAL_READABLE, 0, nullptr), | 97 read_mp->AddAwakable(&waiter, MOJO_HANDLE_SIGNAL_READABLE, 0, nullptr), |
99 MOJO_RESULT_OK); | 98 MOJO_RESULT_OK); |
100 | 99 |
101 // Write a message with just |mp_handle_to_send| through the write end. | 100 // Write a message with just |mp_handle_to_send| through the write end. |
102 HandleTransport transport(test::HandleTryStartTransport(mp_handle_to_send)); | 101 HandleTransport transport(test::HandleTryStartTransport(mp_handle_to_send)); |
(...skipping 614 matching lines...) Loading... |
717 | 716 |
718 test_io_thread.PostTaskAndWait( | 717 test_io_thread.PostTaskAndWait( |
719 [&ipc_support]() { ipc_support.ShutdownOnIOThread(); }); | 718 [&ipc_support]() { ipc_support.ShutdownOnIOThread(); }); |
720 } | 719 } |
721 | 720 |
722 // TODO(vtl): Also test the case of the master "dying" before the slave. (The | 721 // TODO(vtl): Also test the case of the master "dying" before the slave. (The |
723 // slave should get OnMasterDisconnect(), which we currently don't test.) | 722 // slave should get OnMasterDisconnect(), which we currently don't test.) |
724 | 723 |
725 } // namespace system | 724 } // namespace system |
726 } // namespace mojo | 725 } // namespace mojo |
OLD | NEW |