Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Side by Side Diff: ipc/ipc_platform_file.h

Issue 1830853002: Make PlatformFileForTransit a class on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from mseaborn. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/ipc_message_utils.cc ('k') | ipc/ipc_platform_file.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/files/file.h" 8 #include "base/files/file.h"
9 #include "base/process/process.h" 9 #include "base/process/process.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "ipc/ipc_export.h" 11 #include "ipc/ipc_export.h"
12 12
13 #if defined(OS_POSIX) 13 #if defined(OS_POSIX)
14 #include "base/file_descriptor_posix.h" 14 #include "base/file_descriptor_posix.h"
15 #endif 15 #endif
16 16
17 #if defined(OS_WIN)
18 #include "base/memory/shared_memory_handle.h"
19 #endif
20
17 namespace IPC { 21 namespace IPC {
18 22
19 #if defined(OS_WIN) 23 #if defined(OS_WIN)
20 typedef base::PlatformFile PlatformFileForTransit; 24 // The semantics for IPC transfer of a SharedMemoryHandle are exactly the same
25 // as for a PlatformFileForTransit. The object wraps a HANDLE, and has some
26 // metadata that indicates the process to which the HANDLE belongs.
27 using PlatformFileForTransit = base::SharedMemoryHandle;
21 #elif defined(OS_POSIX) 28 #elif defined(OS_POSIX)
22 typedef base::FileDescriptor PlatformFileForTransit; 29 typedef base::FileDescriptor PlatformFileForTransit;
23 #endif 30 #endif
24 31
25 inline PlatformFileForTransit InvalidPlatformFileForTransit() { 32 inline PlatformFileForTransit InvalidPlatformFileForTransit() {
26 #if defined(OS_WIN) 33 #if defined(OS_WIN)
27 return INVALID_HANDLE_VALUE; 34 return PlatformFileForTransit();
28 #elif defined(OS_POSIX) 35 #elif defined(OS_POSIX)
29 return base::FileDescriptor(); 36 return base::FileDescriptor();
30 #endif 37 #endif
31 } 38 }
32 39
33 inline base::PlatformFile PlatformFileForTransitToPlatformFile( 40 inline base::PlatformFile PlatformFileForTransitToPlatformFile(
34 const PlatformFileForTransit& transit) { 41 const PlatformFileForTransit& transit) {
35 #if defined(OS_WIN) 42 #if defined(OS_WIN)
36 return transit; 43 return transit.GetHandle();
37 #elif defined(OS_POSIX) 44 #elif defined(OS_POSIX)
38 return transit.fd; 45 return transit.fd;
39 #endif 46 #endif
40 } 47 }
41 48
42 inline base::File PlatformFileForTransitToFile( 49 inline base::File PlatformFileForTransitToFile(
43 const PlatformFileForTransit& transit) { 50 const PlatformFileForTransit& transit) {
44 #if defined(OS_WIN) 51 #if defined(OS_WIN)
45 return base::File(transit); 52 return base::File(transit.GetHandle());
46 #elif defined(OS_POSIX) 53 #elif defined(OS_POSIX)
47 return base::File(transit.fd); 54 return base::File(transit.fd);
48 #endif 55 #endif
49 } 56 }
50 57
51 // Returns a file handle equivalent to |file| that can be used in |process|. 58 // Returns a file handle equivalent to |file| that can be used in |process|.
52 IPC_EXPORT PlatformFileForTransit GetFileHandleForProcess( 59 IPC_EXPORT PlatformFileForTransit GetFileHandleForProcess(
53 base::PlatformFile file, 60 base::PlatformFile file,
54 base::ProcessHandle process, 61 base::ProcessHandle process,
55 bool close_source_handle); 62 bool close_source_handle);
56 63
57 // Returns a file handle equivalent to |file| that can be used in |process|. 64 // Returns a file handle equivalent to |file| that can be used in |process|.
58 // Note that this function takes ownership of |file|. 65 // Note that this function takes ownership of |file|.
59 IPC_EXPORT PlatformFileForTransit TakeFileHandleForProcess( 66 IPC_EXPORT PlatformFileForTransit TakeFileHandleForProcess(
60 base::File file, 67 base::File file,
61 base::ProcessHandle process); 68 base::ProcessHandle process);
62 69
63 } // namespace IPC 70 } // namespace IPC
64 71
65 #endif // IPC_IPC_PLATFORM_FILE_H_ 72 #endif // IPC_IPC_PLATFORM_FILE_H_
OLDNEW
« no previous file with comments | « ipc/ipc_message_utils.cc ('k') | ipc/ipc_platform_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698