[email protected] | 922c8e9 | 2013-05-30 05:20:29 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
avi | c5960f3 | 2015-12-22 22:49:48 | [diff] [blame] | 5 | #include "build/build_config.h" |
[email protected] | 922c8e9 | 2013-05-30 05:20:29 | [diff] [blame] | 6 | #include "remoting/host/setup/test_util.h" |
7 | |||||
8 | #if defined(OS_WIN) | ||||
9 | #include <windows.h> | ||||
10 | #elif defined(OS_POSIX) | ||||
11 | #include <unistd.h> | ||||
12 | #endif | ||||
13 | |||||
14 | namespace remoting { | ||||
15 | |||||
[email protected] | 0fa0bbf | 2014-05-02 04:28:00 | [diff] [blame] | 16 | bool MakePipe(base::File* read_file, |
17 | base::File* write_file) { | ||||
[email protected] | 922c8e9 | 2013-05-30 05:20:29 | [diff] [blame] | 18 | #if defined(OS_WIN) |
[email protected] | 0fa0bbf | 2014-05-02 04:28:00 | [diff] [blame] | 19 | base::PlatformFile read_handle; |
20 | base::PlatformFile write_handle; | ||||
sergeyu | c5f104b | 2015-01-09 19:33:24 | [diff] [blame] | 21 | if (!CreatePipe(&read_handle, &write_handle, nullptr, 0)) |
[email protected] | 0fa0bbf | 2014-05-02 04:28:00 | [diff] [blame] | 22 | return false; |
23 | *read_file = base::File(read_handle); | ||||
24 | *write_file = base::File(write_handle); | ||||
25 | return true; | ||||
[email protected] | 922c8e9 | 2013-05-30 05:20:29 | [diff] [blame] | 26 | #elif defined(OS_POSIX) |
27 | int fds[2]; | ||||
28 | if (pipe(fds) == 0) { | ||||
[email protected] | 0fa0bbf | 2014-05-02 04:28:00 | [diff] [blame] | 29 | *read_file = base::File(fds[0]); |
30 | *write_file = base::File(fds[1]); | ||||
[email protected] | 922c8e9 | 2013-05-30 05:20:29 | [diff] [blame] | 31 | return true; |
32 | } | ||||
33 | return false; | ||||
34 | #else | ||||
35 | #error Not implemented | ||||
36 | #endif | ||||
37 | } | ||||
38 | |||||
David Sanders | bb0d6af | 2021-12-22 13:25:55 | [diff] [blame] | 39 | } // namespace remoting |