| OLD | NEW |
| 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 namespace mojo { | 7 namespace mojo { |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 MojoResult UnwrapPlatformFile(ScopedHandle handle, base::PlatformFile* file) { | 42 MojoResult UnwrapPlatformFile(ScopedHandle handle, base::PlatformFile* file) { |
| 43 MojoPlatformHandle platform_handle; | 43 MojoPlatformHandle platform_handle; |
| 44 platform_handle.struct_size = sizeof(MojoPlatformHandle); | 44 platform_handle.struct_size = sizeof(MojoPlatformHandle); |
| 45 MojoResult result = MojoUnwrapPlatformHandle(handle.release().value(), | 45 MojoResult result = MojoUnwrapPlatformHandle(handle.release().value(), |
| 46 &platform_handle); | 46 &platform_handle); |
| 47 if (result != MOJO_RESULT_OK) | 47 if (result != MOJO_RESULT_OK) |
| 48 return result; | 48 return result; |
| 49 | 49 |
| 50 if (platform_handle.type == MOJO_PLATFORM_HANDLE_TYPE_INVALID) { | 50 if (platform_handle.type == MOJO_PLATFORM_HANDLE_TYPE_INVALID) { |
| 51 *file = kInvalidPlatformFile; | 51 *file = base::kInvalidPlatformFile; |
| 52 } else { | 52 } else { |
| 53 CHECK_EQ(platform_handle.type, kPlatformFileHandleType); | 53 CHECK_EQ(platform_handle.type, kPlatformFileHandleType); |
| 54 *file = PlatformFileFromPlatformHandleValue(platform_handle.value); | 54 *file = PlatformFileFromPlatformHandleValue(platform_handle.value); |
| 55 } | 55 } |
| 56 | 56 |
| 57 return MOJO_RESULT_OK; | 57 return MOJO_RESULT_OK; |
| 58 } | 58 } |
| 59 | 59 |
| 60 ScopedSharedBufferHandle WrapSharedMemoryHandle( | 60 ScopedSharedBufferHandle WrapSharedMemoryHandle( |
| 61 const base::SharedMemoryHandle& memory_handle, | 61 const base::SharedMemoryHandle& memory_handle, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE); | 120 CHECK_EQ(platform_handle.type, MOJO_PLATFORM_HANDLE_TYPE_WINDOWS_HANDLE); |
| 121 *memory_handle = base::SharedMemoryHandle( | 121 *memory_handle = base::SharedMemoryHandle( |
| 122 reinterpret_cast<HANDLE>(platform_handle.value), | 122 reinterpret_cast<HANDLE>(platform_handle.value), |
| 123 base::GetCurrentProcId()); | 123 base::GetCurrentProcId()); |
| 124 #endif | 124 #endif |
| 125 | 125 |
| 126 return MOJO_RESULT_OK; | 126 return MOJO_RESULT_OK; |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace mojo | 129 } // namespace mojo |
| OLD | NEW |