| Index: device/device_sensors/type_converters.cc
|
| diff --git a/device/device_sensors/type_converters.cc b/device/device_sensors/type_converters.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..da97424cf7be2428a428c0ba09e4298fe0f15c07
|
| --- /dev/null
|
| +++ b/device/device_sensors/type_converters.cc
|
| @@ -0,0 +1,41 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "device/device_sensors/type_converters.h"
|
| +
|
| +namespace mojo {
|
| +
|
| +base::SharedMemoryHandle
|
| +TypeConverter<base::SharedMemoryHandle, device::SharedMemoryPtr>::Convert(
|
| + const device::SharedMemoryPtr& mojo_mem_ptr) {
|
| + base::SharedMemoryHandle handle;
|
| +#if defined(OS_WIN)
|
| + handle = mojo_mem_ptr->mem_handle;
|
| +#elif defined(OS_POSIX)
|
| + handle = base::FileDescriptor(mojo_mem_ptr->fd, true);
|
| +#else
|
| +#error Not implemented.
|
| +#endif
|
| + return handle;
|
| +}
|
| +
|
| +device::SharedMemoryPtr
|
| +TypeConverter<device::SharedMemoryPtr, base::SharedMemoryHandle>::Convert(
|
| + const base::SharedMemoryHandle& handle) {
|
| + device::SharedMemoryPtr result = device::SharedMemory::New();
|
| +#if defined(OS_WIN)
|
| + result->mem_handle = handle;
|
| +#elif defined(OS_POSIX)
|
| + result->fd = handle.fd;
|
| + if (handle.auto_close) {
|
| + // Close fd for current process.
|
| + base::ScopedFD file(handle.fd);
|
| + }
|
| +#else
|
| +#error Not implemented.
|
| +#endif
|
| + return result.Pass();
|
| +}
|
| +
|
| +} // namespace mojo
|
|
|