| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <stdio.h> | 6 #include <stdio.h> |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "mojo/edk/embedder/platform_channel_pair.h" | |
| 15 #include "mojo/edk/embedder/simple_platform_support.h" | 14 #include "mojo/edk/embedder/simple_platform_support.h" |
| 15 #include "mojo/edk/platform/platform_pipe.h" |
| 16 #include "mojo/edk/platform/platform_shared_buffer.h" | 16 #include "mojo/edk/platform/platform_shared_buffer.h" |
| 17 #include "mojo/edk/platform/scoped_platform_handle.h" | 17 #include "mojo/edk/platform/scoped_platform_handle.h" |
| 18 #include "mojo/edk/platform/thread_utils.h" | 18 #include "mojo/edk/platform/thread_utils.h" |
| 19 #include "mojo/edk/system/channel.h" | 19 #include "mojo/edk/system/channel.h" |
| 20 #include "mojo/edk/system/channel_endpoint.h" | 20 #include "mojo/edk/system/channel_endpoint.h" |
| 21 #include "mojo/edk/system/channel_endpoint_id.h" | 21 #include "mojo/edk/system/channel_endpoint_id.h" |
| 22 #include "mojo/edk/system/incoming_endpoint.h" | 22 #include "mojo/edk/system/incoming_endpoint.h" |
| 23 #include "mojo/edk/system/message_pipe.h" | 23 #include "mojo/edk/system/message_pipe.h" |
| 24 #include "mojo/edk/system/message_pipe_dispatcher.h" | 24 #include "mojo/edk/system/message_pipe_dispatcher.h" |
| 25 #include "mojo/edk/system/platform_handle_dispatcher.h" | 25 #include "mojo/edk/system/platform_handle_dispatcher.h" |
| 26 #include "mojo/edk/system/raw_channel.h" | 26 #include "mojo/edk/system/raw_channel.h" |
| 27 #include "mojo/edk/system/shared_buffer_dispatcher.h" | 27 #include "mojo/edk/system/shared_buffer_dispatcher.h" |
| 28 #include "mojo/edk/system/test/scoped_test_dir.h" | 28 #include "mojo/edk/system/test/scoped_test_dir.h" |
| 29 #include "mojo/edk/system/test/test_io_thread.h" | 29 #include "mojo/edk/system/test/test_io_thread.h" |
| 30 #include "mojo/edk/system/test/timeouts.h" | 30 #include "mojo/edk/system/test/timeouts.h" |
| 31 #include "mojo/edk/system/waiter.h" | 31 #include "mojo/edk/system/waiter.h" |
| 32 #include "mojo/edk/test/test_utils.h" | 32 #include "mojo/edk/test/test_utils.h" |
| 33 #include "mojo/edk/util/ref_ptr.h" | 33 #include "mojo/edk/util/ref_ptr.h" |
| 34 #include "mojo/edk/util/scoped_file.h" | 34 #include "mojo/edk/util/scoped_file.h" |
| 35 #include "mojo/public/cpp/system/macros.h" | 35 #include "mojo/public/cpp/system/macros.h" |
| 36 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
| 37 | 37 |
| 38 using mojo::platform::PlatformPipe; |
| 38 using mojo::platform::PlatformSharedBufferMapping; | 39 using mojo::platform::PlatformSharedBufferMapping; |
| 39 using mojo::platform::ScopedPlatformHandle; | 40 using mojo::platform::ScopedPlatformHandle; |
| 40 using mojo::platform::ThreadSleep; | 41 using mojo::platform::ThreadSleep; |
| 41 using mojo::util::MakeRefCounted; | 42 using mojo::util::MakeRefCounted; |
| 42 using mojo::util::RefPtr; | 43 using mojo::util::RefPtr; |
| 43 | 44 |
| 44 namespace mojo { | 45 namespace mojo { |
| 45 namespace system { | 46 namespace system { |
| 46 namespace { | 47 namespace { |
| 47 | 48 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 embedder::PlatformSupport* platform_support() { return &platform_support_; } | 93 embedder::PlatformSupport* platform_support() { return &platform_support_; } |
| 93 test::TestIOThread* io_thread() { return &io_thread_; } | 94 test::TestIOThread* io_thread() { return &io_thread_; } |
| 94 // Warning: It's up to the caller to ensure that the returned channel | 95 // Warning: It's up to the caller to ensure that the returned channel |
| 95 // is/remains valid. | 96 // is/remains valid. |
| 96 Channel* channels(size_t i) { return channels_[i].get(); } | 97 Channel* channels(size_t i) { return channels_[i].get(); } |
| 97 | 98 |
| 98 private: | 99 private: |
| 99 void SetUpOnIOThread() { | 100 void SetUpOnIOThread() { |
| 100 CHECK(io_thread()->IsCurrentAndRunning()); | 101 CHECK(io_thread()->IsCurrentAndRunning()); |
| 101 | 102 |
| 102 embedder::PlatformChannelPair channel_pair; | 103 PlatformPipe channel_pair; |
| 103 platform_handles_[0] = channel_pair.handle0.Pass(); | 104 platform_handles_[0] = channel_pair.handle0.Pass(); |
| 104 platform_handles_[1] = channel_pair.handle1.Pass(); | 105 platform_handles_[1] = channel_pair.handle1.Pass(); |
| 105 } | 106 } |
| 106 | 107 |
| 107 void TearDownOnIOThread() { | 108 void TearDownOnIOThread() { |
| 108 CHECK(io_thread()->IsCurrentAndRunning()); | 109 CHECK(io_thread()->IsCurrentAndRunning()); |
| 109 | 110 |
| 110 if (channels_[0]) { | 111 if (channels_[0]) { |
| 111 channels_[0]->Shutdown(); | 112 channels_[0]->Shutdown(); |
| 112 channels_[0] = nullptr; | 113 channels_[0] = nullptr; |
| (...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1352 mp0->Close(0); | 1353 mp0->Close(0); |
| 1353 mp1->Close(1); | 1354 mp1->Close(1); |
| 1354 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); | 1355 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); |
| 1355 // Note that |local_mp|'s port 0 belong to |dispatcher|, which was closed. | 1356 // Note that |local_mp|'s port 0 belong to |dispatcher|, which was closed. |
| 1356 local_mp->Close(1); | 1357 local_mp->Close(1); |
| 1357 } | 1358 } |
| 1358 | 1359 |
| 1359 } // namespace | 1360 } // namespace |
| 1360 } // namespace system | 1361 } // namespace system |
| 1361 } // namespace mojo | 1362 } // namespace mojo |
| OLD | NEW |