OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef IPC_IPC_PLATFORM_FILE_H_ | 5 #ifndef IPC_IPC_PLATFORM_FILE_H_ |
6 #define IPC_IPC_PLATFORM_FILE_H_ | 6 #define IPC_IPC_PLATFORM_FILE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 | 9 |
10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
11 | 11 |
12 #if defined(OS_POSIX) | 12 #if defined(OS_POSIX) |
13 #include "base/file_descriptor_posix.h" | 13 #include "base/file_descriptor_posix.h" |
14 #endif | 14 #endif |
15 | 15 |
16 namespace IPC { | 16 namespace IPC { |
17 | 17 |
18 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
19 typedef base::PlatformFile PlatformFileForTransit; | 19 typedef base::PlatformFile PlatformFileForTransit; |
20 #elif defined(OS_POSIX) | 20 #elif defined(OS_POSIX) |
21 typedef base::FileDescriptor PlatformFileForTransit; | 21 typedef base::FileDescriptor PlatformFileForTransit; |
22 #endif | 22 #endif |
23 | 23 |
| 24 inline PlatformFileForTransit InvalidPlatformFileForTransit() { |
| 25 #if defined(OS_WIN) |
| 26 return base::kInvalidPlatformFileValue; |
| 27 #elif defined(OS_POSIX) |
| 28 return base::FileDescriptor(); |
| 29 #endif |
| 30 } |
| 31 |
24 inline base::PlatformFile PlatformFileForTransitToPlatformFile( | 32 inline base::PlatformFile PlatformFileForTransitToPlatformFile( |
25 const PlatformFileForTransit& transit) { | 33 const PlatformFileForTransit& transit) { |
26 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
27 return transit; | 35 return transit; |
28 #elif defined(OS_POSIX) | 36 #elif defined(OS_POSIX) |
29 return transit.fd; | 37 return transit.fd; |
30 #endif | 38 #endif |
31 } | 39 } |
32 | 40 |
33 } // namespace IPC | 41 } // namespace IPC |
34 | 42 |
35 #endif // IPC_IPC_PLATFORM_FILE_H_ | 43 #endif // IPC_IPC_PLATFORM_FILE_H_ |
OLD | NEW |