Fix translation extraction failure.
[chromium-blink-merge.git] / ipc / ipc_platform_file.h
blobdf6e8e394c054de21b51d11d642f2cc0c806130b
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"
12 #if defined(OS_POSIX)
13 #include "base/file_descriptor_posix.h"
14 #endif
16 namespace IPC {
18 #if defined(OS_WIN)
19 typedef base::PlatformFile PlatformFileForTransit;
20 #elif defined(OS_POSIX)
21 typedef base::FileDescriptor PlatformFileForTransit;
22 #endif
24 inline PlatformFileForTransit InvalidPlatformFileForTransit() {
25 #if defined(OS_WIN)
26 return INVALID_HANDLE_VALUE;
27 #elif defined(OS_POSIX)
28 return base::FileDescriptor();
29 #endif
32 inline base::PlatformFile PlatformFileForTransitToPlatformFile(
33 const PlatformFileForTransit& transit) {
34 #if defined(OS_WIN)
35 return transit;
36 #elif defined(OS_POSIX)
37 return transit.fd;
38 #endif
41 inline base::File PlatformFileForTransitToFile(
42 const PlatformFileForTransit& transit) {
43 #if defined(OS_WIN)
44 return base::File(transit);
45 #elif defined(OS_POSIX)
46 return base::File(transit.fd);
47 #endif
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(
59 base::File file,
60 base::ProcessHandle process);
62 } // namespace IPC
64 #endif // IPC_IPC_PLATFORM_FILE_H_