Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(557)

Side by Side Diff: mojo/common/common_custom_types_struct_traits.cc

Issue 2147693002: Struct traits used by GpuInfo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed according to comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 #include "mojo/common/common_custom_types_struct_traits.h"
6
7 #include <iterator>
8
9 #include "base/version.h"
10
11 namespace mojo {
12
13 namespace {
14
15 std::string ConstructVersionString(const std::vector<uint32_t>& components) {
Fady Samuel 2016/07/19 17:33:03 I just looked at base::Version's constructor. It s
Alex Z. 2016/07/26 14:38:55 Done.
16 std::stringstream version_stream;
17 for (size_t i = 0; i < components.size(); i++) {
18 if (i != 0)
19 version_stream << ".";
20
21 version_stream << components[i];
22 }
23 return version_stream.str();
24 }
25
26 } // namespace
27
28 // static
29 const std::vector<uint32_t>&
30 StructTraits<mojo::common::mojom::Version, base::Version>::components(
31 const base::Version& version) {
32 return version.components();
33 }
34
35 // static
36 bool StructTraits<mojo::common::mojom::Version, base::Version>::Read(
37 mojo::common::mojom::VersionDataView data,
38 base::Version* out) {
39 std::vector<uint32_t> components;
40 if (!data.ReadComponents(&components))
41 return false;
42
43 *out = base::Version(ConstructVersionString(components));
44 return out->IsValid();
45 }
46
47 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/common/common_custom_types_struct_traits.h ('k') | mojo/common/common_custom_types_struct_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698