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

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

Issue 2875453002: Add a size parameter to SharedMemoryHandle. (Closed)
Patch Set: Remove extraneous period. 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // TODO(rockot): Pass GUIDs through Mojo. https://crbug.com/713763. 117 // TODO(rockot): Pass GUIDs through Mojo. https://crbug.com/713763.
118 base::UnguessableToken guid = base::UnguessableToken::Create(); 118 base::UnguessableToken guid = base::UnguessableToken::Create();
119 #if defined(OS_MACOSX) && !defined(OS_IOS) 119 #if defined(OS_MACOSX) && !defined(OS_IOS)
120 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT); 120 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT);
121 *memory_handle = base::SharedMemoryHandle( 121 *memory_handle = base::SharedMemoryHandle(
122 static_cast<mach_port_t>(platform_handle.value), num_bytes, guid); 122 static_cast<mach_port_t>(platform_handle.value), num_bytes, guid);
123 #elif defined(OS_POSIX) 123 #elif defined(OS_POSIX)
124 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR); 124 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR);
125 *memory_handle = base::SharedMemoryHandle( 125 *memory_handle = base::SharedMemoryHandle(
126 base::FileDescriptor(static_cast<int>(platform_handle.value), false), 126 base::FileDescriptor(static_cast<int>(platform_handle.value), false),
127 guid); 127 num_bytes, guid);
128 #elif defined(OS_WIN) 128 #elif defined(OS_WIN)
129 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE); 129 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE);
130 *memory_handle = base::SharedMemoryHandle( 130 *memory_handle = base::SharedMemoryHandle(
131 reinterpret_cast<HANDLE>(platform_handle.value), guid); 131 reinterpret_cast<HANDLE>(platform_handle.value), num_bytes, guid);
132 #endif 132 #endif
133 133
134 return MOJO_RESULT_OK; 134 return MOJO_RESULT_OK;
135 } 135 }
136 136
137 #if defined(OS_MACOSX) && !defined(OS_IOS) 137 #if defined(OS_MACOSX) && !defined(OS_IOS)
138 ScopedHandle WrapMachPort(mach_port_t port) { 138 ScopedHandle WrapMachPort(mach_port_t port) {
139 kern_return_t kr = 139 kern_return_t kr =
140 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);
141 MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr) 141 MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr)
(...skipping 21 matching lines...) Expand all
163 if (result != MOJO_RESULT_OK) 163 if (result != MOJO_RESULT_OK)
164 return result; 164 return result;
165 165
166 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT); 166 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT);
167 *port = static_cast<mach_port_t>(platform_handle.value); 167 *port = static_cast<mach_port_t>(platform_handle.value);
168 return MOJO_RESULT_OK; 168 return MOJO_RESULT_OK;
169 } 169 }
170 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 170 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
171 171
172 } // 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