| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/platform_handle/platform_handle.h" | 5 #include "mojo/platform_handle/platform_handle.h" |
| 6 |
| 7 #if defined(USE_CHROME_EDK) |
| 8 #include "mojo/edk/embedder/embedder.h" |
| 9 #else |
| 6 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | 10 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" |
| 11 #endif |
| 7 | 12 |
| 8 extern "C" { | 13 extern "C" { |
| 9 | 14 |
| 10 MojoResult MojoCreatePlatformHandleWrapper(MojoPlatformHandle platform_handle, | 15 MojoResult MojoCreatePlatformHandleWrapper(MojoPlatformHandle platform_handle, |
| 11 MojoHandle* wrapper) { | 16 MojoHandle* wrapper) { |
| 17 #if defined(USE_CHROME_EDK) |
| 18 mojo::edk::PlatformHandle platform_handle_wrapper(platform_handle); |
| 19 mojo::edk::ScopedPlatformHandle scoped_platform_handle( |
| 20 platform_handle_wrapper); |
| 21 return mojo::edk::CreatePlatformHandleWrapper( |
| 22 scoped_platform_handle.Pass(), wrapper); |
| 23 #else |
| 12 mojo::embedder::PlatformHandle platform_handle_wrapper(platform_handle); | 24 mojo::embedder::PlatformHandle platform_handle_wrapper(platform_handle); |
| 13 mojo::embedder::ScopedPlatformHandle scoped_platform_handle( | 25 mojo::embedder::ScopedPlatformHandle scoped_platform_handle( |
| 14 platform_handle_wrapper); | 26 platform_handle_wrapper); |
| 15 return mojo::embedder::CreatePlatformHandleWrapper( | 27 return mojo::embedder::CreatePlatformHandleWrapper( |
| 16 scoped_platform_handle.Pass(), wrapper); | 28 scoped_platform_handle.Pass(), wrapper); |
| 29 #endif |
| 17 } | 30 } |
| 18 | 31 |
| 19 MojoResult MojoExtractPlatformHandle(MojoHandle wrapper, | 32 MojoResult MojoExtractPlatformHandle(MojoHandle wrapper, |
| 20 MojoPlatformHandle* platform_handle) { | 33 MojoPlatformHandle* platform_handle) { |
| 34 #if defined(USE_CHROME_EDK) |
| 35 mojo::edk::ScopedPlatformHandle scoped_platform_handle; |
| 36 MojoResult result = mojo::edk::PassWrappedPlatformHandle( |
| 37 wrapper, &scoped_platform_handle); |
| 38 #else |
| 21 mojo::embedder::ScopedPlatformHandle scoped_platform_handle; | 39 mojo::embedder::ScopedPlatformHandle scoped_platform_handle; |
| 22 MojoResult result = mojo::embedder::PassWrappedPlatformHandle( | 40 MojoResult result = mojo::embedder::PassWrappedPlatformHandle( |
| 23 wrapper, &scoped_platform_handle); | 41 wrapper, &scoped_platform_handle); |
| 42 #endif |
| 24 if (result != MOJO_RESULT_OK) | 43 if (result != MOJO_RESULT_OK) |
| 25 return result; | 44 return result; |
| 26 | 45 |
| 27 DCHECK(scoped_platform_handle.is_valid()); | 46 DCHECK(scoped_platform_handle.is_valid()); |
| 28 #if defined(OS_POSIX) | 47 #if defined(OS_POSIX) |
| 29 *platform_handle = scoped_platform_handle.release().fd; | 48 *platform_handle = scoped_platform_handle.release().fd; |
| 30 #elif defined(OS_WIN) | 49 #elif defined(OS_WIN) |
| 31 *platform_handle = scoped_platform_handle.release().handle; | 50 *platform_handle = scoped_platform_handle.release().handle; |
| 32 #else | 51 #else |
| 33 #error "Platform not yet supported." | 52 #error "Platform not yet supported." |
| 34 #endif | 53 #endif |
| 35 return MOJO_RESULT_OK; | 54 return MOJO_RESULT_OK; |
| 36 } | 55 } |
| 37 | 56 |
| 38 } // extern "C" | 57 } // extern "C" |
| OLD | NEW |