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

Side by Side 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, 6 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 unified diff | Download patch
« no previous file with comments | « device/device_sensors/type_converters.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "device/device_sensors/type_converters.h"
6
7 namespace mojo {
8
9 base::SharedMemoryHandle
10 TypeConverter<base::SharedMemoryHandle, device::SharedMemoryPtr>::Convert(
11 const device::SharedMemoryPtr& mojo_mem_ptr) {
12 base::SharedMemoryHandle handle;
13 #if defined(OS_WIN)
14 handle = mojo_mem_ptr->mem_handle;
15 #elif defined(OS_POSIX)
16 handle = base::FileDescriptor(mojo_mem_ptr->fd, true);
17 #else
18 #error Not implemented.
19 #endif
20 return handle;
21 }
22
23 device::SharedMemoryPtr
24 TypeConverter<device::SharedMemoryPtr, base::SharedMemoryHandle>::Convert(
25 const base::SharedMemoryHandle& handle) {
26 device::SharedMemoryPtr result = device::SharedMemory::New();
27 #if defined(OS_WIN)
28 result->mem_handle = handle;
29 #elif defined(OS_POSIX)
30 result->fd = handle.fd;
31 if (handle.auto_close) {
32 // Close fd for current process.
33 base::ScopedFD file(handle.fd);
34 }
35 #else
36 #error Not implemented.
37 #endif
38 return result.Pass();
39 }
40
41 } // namespace mojo
OLDNEW
« 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