| 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 #include "base/files/scoped_file.h" | |
| 15 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
| 16 #include "base/location.h" | 15 #include "base/location.h" |
| 17 #include "base/logging.h" | 16 #include "base/logging.h" |
| 18 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 19 #include "build/build_config.h" // TODO(vtl): Remove this. | 18 #include "build/build_config.h" // TODO(vtl): Remove this. |
| 20 #include "mojo/edk/embedder/platform_channel_pair.h" | 19 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 21 #include "mojo/edk/embedder/platform_shared_buffer.h" | 20 #include "mojo/edk/embedder/platform_shared_buffer.h" |
| 22 #include "mojo/edk/embedder/scoped_platform_handle.h" | 21 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 23 #include "mojo/edk/embedder/simple_platform_support.h" | 22 #include "mojo/edk/embedder/simple_platform_support.h" |
| 24 #include "mojo/edk/system/channel.h" | 23 #include "mojo/edk/system/channel.h" |
| 25 #include "mojo/edk/system/channel_endpoint.h" | 24 #include "mojo/edk/system/channel_endpoint.h" |
| 26 #include "mojo/edk/system/channel_endpoint_id.h" | 25 #include "mojo/edk/system/channel_endpoint_id.h" |
| 27 #include "mojo/edk/system/incoming_endpoint.h" | 26 #include "mojo/edk/system/incoming_endpoint.h" |
| 28 #include "mojo/edk/system/message_pipe.h" | 27 #include "mojo/edk/system/message_pipe.h" |
| 29 #include "mojo/edk/system/message_pipe_dispatcher.h" | 28 #include "mojo/edk/system/message_pipe_dispatcher.h" |
| 30 #include "mojo/edk/system/platform_handle_dispatcher.h" | 29 #include "mojo/edk/system/platform_handle_dispatcher.h" |
| 31 #include "mojo/edk/system/raw_channel.h" | 30 #include "mojo/edk/system/raw_channel.h" |
| 32 #include "mojo/edk/system/shared_buffer_dispatcher.h" | 31 #include "mojo/edk/system/shared_buffer_dispatcher.h" |
| 33 #include "mojo/edk/system/test_utils.h" | 32 #include "mojo/edk/system/test_utils.h" |
| 34 #include "mojo/edk/system/waiter.h" | 33 #include "mojo/edk/system/waiter.h" |
| 35 #include "mojo/edk/test/test_io_thread.h" | 34 #include "mojo/edk/test/test_io_thread.h" |
| 36 #include "mojo/edk/test/test_utils.h" | 35 #include "mojo/edk/test/test_utils.h" |
| 36 #include "mojo/edk/util/scoped_file.h" |
| 37 #include "mojo/public/cpp/system/macros.h" | 37 #include "mojo/public/cpp/system/macros.h" |
| 38 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
| 39 | 39 |
| 40 namespace mojo { | 40 namespace mojo { |
| 41 namespace system { | 41 namespace system { |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 const MojoHandleSignals kAllSignals = MOJO_HANDLE_SIGNAL_READABLE | | 44 const MojoHandleSignals kAllSignals = MOJO_HANDLE_SIGNAL_READABLE | |
| 45 MOJO_HANDLE_SIGNAL_WRITABLE | | 45 MOJO_HANDLE_SIGNAL_WRITABLE | |
| 46 MOJO_HANDLE_SIGNAL_PEER_CLOSED; | 46 MOJO_HANDLE_SIGNAL_PEER_CLOSED; |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 uint32_t context = 0; | 1033 uint32_t context = 0; |
| 1034 HandleSignalsState hss; | 1034 HandleSignalsState hss; |
| 1035 | 1035 |
| 1036 scoped_refptr<ChannelEndpoint> ep0; | 1036 scoped_refptr<ChannelEndpoint> ep0; |
| 1037 scoped_refptr<MessagePipe> mp0(MessagePipe::CreateLocalProxy(&ep0)); | 1037 scoped_refptr<MessagePipe> mp0(MessagePipe::CreateLocalProxy(&ep0)); |
| 1038 scoped_refptr<ChannelEndpoint> ep1; | 1038 scoped_refptr<ChannelEndpoint> ep1; |
| 1039 scoped_refptr<MessagePipe> mp1(MessagePipe::CreateProxyLocal(&ep1)); | 1039 scoped_refptr<MessagePipe> mp1(MessagePipe::CreateProxyLocal(&ep1)); |
| 1040 BootstrapChannelEndpoints(ep0, ep1); | 1040 BootstrapChannelEndpoints(ep0, ep1); |
| 1041 | 1041 |
| 1042 base::FilePath unused; | 1042 base::FilePath unused; |
| 1043 base::ScopedFILE fp( | 1043 util::ScopedFILE fp( |
| 1044 base::CreateAndOpenTemporaryFileInDir(temp_dir.path(), &unused)); | 1044 base::CreateAndOpenTemporaryFileInDir(temp_dir.path(), &unused)); |
| 1045 EXPECT_EQ(sizeof(kHello), fwrite(kHello, 1, sizeof(kHello), fp.get())); | 1045 EXPECT_EQ(sizeof(kHello), fwrite(kHello, 1, sizeof(kHello), fp.get())); |
| 1046 // We'll try to pass this dispatcher, which will cause a |PlatformHandle| to | 1046 // We'll try to pass this dispatcher, which will cause a |PlatformHandle| to |
| 1047 // be passed. | 1047 // be passed. |
| 1048 scoped_refptr<PlatformHandleDispatcher> dispatcher = | 1048 scoped_refptr<PlatformHandleDispatcher> dispatcher = |
| 1049 PlatformHandleDispatcher::Create( | 1049 PlatformHandleDispatcher::Create( |
| 1050 mojo::test::PlatformHandleFromFILE(fp.Pass())); | 1050 mojo::test::PlatformHandleFromFILE(fp.Pass())); |
| 1051 | 1051 |
| 1052 // Prepare to wait on MP 1, port 1. (Add the waiter now. Otherwise, if we do | 1052 // Prepare to wait on MP 1, port 1. (Add the waiter now. Otherwise, if we do |
| 1053 // it later, it might already be readable.) | 1053 // it later, it might already be readable.) |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 mp0->Close(0); | 1369 mp0->Close(0); |
| 1370 mp1->Close(1); | 1370 mp1->Close(1); |
| 1371 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); | 1371 EXPECT_EQ(MOJO_RESULT_OK, dispatcher->Close()); |
| 1372 // Note that |local_mp|'s port 0 belong to |dispatcher|, which was closed. | 1372 // Note that |local_mp|'s port 0 belong to |dispatcher|, which was closed. |
| 1373 local_mp->Close(1); | 1373 local_mp->Close(1); |
| 1374 } | 1374 } |
| 1375 | 1375 |
| 1376 } // namespace | 1376 } // namespace |
| 1377 } // namespace system | 1377 } // namespace system |
| 1378 } // namespace mojo | 1378 } // namespace mojo |
| OLD | NEW |