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
3 // found in the LICENSE file.
5 #include "mojo/platform_handle/platform_handle.h"
6 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h"
10 MojoResult
MojoCreatePlatformHandleWrapper(MojoPlatformHandle platform_handle
,
11 MojoHandle
* wrapper
) {
12 mojo::embedder::PlatformHandle
platform_handle_wrapper(platform_handle
);
13 mojo::embedder::ScopedPlatformHandle
scoped_platform_handle(
14 platform_handle_wrapper
);
15 return mojo::embedder::CreatePlatformHandleWrapper(
16 scoped_platform_handle
.Pass(), wrapper
);
19 MojoResult
MojoExtractPlatformHandle(MojoHandle wrapper
,
20 MojoPlatformHandle
* platform_handle
) {
21 mojo::embedder::ScopedPlatformHandle scoped_platform_handle
;
22 MojoResult result
= mojo::embedder::PassWrappedPlatformHandle(
23 wrapper
, &scoped_platform_handle
);
24 if (result
!= MOJO_RESULT_OK
)
27 DCHECK(scoped_platform_handle
.is_valid());
29 *platform_handle
= scoped_platform_handle
.release().fd
;
31 *platform_handle
= scoped_platform_handle
.release().handle
;
33 #error "Platform not yet supported."
35 return MOJO_RESULT_OK
;