blob: f5cc246dfc2dd56b2e4088f8a60ff8bfc886d763 [file] [log] [blame]
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "mojo/public/cpp/base/file_mojom_traits.h"
#include "base/files/file.h"
namespace mojo {
mojo::PlatformHandle
StructTraits<mojo_base::mojom::FileDataView, base::File>::fd(base::File& file) {
DCHECK(file.IsValid());
return mojo::PlatformHandle(
base::ScopedPlatformFile(file.TakePlatformFile()));
}
bool StructTraits<mojo_base::mojom::FileDataView, base::File>::Read(
mojo_base::mojom::FileDataView data,
base::File* file) {
*file = base::File(data.TakeFd().TakePlatformFile(), data.async());
return true;
}
} // namespace mojo