Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(674)

Unified Diff: device/device_sensors/type_converters.cc

Issue 1164563003: Extract device_sensors to /device via Mojofication (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/device_sensors/type_converters.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « device/device_sensors/type_converters.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698