Commit 8dd26d24 authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

Convert mojo/public/mojom/base/file.mojom to handle<platform>

Bug: 710376
Change-Id: I0c28c2cfbc6a034bbe41d68b6b1e021408365ff7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2062339Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742678}
parent 216eb5de
...@@ -4,26 +4,21 @@ ...@@ -4,26 +4,21 @@
#include "mojo/public/cpp/base/file_mojom_traits.h" #include "mojo/public/cpp/base/file_mojom_traits.h"
#include "base/files/file.h" #include "base/files/file.h"
#include "mojo/public/cpp/system/platform_handle.h"
namespace mojo { namespace mojo {
mojo::ScopedHandle StructTraits<mojo_base::mojom::FileDataView, base::File>::fd( mojo::PlatformHandle
base::File& file) { StructTraits<mojo_base::mojom::FileDataView, base::File>::fd(base::File& file) {
DCHECK(file.IsValid()); DCHECK(file.IsValid());
return mojo::WrapPlatformFile(file.TakePlatformFile()); return mojo::PlatformHandle(
base::ScopedPlatformFile(file.TakePlatformFile()));
} }
bool StructTraits<mojo_base::mojom::FileDataView, base::File>::Read( bool StructTraits<mojo_base::mojom::FileDataView, base::File>::Read(
mojo_base::mojom::FileDataView data, mojo_base::mojom::FileDataView data,
base::File* file) { base::File* file) {
base::PlatformFile platform_handle = base::kInvalidPlatformFile; *file = base::File(data.TakeFd().TakePlatformFile(), data.async());
if (mojo::UnwrapPlatformFile(data.TakeFd(), &platform_handle) !=
MOJO_RESULT_OK) {
return false;
}
*file = base::File(platform_handle, data.async());
return true; return true;
} }
......
...@@ -18,7 +18,7 @@ struct COMPONENT_EXPORT(MOJO_BASE_SHARED_TRAITS) ...@@ -18,7 +18,7 @@ struct COMPONENT_EXPORT(MOJO_BASE_SHARED_TRAITS)
static void SetToNull(base::File* file) { *file = base::File(); } static void SetToNull(base::File* file) { *file = base::File(); }
static mojo::ScopedHandle fd(base::File& file); static mojo::PlatformHandle fd(base::File& file);
static bool async(base::File& file) { return file.async(); } static bool async(base::File& file) { return file.async(); }
static bool Read(mojo_base::mojom::FileDataView data, base::File* file); static bool Read(mojo_base::mojom::FileDataView data, base::File* file);
}; };
......
...@@ -6,6 +6,6 @@ module mojo_base.mojom; ...@@ -6,6 +6,6 @@ module mojo_base.mojom;
// Corresponds to |base::File| in base/files/file.h // Corresponds to |base::File| in base/files/file.h
struct File { struct File {
handle fd; handle<platform> fd;
bool async; bool async;
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment