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

Unified Diff: mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc

Issue 1966933002: Mojo C++ bindings: switch the existing usage of StructTraits to use the new data view interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@26_reader
Patch Set: typeid() is not allowed :/ Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc
diff --git a/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc b/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc
index 8d4f97d43fffa05a1ad881936725a9d2ba592207..700368e83eaee928a7e4cba14e26fb03ecb734b0 100644
--- a/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc
+++ b/mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.cc
@@ -3,19 +3,21 @@
// found in the LICENSE file.
#include "mojo/public/cpp/bindings/tests/struct_with_traits_impl_traits.h"
-#include "mojo/public/interfaces/bindings/tests/struct_with_traits.mojom.h"
namespace mojo {
// static
bool StructTraits<test::StructWithTraits, test::StructWithTraitsImpl>::Read(
- test::StructWithTraits_Reader r,
+ test::StructWithTraitsDataView data,
test::StructWithTraitsImpl* out) {
- out->set_bool(r.f_bool());
- out->set_uint32(r.f_uint32());
- out->set_uint64(r.f_uint64());
- out->set_string(r.f_string().as_string());
- return r.f_string() == r.f_string2();
+ out->set_bool(data.f_bool());
+ out->set_uint32(data.f_uint32());
+ out->set_uint64(data.f_uint64());
+ base::StringPiece f_string, f_string2;
+ if (!data.ReadFString(&f_string) || !data.ReadFString2(&f_string2))
+ return false;
+ out->set_string(f_string.as_string());
+ return f_string == f_string2;
}
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698