| 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/raw_channel.h" | 5 #include "mojo/edk/system/raw_channel.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 15 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/memory/scoped_vector.h" | 19 #include "base/memory/scoped_vector.h" |
| 20 #include "base/synchronization/waitable_event.h" | 20 #include "base/synchronization/waitable_event.h" |
| 21 #include "base/threading/simple_thread.h" | 21 #include "base/threading/simple_thread.h" |
| 22 #include "build/build_config.h" // TODO(vtl): Remove this. | |
| 23 #include "mojo/edk/embedder/platform_channel_pair.h" | 22 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 24 #include "mojo/edk/embedder/platform_handle.h" | 23 #include "mojo/edk/embedder/platform_handle.h" |
| 25 #include "mojo/edk/embedder/scoped_platform_handle.h" | 24 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 26 #include "mojo/edk/system/message_in_transit.h" | 25 #include "mojo/edk/system/message_in_transit.h" |
| 27 #include "mojo/edk/system/mutex.h" | 26 #include "mojo/edk/system/mutex.h" |
| 28 #include "mojo/edk/system/test_utils.h" | 27 #include "mojo/edk/system/test_utils.h" |
| 29 #include "mojo/edk/system/transport_data.h" | 28 #include "mojo/edk/system/transport_data.h" |
| 30 #include "mojo/edk/test/test_io_thread.h" | 29 #include "mojo/edk/test/test_io_thread.h" |
| 31 #include "mojo/edk/test/test_utils.h" | 30 #include "mojo/edk/test/test_utils.h" |
| 32 #include "mojo/edk/util/scoped_file.h" | 31 #include "mojo/edk/util/scoped_file.h" |
| (...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 } | 786 } |
| 788 | 787 |
| 789 void Wait() { done_event_.Wait(); } | 788 void Wait() { done_event_.Wait(); } |
| 790 | 789 |
| 791 private: | 790 private: |
| 792 base::WaitableEvent done_event_; | 791 base::WaitableEvent done_event_; |
| 793 | 792 |
| 794 MOJO_DISALLOW_COPY_AND_ASSIGN(ReadPlatformHandlesCheckerRawChannelDelegate); | 793 MOJO_DISALLOW_COPY_AND_ASSIGN(ReadPlatformHandlesCheckerRawChannelDelegate); |
| 795 }; | 794 }; |
| 796 | 795 |
| 797 #if defined(OS_POSIX) | 796 TEST_F(RawChannelTest, ReadWritePlatformHandles) { |
| 798 #define MAYBE_ReadWritePlatformHandles ReadWritePlatformHandles | |
| 799 #else | |
| 800 // Not yet implemented (on Windows). | |
| 801 #define MAYBE_ReadWritePlatformHandles DISABLED_ReadWritePlatformHandles | |
| 802 #endif | |
| 803 TEST_F(RawChannelTest, MAYBE_ReadWritePlatformHandles) { | |
| 804 base::ScopedTempDir temp_dir; | 797 base::ScopedTempDir temp_dir; |
| 805 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 798 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 806 | 799 |
| 807 WriteOnlyRawChannelDelegate write_delegate; | 800 WriteOnlyRawChannelDelegate write_delegate; |
| 808 scoped_ptr<RawChannel> rc_write(RawChannel::Create(handles[0].Pass())); | 801 scoped_ptr<RawChannel> rc_write(RawChannel::Create(handles[0].Pass())); |
| 809 io_thread()->PostTaskAndWait(FROM_HERE, | 802 io_thread()->PostTaskAndWait(FROM_HERE, |
| 810 base::Bind(&InitOnIOThread, rc_write.get(), | 803 base::Bind(&InitOnIOThread, rc_write.get(), |
| 811 base::Unretained(&write_delegate))); | 804 base::Unretained(&write_delegate))); |
| 812 | 805 |
| 813 ReadPlatformHandlesCheckerRawChannelDelegate read_delegate; | 806 ReadPlatformHandlesCheckerRawChannelDelegate read_delegate; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 FROM_HERE, | 841 FROM_HERE, |
| 849 base::Bind(&RawChannel::Shutdown, base::Unretained(rc_read.get()))); | 842 base::Bind(&RawChannel::Shutdown, base::Unretained(rc_read.get()))); |
| 850 io_thread()->PostTaskAndWait( | 843 io_thread()->PostTaskAndWait( |
| 851 FROM_HERE, | 844 FROM_HERE, |
| 852 base::Bind(&RawChannel::Shutdown, base::Unretained(rc_write.get()))); | 845 base::Bind(&RawChannel::Shutdown, base::Unretained(rc_write.get()))); |
| 853 } | 846 } |
| 854 | 847 |
| 855 } // namespace | 848 } // namespace |
| 856 } // namespace system | 849 } // namespace system |
| 857 } // namespace mojo | 850 } // namespace mojo |
| OLD | NEW |