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

Unified Diff: mojo/common/common_custom_types_struct_traits_win.cc

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
« no previous file with comments | « mojo/common/common_custom_types_struct_traits_win.h ('k') | mojo/common/common_custom_types_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/common/common_custom_types_struct_traits_win.cc
diff --git a/mojo/common/common_custom_types_struct_traits_win.cc b/mojo/common/common_custom_types_struct_traits_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3e6808f9574f1bea8a0072e8920fc4119725ddf4
--- /dev/null
+++ b/mojo/common/common_custom_types_struct_traits_win.cc
@@ -0,0 +1,31 @@
+// 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_win.h"
+
+#include "mojo/public/cpp/system/platform_handle.h"
+
+namespace mojo {
+
+mojo::ScopedHandle StructTraits<
+ common::mojom::WindowsHandleDataView,
+ base::win::ScopedHandle>::wrapped_handle(base::win::ScopedHandle& handle) {
+ DCHECK(handle.IsValid());
+ return mojo::WrapPlatformFile(handle.Take());
+}
+
+bool StructTraits<
+ common::mojom::WindowsHandleDataView,
+ base::win::ScopedHandle>::Read(common::mojom::WindowsHandleDataView data,
+ base::win::ScopedHandle* handle) {
+ base::PlatformFile platform_handle = base::kInvalidPlatformFile;
+ if (mojo::UnwrapPlatformFile(data.TakeWrappedHandle(), &platform_handle) !=
+ MOJO_RESULT_OK) {
+ return false;
+ }
+ *handle = base::win::ScopedHandle(platform_handle);
+ return true;
+}
+
+} // namespace mojo
« no previous file with comments | « mojo/common/common_custom_types_struct_traits_win.h ('k') | mojo/common/common_custom_types_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698