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

Side by Side Diff: mojo/edk/system/platform_wrapper_unittest.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/embedder/platform_shared_buffer.cc ('k') | mojo/public/cpp/system/platform_handle.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 <stdint.h> 5 #include <stdint.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 // TODO(rockot): Pass GUIDs through Mojo. https://crbug.com/713763. 164 // TODO(rockot): Pass GUIDs through Mojo. https://crbug.com/713763.
165 base::UnguessableToken guid = base::UnguessableToken::Create(); 165 base::UnguessableToken guid = base::UnguessableToken::Create();
166 #if defined(OS_MACOSX) && !defined(OS_IOS) 166 #if defined(OS_MACOSX) && !defined(OS_IOS)
167 ASSERT_EQ(MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT, os_buffer.type); 167 ASSERT_EQ(MOJO_PLATFORM_HANDLE_TYPE_MACH_PORT, os_buffer.type);
168 base::SharedMemoryHandle memory_handle( 168 base::SharedMemoryHandle memory_handle(
169 static_cast<mach_port_t>(os_buffer.value), size, guid); 169 static_cast<mach_port_t>(os_buffer.value), size, guid);
170 #elif defined(OS_POSIX) 170 #elif defined(OS_POSIX)
171 ASSERT_EQ(MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR, os_buffer.type); 171 ASSERT_EQ(MOJO_PLATFORM_HANDLE_TYPE_FILE_DESCRIPTOR, os_buffer.type);
172 base::SharedMemoryHandle memory_handle( 172 base::SharedMemoryHandle memory_handle(
173 base::FileDescriptor(static_cast<int>(os_buffer.value), false), guid); 173 base::FileDescriptor(static_cast<int>(os_buffer.value), false), size,
174 guid);
174 #elif defined(OS_WIN) 175 #elif defined(OS_WIN)
175 ASSERT_EQ(MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE, os_buffer.type); 176 ASSERT_EQ(MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE, os_buffer.type);
176 base::SharedMemoryHandle memory_handle( 177 base::SharedMemoryHandle memory_handle(
177 reinterpret_cast<HANDLE>(os_buffer.value), guid); 178 reinterpret_cast<HANDLE>(os_buffer.value), size, guid);
178 #endif 179 #endif
179 180
180 base::SharedMemory memory(memory_handle, read_only); 181 base::SharedMemory memory(memory_handle, read_only);
181 memory.Map(message.size()); 182 memory.Map(message.size());
182 ASSERT_TRUE(memory.memory()); 183 ASSERT_TRUE(memory.memory());
183 184
184 EXPECT_TRUE(std::equal(message.begin(), message.end(), 185 EXPECT_TRUE(std::equal(message.begin(), message.end(),
185 static_cast<const char*>(memory.memory()))); 186 static_cast<const char*>(memory.memory())));
186 } 187 }
187 188
(...skipping 16 matching lines...) Expand all
204 MojoHandle wrapped_handle; 205 MojoHandle wrapped_handle;
205 MojoPlatformHandle platform_handle; 206 MojoPlatformHandle platform_handle;
206 platform_handle.struct_size = 0; 207 platform_handle.struct_size = 0;
207 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, 208 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT,
208 MojoWrapPlatformHandle(&platform_handle, &wrapped_handle)); 209 MojoWrapPlatformHandle(&platform_handle, &wrapped_handle));
209 } 210 }
210 211
211 } // namespace 212 } // namespace
212 } // namespace edk 213 } // namespace edk
213 } // namespace mojo 214 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/embedder/platform_shared_buffer.cc ('k') | mojo/public/cpp/system/platform_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698