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 mojo::ConstCArray<uint16_t> |
| 13 StructTraits<mojo::common::mojom::String16DataView, base::string16>::data( |
| 14 const base::string16& str) { |
| 15 return mojo::ConstCArray<uint16_t>( |
| 16 str.size(), reinterpret_cast<const uint16_t*>(str.data())); |
| 17 } |
| 18 |
| 19 // static |
| 20 bool StructTraits<mojo::common::mojom::String16DataView, base::string16>::Read( |
| 21 mojo::common::mojom::String16DataView data, |
| 22 base::string16* out) { |
| 23 mojo::ArrayDataView<uint16_t> view; |
| 24 data.GetDataDataView(&view); |
| 25 if (view.is_null()) |
| 26 return false; |
| 27 out->assign(reinterpret_cast<const base::char16*>(view.data()), view.size()); |
| 28 return true; |
| 29 } |
| 30 |
| 31 // static |
12 const std::vector<uint32_t>& | 32 const std::vector<uint32_t>& |
13 StructTraits<mojo::common::mojom::VersionDataView, base::Version>::components( | 33 StructTraits<mojo::common::mojom::VersionDataView, base::Version>::components( |
14 const base::Version& version) { | 34 const base::Version& version) { |
15 return version.components(); | 35 return version.components(); |
16 } | 36 } |
17 | 37 |
18 // static | 38 // static |
19 bool StructTraits<mojo::common::mojom::VersionDataView, base::Version>::Read( | 39 bool StructTraits<mojo::common::mojom::VersionDataView, base::Version>::Read( |
20 mojo::common::mojom::VersionDataView data, | 40 mojo::common::mojom::VersionDataView data, |
21 base::Version* out) { | 41 base::Version* out) { |
(...skipping 15 matching lines...) Expand all Loading... |
37 | 57 |
38 // Receiving a zeroed UnguessableToken is a security issue. | 58 // Receiving a zeroed UnguessableToken is a security issue. |
39 if (high == 0 && low == 0) | 59 if (high == 0 && low == 0) |
40 return false; | 60 return false; |
41 | 61 |
42 *out = base::UnguessableToken::Deserialize(high, low); | 62 *out = base::UnguessableToken::Deserialize(high, low); |
43 return true; | 63 return true; |
44 } | 64 } |
45 | 65 |
46 } // namespace mojo | 66 } // namespace mojo |
OLD | NEW |