Updating trunk VERSION from 1007.0 to 1008.0
[chromium-blink-merge.git] / ipc / ipc_platform_file.h
blobdaaf21cb14b241f07333c25ab825e1518773cc36
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_
7 #pragma once
9 #include "base/basictypes.h"
10 #include "base/platform_file.h"
11 #include "base/process.h"
12 #include "ipc/ipc_export.h"
14 #if defined(OS_POSIX)
15 #include "base/file_descriptor_posix.h"
16 #endif
18 namespace IPC {
20 #if defined(OS_WIN)
21 typedef base::PlatformFile PlatformFileForTransit;
22 #elif defined(OS_POSIX)
23 typedef base::FileDescriptor PlatformFileForTransit;
24 #endif
26 inline PlatformFileForTransit InvalidPlatformFileForTransit() {
27 #if defined(OS_WIN)
28 return base::kInvalidPlatformFileValue;
29 #elif defined(OS_POSIX)
30 return base::FileDescriptor();
31 #endif
34 inline base::PlatformFile PlatformFileForTransitToPlatformFile(
35 const PlatformFileForTransit& transit) {
36 #if defined(OS_WIN)
37 return transit;
38 #elif defined(OS_POSIX)
39 return transit.fd;
40 #endif
43 // Returns a file handle equivalent to |file| that can be used in |process|.
44 IPC_EXPORT PlatformFileForTransit GetFileHandleForProcess(
45 base::PlatformFile file,
46 base::ProcessHandle process,
47 bool close_source_handle);
49 } // namespace IPC
51 #endif // IPC_IPC_PLATFORM_FILE_H_