Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / remoting / host / setup / test_util.cc
blobefac12393f58fcb278f8ddeb24377ffe04013417
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.
5 #include "remoting/host/setup/test_util.h"
7 #if defined(OS_WIN)
8 #include <windows.h>
9 #elif defined(OS_POSIX)
10 #include <unistd.h>
11 #endif
13 namespace remoting {
15 bool MakePipe(base::File* read_file,
16 base::File* write_file) {
17 #if defined(OS_WIN)
18 base::PlatformFile read_handle;
19 base::PlatformFile write_handle;
20 if (!CreatePipe(&read_handle, &write_handle, nullptr, 0))
21 return false;
22 *read_file = base::File(read_handle);
23 *write_file = base::File(write_handle);
24 return true;
25 #elif defined(OS_POSIX)
26 int fds[2];
27 if (pipe(fds) == 0) {
28 *read_file = base::File(fds[0]);
29 *write_file = base::File(fds[1]);
30 return true;
32 return false;
33 #else
34 #error Not implemented
35 #endif
38 } // namepsace remoting