Chromium Code Reviews| Index: mojo/common/common_custom_types_struct_traits.cc |
| diff --git a/mojo/common/common_custom_types_struct_traits.cc b/mojo/common/common_custom_types_struct_traits.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2bb7a6eb5e29b50502591b0c6ba6a2c0d9607cb1 |
| --- /dev/null |
| +++ b/mojo/common/common_custom_types_struct_traits.cc |
| @@ -0,0 +1,32 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "mojo/common/common_custom_types_struct_traits.h" |
| + |
| +#include <iterator> |
| + |
| +#include "base/version.h" |
| + |
| +namespace mojo { |
| + |
| +// static |
| +const std::vector<uint32_t>& |
| +StructTraits<mojo::common::mojom::Version, base::Version>::components( |
| + const base::Version& version) { |
| + return version.components(); |
|
dcheng
2016/07/28 02:09:39
Assuming this isn't doing any implicit conversions
Alex Z.
2016/07/28 19:40:44
Done.
|
| +} |
| + |
| +// static |
| +bool StructTraits<mojo::common::mojom::Version, base::Version>::Read( |
| + mojo::common::mojom::VersionDataView data, |
| + base::Version* out) { |
| + std::vector<uint32_t> components; |
| + if (!data.ReadComponents(&components)) |
| + return false; |
| + |
| + *out = base::Version(base::Version(std::move(components))); |
| + return out->IsValid(); |
| +} |
| + |
| +} // namespace mojo |