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

Side by Side Diff: mojo/public/cpp/system/platform_handle.h

Issue 1995753002: [mojo-edk] Expose portable API for platform handle wrapping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
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.
7 //
8 // Please see "mojo/public/c/system/platform_handle.h" for complete
9 // documentation of the API.
10
11 #ifndef MOJO_PUBLIC_CPP_SYSTEM_PLATFORM_HANDLE_H_
12 #define MOJO_PUBLIC_CPP_SYSTEM_PLATFORM_HANDLE_H_
13
14 #include <stdint.h>
15
16 #include "base/compiler_specific.h"
17 #include "base/files/file.h"
18 #include "base/logging.h"
19 #include "base/macros.h"
20 #include "base/memory/shared_memory_handle.h"
21 #include "base/process/process_handle.h"
22 #include "mojo/public/c/system/platform_handle.h"
23 #include "mojo/public/cpp/system/buffer.h"
24 #include "mojo/public/cpp/system/handle.h"
25
26 #if defined(OS_WIN)
27 #include <windows.h>
28 #endif
29
30 namespace mojo {
31
32 #if defined(OS_POSIX)
33
34 const MojoPlatformHandleType kPlatformFileHandleType =
35 MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR;
36 const base::PlatformFile kInvalidPlatformFile = -1;
Anand Mistry (off Chromium) 2016/05/24 00:36:45 not in scope, so no action necessary. kInvalidPlat
Ken Rockot(use gerrit already) 2016/05/24 00:53:38 Yep, noticed that too. I'll try to post a patch la
37
38 #if defined(OS_MACOSX) && !defined(OS_IOS)
39 const MojoPlatformHandleType kPlatformSharedBufferHandleType =
40 MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT;
41 #else
42 const MojoPlatformHandleType kPlatformSharedBufferHandleType =
43 MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR;
44 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
45
46 #elif defined(OS_WIN)
47 const MojoPlatformHandleType kPlatformFileHandleType =
48 MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE;
49 const base::PlatformFile kInvalidPlatformFile = INVALID_HANDLE_VALUE;
50
51 const MojoPlatformHandleType kPlatformSharedBufferHandleType =
52 MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE;
53 #endif // defined(OS_POSIX)
54
55 // Wraps a PlatformFile as a Mojo handle. Takes ownership of the file object.
56 ScopedHandle WrapPlatformFile(base::PlatformFile platform_file);
57
58 // Unwraps a PlatformFile from a Mojo handle.
59 MojoResult UnwrapPlatformFile(ScopedHandle handle, base::PlatformFile* file);
60
61 // Wraps a base::SharedMemoryHandle as a Mojo handle. Takes ownership of the
62 // SharedMemoryHandle. Note that |read_only| is only an indicator of whether
63 // |memory_handle| only supports read-only mapping. It does NOT have any
64 // influence on the access control of the shared buffer object.
65 ScopedSharedBufferHandle WrapSharedMemoryHandle(
66 const base::SharedMemoryHandle& memory_handle,
67 size_t size,
68 bool read_only);
69
70 // Unwraps a base::SharedMemoryHandle from a Mojo handle. The caller assumes
71 // responsibility for the lifetime of the SharedMemoryHandle.
72 MojoResult UnwrapSharedMemoryHandle(ScopedSharedBufferHandle handle,
73 base::SharedMemoryHandle* memory_handle,
74 size_t* size,
75 bool* read_only);
76
77 } // namespace mojo
78
79 #endif // MOJO_PUBLIC_CPP_SYSTEM_PLATFORM_HANDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698