Chromium Code Reviews| 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_TRAITS_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_TRAITS_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_TRAITS_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_TRAITS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 | 94 |
| 95 template <> | 95 template <> |
| 96 struct StructTraits<test::PassByValueStructWithTraits, | 96 struct StructTraits<test::PassByValueStructWithTraits, |
| 97 test::PassByValueStructWithTraitsImpl> { | 97 test::PassByValueStructWithTraitsImpl> { |
| 98 // Deserialization to test::PassByValueStructTraitsImpl. | 98 // Deserialization to test::PassByValueStructTraitsImpl. |
| 99 static bool Read(test::PassByValueStructWithTraits::DataView data, | 99 static bool Read(test::PassByValueStructWithTraits::DataView data, |
| 100 test::PassByValueStructWithTraitsImpl* out); | 100 test::PassByValueStructWithTraitsImpl* out); |
| 101 | 101 |
| 102 // Fields in test::PassByValueStructWithTraits. | 102 // Fields in test::PassByValueStructWithTraits. |
| 103 // See src/mojo/public/interfaces/bindings/tests/struct_with_traits.mojom. | 103 // See src/mojo/public/interfaces/bindings/tests/struct_with_traits.mojom. |
| 104 static ScopedHandle& f_handle(test::PassByValueStructWithTraitsImpl& value) { | 104 static ScopedHandle f_handle(test::PassByValueStructWithTraitsImpl& value) { |
| 105 return value.get_mutable_handle(); | 105 return std::move(value.get_mutable_handle()); |
|
Peng
2016/07/06 18:05:26
Yes. This is what I need.
| |
| 106 } | 106 } |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 template <> | 109 template <> |
| 110 struct StructTraits<test::StructWithTraitsForUniquePtrTest, | 110 struct StructTraits<test::StructWithTraitsForUniquePtrTest, |
| 111 std::unique_ptr<int>> { | 111 std::unique_ptr<int>> { |
| 112 static int f_int32(const std::unique_ptr<int>& data) { return *data; } | 112 static int f_int32(const std::unique_ptr<int>& data) { return *data; } |
| 113 | 113 |
| 114 static bool Read(test::StructWithTraitsForUniquePtrTest::DataView data, | 114 static bool Read(test::StructWithTraitsForUniquePtrTest::DataView data, |
| 115 std::unique_ptr<int>* out) { | 115 std::unique_ptr<int>* out) { |
| 116 out->reset(new int(data.f_int32())); | 116 out->reset(new int(data.f_int32())); |
| 117 return true; | 117 return true; |
| 118 } | 118 } |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 } // namespace mojo | 121 } // namespace mojo |
| 122 | 122 |
| 123 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_TRAITS_H_ | 123 #endif // MOJO_PUBLIC_CPP_BINDINGS_TESTS_STRUCT_WITH_TRAITS_IMPL_TRAITS_H_ |
| OLD | NEW |