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/files/file.h"
9 #include "base/process/process.h"
10 #include "ipc/ipc_export.h"
13 #include "base/file_descriptor_posix.h"
19 typedef base::PlatformFile PlatformFileForTransit
;
20 #elif defined(OS_POSIX)
21 typedef base::FileDescriptor PlatformFileForTransit
;
24 inline PlatformFileForTransit
InvalidPlatformFileForTransit() {
26 return INVALID_HANDLE_VALUE
;
27 #elif defined(OS_POSIX)
28 return base::FileDescriptor();
32 inline base::PlatformFile
PlatformFileForTransitToPlatformFile(
33 const PlatformFileForTransit
& transit
) {
36 #elif defined(OS_POSIX)
41 inline base::File
PlatformFileForTransitToFile(
42 const PlatformFileForTransit
& transit
) {
44 return base::File(transit
);
45 #elif defined(OS_POSIX)
46 return base::File(transit
.fd
);
50 // Returns a file handle equivalent to |file| that can be used in |process|.
51 IPC_EXPORT PlatformFileForTransit
GetFileHandleForProcess(
52 base::PlatformFile file
,
53 base::ProcessHandle process
,
54 bool close_source_handle
);
56 // Returns a file handle equivalent to |file| that can be used in |process|.
57 // Note that this function takes ownership of |file|.
58 IPC_EXPORT PlatformFileForTransit
TakeFileHandleForProcess(
60 base::ProcessHandle process
);
64 #endif // IPC_IPC_PLATFORM_FILE_H_