| Index: mojo/common/common_custom_types_struct_traits_posix.cc
|
| diff --git a/mojo/common/common_custom_types_struct_traits_posix.cc b/mojo/common/common_custom_types_struct_traits_posix.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..3319a5064952a2b69c4742e706d3a226be209c5f
|
| --- /dev/null
|
| +++ b/mojo/common/common_custom_types_struct_traits_posix.cc
|
| @@ -0,0 +1,30 @@
|
| +// Copyright 2016 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 "mojo/common/common_custom_types_struct_traits_posix.h"
|
| +
|
| +#include "mojo/public/cpp/system/platform_handle.h"
|
| +
|
| +namespace mojo {
|
| +
|
| +mojo::ScopedHandle
|
| +StructTraits<common::mojom::FileDescriptorDataView,
|
| + base::ScopedFD>::wrapped_handle(base::ScopedFD& fd) {
|
| + DCHECK(fd.is_valid());
|
| + return mojo::WrapPlatformFile(fd.release());
|
| +}
|
| +
|
| +bool StructTraits<common::mojom::FileDescriptorDataView, base::ScopedFD>::Read(
|
| + common::mojom::FileDescriptorDataView data,
|
| + base::ScopedFD* fd) {
|
| + base::PlatformFile platform_handle = base::kInvalidPlatformFile;
|
| + if (mojo::UnwrapPlatformFile(data.TakeWrappedHandle(), &platform_handle) !=
|
| + MOJO_RESULT_OK) {
|
| + return false;
|
| + }
|
| + *fd = base::ScopedFD(platform_handle);
|
| + return true;
|
| +}
|
| +
|
| +} // namespace mojo
|
|
|