OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/common/common_custom_types_struct_traits.h" | 5 #include "mojo/common/common_custom_types_struct_traits.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
9 namespace mojo { | 9 namespace mojo { |
10 | 10 |
11 // static | 11 // static |
12 std::vector<uint16_t> | |
13 StructTraits<mojo::common::mojom::String16DataView, base::string16>::data( | |
14 const base::string16& str) { | |
15 return std::vector<uint16_t>(str.data(), str.data() + str.size()); | |
Ken Rockot(use gerrit already)
2016/10/04 18:20:28
Another reason to add mojo::ConstCArray (see other
Zhiqiang Zhang (Slow)
2016/10/04 20:06:22
Done.
| |
16 } | |
17 | |
18 // static | |
19 bool StructTraits<mojo::common::mojom::String16DataView, base::string16>::Read( | |
20 mojo::common::mojom::String16DataView data, | |
21 base::string16* out) { | |
22 mojo::ArrayDataView<uint16_t> view; | |
23 data.GetDataDataView(&view); | |
24 if (view.is_null()) | |
25 return false; | |
26 out->assign(reinterpret_cast<const base::char16*>(view.data()), view.size()); | |
27 return true; | |
28 } | |
29 | |
30 // static | |
12 const std::vector<uint32_t>& | 31 const std::vector<uint32_t>& |
13 StructTraits<mojo::common::mojom::VersionDataView, base::Version>::components( | 32 StructTraits<mojo::common::mojom::VersionDataView, base::Version>::components( |
14 const base::Version& version) { | 33 const base::Version& version) { |
15 return version.components(); | 34 return version.components(); |
16 } | 35 } |
17 | 36 |
18 // static | 37 // static |
19 bool StructTraits<mojo::common::mojom::VersionDataView, base::Version>::Read( | 38 bool StructTraits<mojo::common::mojom::VersionDataView, base::Version>::Read( |
20 mojo::common::mojom::VersionDataView data, | 39 mojo::common::mojom::VersionDataView data, |
21 base::Version* out) { | 40 base::Version* out) { |
(...skipping 15 matching lines...) Expand all Loading... | |
37 | 56 |
38 // Receiving a zeroed UnguessableToken is a security issue. | 57 // Receiving a zeroed UnguessableToken is a security issue. |
39 if (high == 0 && low == 0) | 58 if (high == 0 && low == 0) |
40 return false; | 59 return false; |
41 | 60 |
42 *out = base::UnguessableToken::Deserialize(high, low); | 61 *out = base::UnguessableToken::Deserialize(high, low); |
43 return true; | 62 return true; |
44 } | 63 } |
45 | 64 |
46 } // namespace mojo | 65 } // namespace mojo |
OLD | NEW |