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

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

Issue 2859843002: Add a GUID to base::SharedMemoryHandle. (Closed)
Patch Set: fix guid on android. Created 3 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
« no previous file with comments | « mojo/edk/system/platform_wrapper_unittest.cc ('k') | ppapi/proxy/nacl_message_scanner.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 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 #include "mojo/public/cpp/system/platform_handle.h" 5 #include "mojo/public/cpp/system/platform_handle.h"
6 6
7 #if defined(OS_MACOSX) && !defined(OS_IOS) 7 #if defined(OS_MACOSX) && !defined(OS_IOS)
8 #include <mach/mach.h> 8 #include <mach/mach.h>
9 #include "base/mac/mach_logging.h" 9 #include "base/mac/mach_logging.h"
10 #endif 10 #endif
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 handle.release().value(), &platform_handle, &num_bytes, &flags); 107 handle.release().value(), &platform_handle, &num_bytes, &flags);
108 if (result != MOJO_RESULT_OK) 108 if (result != MOJO_RESULT_OK)
109 return result; 109 return result;
110 110
111 if (size) 111 if (size)
112 *size = num_bytes; 112 *size = num_bytes;
113 113
114 if (read_only) 114 if (read_only)
115 *read_only = flags & MOJO_PLATFORM_SHARED_BUFFER_HANDLE_FLAG_READ_ONLY; 115 *read_only = flags & MOJO_PLATFORM_SHARED_BUFFER_HANDLE_FLAG_READ_ONLY;
116 116
117 // TODO(rockot): Pass GUIDs through Mojo. https://crbug.com/713763.
118 base::UnguessableToken guid = base::UnguessableToken::Create();
117 #if defined(OS_MACOSX) && !defined(OS_IOS) 119 #if defined(OS_MACOSX) && !defined(OS_IOS)
118 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT); 120 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT);
119 *memory_handle = base::SharedMemoryHandle( 121 *memory_handle = base::SharedMemoryHandle(
120 static_cast<mach_port_t>(platform_handle.value), num_bytes); 122 static_cast<mach_port_t>(platform_handle.value), num_bytes, guid);
121 #elif defined(OS_POSIX) 123 #elif defined(OS_POSIX)
122 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR); 124 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR);
123 *memory_handle = base::SharedMemoryHandle( 125 *memory_handle = base::SharedMemoryHandle(
124 base::FileDescriptor(static_cast<int>(platform_handle.value), false)); 126 base::FileDescriptor(static_cast<int>(platform_handle.value), false),
127 guid);
125 #elif defined(OS_WIN) 128 #elif defined(OS_WIN)
126 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE); 129 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE);
127 *memory_handle = 130 *memory_handle = base::SharedMemoryHandle(
128 base::SharedMemoryHandle(reinterpret_cast<HANDLE>(platform_handle.value)); 131 reinterpret_cast<HANDLE>(platform_handle.value), guid);
129 #endif 132 #endif
130 133
131 return MOJO_RESULT_OK; 134 return MOJO_RESULT_OK;
132 } 135 }
133 136
134 #if defined(OS_MACOSX) && !defined(OS_IOS) 137 #if defined(OS_MACOSX) && !defined(OS_IOS)
135 ScopedHandle WrapMachPort(mach_port_t port) { 138 ScopedHandle WrapMachPort(mach_port_t port) {
136 kern_return_t kr = 139 kern_return_t kr =
137 mach_port_mod_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND, 1); 140 mach_port_mod_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND, 1);
138 MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr) 141 MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr)
(...skipping 21 matching lines...) Expand all
160 if (result != MOJO_RESULT_OK) 163 if (result != MOJO_RESULT_OK)
161 return result; 164 return result;
162 165
163 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT); 166 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT);
164 *port = static_cast<mach_port_t>(platform_handle.value); 167 *port = static_cast<mach_port_t>(platform_handle.value);
165 return MOJO_RESULT_OK; 168 return MOJO_RESULT_OK;
166 } 169 }
167 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 170 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
168 171
169 } // namespace mojo 172 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/platform_wrapper_unittest.cc ('k') | ppapi/proxy/nacl_message_scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698