• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef MOJO_PUBLIC_CPP_BASE_FILE_MOJOM_TRAITS_H_
6 #define MOJO_PUBLIC_CPP_BASE_FILE_MOJOM_TRAITS_H_
7 
8 #include "base/component_export.h"
9 #include "base/files/file.h"
10 #include "mojo/public/mojom/base/file.mojom-shared.h"
11 
12 namespace mojo {
13 
14 template <>
COMPONENT_EXPORT(MOJO_BASE_MOJOM)15 struct COMPONENT_EXPORT(MOJO_BASE_MOJOM)
16     StructTraits<mojo_base::mojom::FileDataView, base::File> {
17   static bool IsNull(const base::File& file) { return !file.IsValid(); }
18 
19   static void SetToNull(base::File* file) { *file = base::File(); }
20 
21   static mojo::ScopedHandle fd(base::File& file);
22   static bool async(base::File& file) { return file.async(); }
23   static bool Read(mojo_base::mojom::FileDataView data, base::File* file);
24 };
25 
26 }  // namespace mojo
27 
28 #endif  // MOJO_PUBLIC_CPP_BASE_FILE_MOJOM_TRAITS_H_
29