1 // Copyright 2017 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_TIME_MOJOM_TRAITS_H_ 6 #define MOJO_PUBLIC_CPP_BASE_TIME_MOJOM_TRAITS_H_ 7 8 #include "base/component_export.h" 9 #include "base/time/time.h" 10 #include "mojo/public/mojom/base/time.mojom-shared.h" 11 12 namespace mojo { 13 14 template <> COMPONENT_EXPORT(MOJO_BASE_SHARED_TRAITS)15struct COMPONENT_EXPORT(MOJO_BASE_SHARED_TRAITS) 16 StructTraits<mojo_base::mojom::TimeDataView, base::Time> { 17 static int64_t internal_value(const base::Time& time); 18 19 static bool Read(mojo_base::mojom::TimeDataView data, base::Time* time); 20 }; 21 22 template <> COMPONENT_EXPORT(MOJO_BASE_SHARED_TRAITS)23struct COMPONENT_EXPORT(MOJO_BASE_SHARED_TRAITS) 24 StructTraits<mojo_base::mojom::TimeDeltaDataView, base::TimeDelta> { 25 static int64_t microseconds(const base::TimeDelta& delta); 26 27 static bool Read(mojo_base::mojom::TimeDeltaDataView data, 28 base::TimeDelta* delta); 29 }; 30 31 template <> COMPONENT_EXPORT(MOJO_BASE_SHARED_TRAITS)32struct COMPONENT_EXPORT(MOJO_BASE_SHARED_TRAITS) 33 StructTraits<mojo_base::mojom::TimeTicksDataView, base::TimeTicks> { 34 static int64_t internal_value(const base::TimeTicks& time); 35 36 static bool Read(mojo_base::mojom::TimeTicksDataView data, 37 base::TimeTicks* time); 38 }; 39 40 } // namespace mojo 41 42 #endif // MOJO_PUBLIC_CPP_BASE_TIME_MOJOM_TRAITS_H_ 43