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

Unified Diff: mojo/common/common_custom_types_struct_traits_posix.h

Issue 2561003002: Add mojo structs for ScopedFD and ScopedHandle. (Closed)
Patch Set: Created 4 years 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
Index: mojo/common/common_custom_types_struct_traits_posix.h
diff --git a/mojo/common/common_custom_types_struct_traits_posix.h b/mojo/common/common_custom_types_struct_traits_posix.h
new file mode 100644
index 0000000000000000000000000000000000000000..ac7d95230d57e981df8607a9794f10d781d00349
--- /dev/null
+++ b/mojo/common/common_custom_types_struct_traits_posix.h
@@ -0,0 +1,27 @@
+// 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.
+
+#ifndef MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_POSIX_H_
+#define MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_POSIX_H_
+
+#include "base/files/scoped_file.h"
+#include "mojo/common/mojo_common_export.h"
+#include "mojo/common/platform_handle.mojom-shared.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<common::mojom::FileDescriptorDataView, base::ScopedFD> {
+ static bool IsNull(const base::ScopedFD& fd) { return !fd.is_valid(); }
+
+ static void SetToNull(base::ScopedFD* fd) { *fd = base::ScopedFD(); }
+
+ static mojo::ScopedHandle wrapped_handle(base::ScopedFD& fd);
+ static bool Read(common::mojom::FileDescriptorDataView data,
+ base::ScopedFD* fd);
+};
+
+} // namespace mojo
+
+#endif // MOJO_COMMON_COMMON_CUSTOM_TYPES_STRUCT_TRAITS_POSIX_H_
« no previous file with comments | « mojo/common/common_custom_types_struct_traits.h ('k') | mojo/common/common_custom_types_struct_traits_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698