| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/edk/embedder/embedder.h" | 5 #include "mojo/edk/embedder/embedder.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(sb1)); | 421 EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoClose(sb1)); |
| 422 } | 422 } |
| 423 | 423 |
| 424 #if defined(OS_MACOSX) && !defined(OS_IOS) | 424 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 425 TEST_F(EmbedderTest, MultiprocessMachSharedMemory) { | 425 TEST_F(EmbedderTest, MultiprocessMachSharedMemory) { |
| 426 RUN_CHILD_ON_PIPE(MultiprocessSharedMemoryClient, server_mp) | 426 RUN_CHILD_ON_PIPE(MultiprocessSharedMemoryClient, server_mp) |
| 427 // 1. Create a Mach base::SharedMemory object and create a mojo shared | 427 // 1. Create a Mach base::SharedMemory object and create a mojo shared |
| 428 // buffer from it. | 428 // buffer from it. |
| 429 base::SharedMemoryCreateOptions options; | 429 base::SharedMemoryCreateOptions options; |
| 430 options.size = 123; | 430 options.size = 123; |
| 431 options.type = base::SharedMemoryHandle::MACH; |
| 431 base::SharedMemory shared_memory; | 432 base::SharedMemory shared_memory; |
| 432 ASSERT_TRUE(shared_memory.Create(options)); | 433 ASSERT_TRUE(shared_memory.Create(options)); |
| 433 base::SharedMemoryHandle shm_handle = base::SharedMemory::DuplicateHandle( | 434 base::SharedMemoryHandle shm_handle = base::SharedMemory::DuplicateHandle( |
| 434 shared_memory.handle()); | 435 shared_memory.handle()); |
| 435 MojoHandle sb1; | 436 MojoHandle sb1; |
| 436 ASSERT_EQ(MOJO_RESULT_OK, | 437 ASSERT_EQ(MOJO_RESULT_OK, |
| 437 CreateSharedBufferWrapper(shm_handle, 123, false, &sb1)); | 438 CreateSharedBufferWrapper(shm_handle, 123, false, &sb1)); |
| 438 | 439 |
| 439 // 2. Map |sb1| and write something into it. | 440 // 2. Map |sb1| and write something into it. |
| 440 char* buffer = nullptr; | 441 char* buffer = nullptr; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 ASSERT_TRUE(file.IsValid()); | 496 ASSERT_TRUE(file.IsValid()); |
| 496 scoped_handle.reset(PlatformHandle(file.TakePlatformFile())); | 497 scoped_handle.reset(PlatformHandle(file.TakePlatformFile())); |
| 497 EXPECT_EQ(PlatformHandle::Type::POSIX, scoped_handle.get().type); | 498 EXPECT_EQ(PlatformHandle::Type::POSIX, scoped_handle.get().type); |
| 498 } else if (type == HandleType::MACH_NULL) { | 499 } else if (type == HandleType::MACH_NULL) { |
| 499 scoped_handle.reset(PlatformHandle( | 500 scoped_handle.reset(PlatformHandle( |
| 500 static_cast<mach_port_t>(MACH_PORT_NULL))); | 501 static_cast<mach_port_t>(MACH_PORT_NULL))); |
| 501 EXPECT_EQ(PlatformHandle::Type::MACH, scoped_handle.get().type); | 502 EXPECT_EQ(PlatformHandle::Type::MACH, scoped_handle.get().type); |
| 502 } else { | 503 } else { |
| 503 base::SharedMemoryCreateOptions options; | 504 base::SharedMemoryCreateOptions options; |
| 504 options.size = kShmSize; | 505 options.size = kShmSize; |
| 506 options.type = base::SharedMemoryHandle::MACH; |
| 505 base::SharedMemory shared_memory; | 507 base::SharedMemory shared_memory; |
| 506 ASSERT_TRUE(shared_memory.Create(options)); | 508 ASSERT_TRUE(shared_memory.Create(options)); |
| 507 base::SharedMemoryHandle shm_handle = | 509 base::SharedMemoryHandle shm_handle = |
| 508 base::SharedMemory::DuplicateHandle(shared_memory.handle()); | 510 base::SharedMemory::DuplicateHandle(shared_memory.handle()); |
| 509 scoped_handle.reset(PlatformHandle(shm_handle.GetMemoryObject())); | 511 scoped_handle.reset(PlatformHandle(shm_handle.GetMemoryObject())); |
| 510 EXPECT_EQ(PlatformHandle::Type::MACH, scoped_handle.get().type); | 512 EXPECT_EQ(PlatformHandle::Type::MACH, scoped_handle.get().type); |
| 511 } | 513 } |
| 512 ASSERT_EQ(MOJO_RESULT_OK, CreatePlatformHandleWrapper( | 514 ASSERT_EQ(MOJO_RESULT_OK, CreatePlatformHandleWrapper( |
| 513 std::move(scoped_handle), platform_handles + i)); | 515 std::move(scoped_handle), platform_handles + i)); |
| 514 } | 516 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 client_mp) { | 655 client_mp) { |
| 654 ASSERT_EQ(MOJO_RESULT_OK, MojoWait(client_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED, | 656 ASSERT_EQ(MOJO_RESULT_OK, MojoWait(client_mp, MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
| 655 MOJO_DEADLINE_INDEFINITE, nullptr)); | 657 MOJO_DEADLINE_INDEFINITE, nullptr)); |
| 656 } | 658 } |
| 657 | 659 |
| 658 #endif // !defined(OS_IOS) | 660 #endif // !defined(OS_IOS) |
| 659 | 661 |
| 660 } // namespace | 662 } // namespace |
| 661 } // namespace edk | 663 } // namespace edk |
| 662 } // namespace mojo | 664 } // namespace mojo |
| OLD | NEW |