OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // This file provides a C++ wrapping around the Mojo C API for platform handles, | 5 // This file provides a C++ wrapping around the Mojo C API for platform handles, |
6 // replacing the prefix of "Mojo" with a "mojo" namespace. | 6 // replacing the prefix of "Mojo" with a "mojo" namespace. |
7 // | 7 // |
8 // Please see "mojo/public/c/system/platform_handle.h" for complete | 8 // Please see "mojo/public/c/system/platform_handle.h" for complete |
9 // documentation of the API. | 9 // documentation of the API. |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "mojo/public/cpp/system/buffer.h" | 23 #include "mojo/public/cpp/system/buffer.h" |
24 #include "mojo/public/cpp/system/handle.h" | 24 #include "mojo/public/cpp/system/handle.h" |
25 | 25 |
26 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
27 #include <windows.h> | 27 #include <windows.h> |
28 #endif | 28 #endif |
29 | 29 |
30 namespace mojo { | 30 namespace mojo { |
31 | 31 |
32 #if defined(OS_POSIX) | 32 #if defined(OS_POSIX) |
33 | |
34 const MojoPlatformHandleType kPlatformFileHandleType = | 33 const MojoPlatformHandleType kPlatformFileHandleType = |
35 MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR; | 34 MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR; |
36 const base::PlatformFile kInvalidPlatformFile = -1; | |
37 | 35 |
38 #if defined(OS_MACOSX) && !defined(OS_IOS) | 36 #if defined(OS_MACOSX) && !defined(OS_IOS) |
39 const MojoPlatformHandleType kPlatformSharedBufferHandleType = | 37 const MojoPlatformHandleType kPlatformSharedBufferHandleType = |
40 MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT; | 38 MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT; |
41 #else | 39 #else |
42 const MojoPlatformHandleType kPlatformSharedBufferHandleType = | 40 const MojoPlatformHandleType kPlatformSharedBufferHandleType = |
43 MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR; | 41 MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR; |
44 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 42 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
45 | 43 |
46 #elif defined(OS_WIN) | 44 #elif defined(OS_WIN) |
47 const MojoPlatformHandleType kPlatformFileHandleType = | 45 const MojoPlatformHandleType kPlatformFileHandleType = |
48 MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE; | 46 MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE; |
49 const base::PlatformFile kInvalidPlatformFile = INVALID_HANDLE_VALUE; | |
50 | 47 |
51 const MojoPlatformHandleType kPlatformSharedBufferHandleType = | 48 const MojoPlatformHandleType kPlatformSharedBufferHandleType = |
52 MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE; | 49 MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE; |
53 #endif // defined(OS_POSIX) | 50 #endif // defined(OS_POSIX) |
54 | 51 |
55 // Wraps a PlatformFile as a Mojo handle. Takes ownership of the file object. | 52 // Wraps a PlatformFile as a Mojo handle. Takes ownership of the file object. |
56 ScopedHandle WrapPlatformFile(base::PlatformFile platform_file); | 53 ScopedHandle WrapPlatformFile(base::PlatformFile platform_file); |
57 | 54 |
58 // Unwraps a PlatformFile from a Mojo handle. | 55 // Unwraps a PlatformFile from a Mojo handle. |
59 MojoResult UnwrapPlatformFile(ScopedHandle handle, base::PlatformFile* file); | 56 MojoResult UnwrapPlatformFile(ScopedHandle handle, base::PlatformFile* file); |
(...skipping 10 matching lines...) Expand all Loading... |
70 // Unwraps a base::SharedMemoryHandle from a Mojo handle. The caller assumes | 67 // Unwraps a base::SharedMemoryHandle from a Mojo handle. The caller assumes |
71 // responsibility for the lifetime of the SharedMemoryHandle. | 68 // responsibility for the lifetime of the SharedMemoryHandle. |
72 MojoResult UnwrapSharedMemoryHandle(ScopedSharedBufferHandle handle, | 69 MojoResult UnwrapSharedMemoryHandle(ScopedSharedBufferHandle handle, |
73 base::SharedMemoryHandle* memory_handle, | 70 base::SharedMemoryHandle* memory_handle, |
74 size_t* size, | 71 size_t* size, |
75 bool* read_only); | 72 bool* read_only); |
76 | 73 |
77 } // namespace mojo | 74 } // namespace mojo |
78 | 75 |
79 #endif // MOJO_PUBLIC_CPP_SYSTEM_PLATFORM_HANDLE_H_ | 76 #endif // MOJO_PUBLIC_CPP_SYSTEM_PLATFORM_HANDLE_H_ |
OLD | NEW |