blob: 1c1cfea858260ffde20c917996b10515392201eb [file] [log] [blame]
Forrest Reiling74b0cac2016-03-02 16:21:15 -08001// Copyright 2016 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.
4
5// This file contains implementations for the platform handle thunks
6// (see //mojo/public/platform/native/platform_handle_private.h)
7
8#include "base/logging.h"
9#include "mojo/edk/embedder/embedder.h"
10#include "mojo/public/platform/native/platform_handle_private.h"
11
12using mojo::platform::PlatformHandle;
13using mojo::platform::ScopedPlatformHandle;
14
15MojoResult MojoCreatePlatformHandleWrapper(MojoPlatformHandle platform_handle,
16 MojoHandle* wrapper) {
17 PlatformHandle platform_handle_wrapper(platform_handle);
18 ScopedPlatformHandle scoped_platform_handle(platform_handle_wrapper);
19 return mojo::embedder::CreatePlatformHandleWrapper(
20 scoped_platform_handle.Pass(), wrapper);
21}
22
23MojoResult MojoExtractPlatformHandle(MojoHandle wrapper,
24 MojoPlatformHandle* platform_handle) {
25 ScopedPlatformHandle scoped_platform_handle;
26 MojoResult result = mojo::embedder::PassWrappedPlatformHandle(
27 wrapper, &scoped_platform_handle);
28 if (result != MOJO_RESULT_OK)
29 return result;
30
31 DCHECK(scoped_platform_handle.is_valid());
32 *platform_handle = scoped_platform_handle.release().fd;
33 return MOJO_RESULT_OK;
34}