1 // Copyright (c) 2011 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 #ifndef IPC_IPC_PLATFORM_FILE_H_
6 #define IPC_IPC_PLATFORM_FILE_H_
8 #include "base/basictypes.h"
9 #include "base/files/file.h"
10 #include "base/platform_file.h"
11 #include "base/process/process.h"
12 #include "ipc/ipc_export.h"
15 #include "base/file_descriptor_posix.h"
21 typedef base::PlatformFile PlatformFileForTransit
;
22 #elif defined(OS_POSIX)
23 typedef base::FileDescriptor PlatformFileForTransit
;
26 inline PlatformFileForTransit
InvalidPlatformFileForTransit() {
28 return base::kInvalidPlatformFileValue
;
29 #elif defined(OS_POSIX)
30 return base::FileDescriptor();
34 inline base::PlatformFile
PlatformFileForTransitToPlatformFile(
35 const PlatformFileForTransit
& transit
) {
38 #elif defined(OS_POSIX)
43 inline base::File
PlatformFileForTransitToFile(
44 const PlatformFileForTransit
& transit
) {
46 return base::File(transit
);
47 #elif defined(OS_POSIX)
48 return base::File(transit
.fd
);
52 // Returns a file handle equivalent to |file| that can be used in |process|.
53 IPC_EXPORT PlatformFileForTransit
GetFileHandleForProcess(
54 base::PlatformFile file
,
55 base::ProcessHandle process
,
56 bool close_source_handle
);
58 // Returns a file handle equivalent to |file| that can be used in |process|.
59 // Note that this function takes ownership of |file|.
60 IPC_EXPORT PlatformFileForTransit
TakeFileHandleForProcess(
62 base::ProcessHandle process
);
66 #endif // IPC_IPC_PLATFORM_FILE_H_