Home | History | Annotate | Download | only in base
      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_INFO_MOJOM_TRAITS_H_
      6 #define MOJO_PUBLIC_CPP_BASE_FILE_INFO_MOJOM_TRAITS_H_
      7 
      8 #include <cstdint>
      9 
     10 #include "base/component_export.h"
     11 #include "base/files/file.h"
     12 #include "base/macros.h"
     13 #include "mojo/public/cpp/bindings/struct_traits.h"
     14 #include "mojo/public/mojom/base/file_info.mojom-shared.h"
     15 
     16 namespace mojo {
     17 
     18 template <>
     19 struct COMPONENT_EXPORT(MOJO_BASE_SHARED_TRAITS)
     20     StructTraits<mojo_base::mojom::FileInfoDataView, base::File::Info> {
     21   static int64_t size(const base::File::Info& info) { return info.size; }
     22 
     23   static bool is_directory(const base::File::Info& info) {
     24     return info.is_directory;
     25   }
     26 
     27   static bool is_symbolic_link(const base::File::Info& info) {
     28     return info.is_symbolic_link;
     29   }
     30 
     31   static base::Time last_modified(const base::File::Info& info) {
     32     return info.last_modified;
     33   }
     34 
     35   static base::Time last_accessed(const base::File::Info& info) {
     36     return info.last_accessed;
     37   }
     38 
     39   static base::Time creation_time(const base::File::Info& info) {
     40     return info.creation_time;
     41   }
     42 
     43   static bool Read(mojo_base::mojom::FileInfoDataView data,
     44                    base::File::Info* out);
     45 };
     46 
     47 }  // namespace mojo
     48 
     49 #endif  // MOJO_PUBLIC_CPP_BASE_FILE_INFO_MOJOM_TRAITS_H_
     50