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

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

Issue 507173003: Change TypeConverter<X,Y>::ConvertFrom and ConvertTo into a single symmetric (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile for real Created 6 years, 3 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/type_conversion_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/type_conversion_unittest.cc b/mojo/public/cpp/bindings/tests/type_conversion_unittest.cc
index ed652a1aaf579b840504b5b1f5325f2114f9d195..8b0e9409bc5cf25e89cefc2d56fae66862a8eb72 100644
--- a/mojo/public/cpp/bindings/tests/type_conversion_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/type_conversion_unittest.cc
@@ -41,9 +41,8 @@ bool AreEqualRectArrays(const Array<test::RectPtr>& rects1,
} // namespace
template <>
-class TypeConverter<test::RectPtr, RedmondRect> {
- public:
- static test::RectPtr ConvertFrom(const RedmondRect& input) {
+struct TypeConverter<test::RectPtr, RedmondRect> {
+ static test::RectPtr Convert(const RedmondRect& input) {
test::RectPtr rect(test::Rect::New());
rect->x = input.left;
rect->y = input.top;
@@ -51,7 +50,11 @@ class TypeConverter<test::RectPtr, RedmondRect> {
rect->height = input.bottom - input.top;
return rect.Pass();
}
- static RedmondRect ConvertTo(const test::RectPtr& input) {
+};
+
+template <>
+struct TypeConverter<RedmondRect, test::RectPtr> {
+ static RedmondRect Convert(const test::RectPtr& input) {
RedmondRect rect;
rect.left = input->x;
rect.top = input->y;
@@ -62,15 +65,18 @@ class TypeConverter<test::RectPtr, RedmondRect> {
};
template <>
-class TypeConverter<test::NamedRegionPtr, RedmondNamedRegion> {
- public:
- static test::NamedRegionPtr ConvertFrom(const RedmondNamedRegion& input) {
+struct TypeConverter<test::NamedRegionPtr, RedmondNamedRegion> {
+ static test::NamedRegionPtr Convert(const RedmondNamedRegion& input) {
test::NamedRegionPtr region(test::NamedRegion::New());
region->name = input.name;
region->rects = Array<test::RectPtr>::From(input.rects);
return region.Pass();
}
- static RedmondNamedRegion ConvertTo(const test::NamedRegionPtr& input) {
+};
+
+template <>
+struct TypeConverter<RedmondNamedRegion, test::NamedRegionPtr> {
+ static RedmondNamedRegion Convert(const test::NamedRegionPtr& input) {
RedmondNamedRegion region;
region.name = input->name;
region.rects = input->rects.To<std::vector<RedmondRect> >();
« no previous file with comments | « mojo/public/cpp/bindings/tests/sample_service_unittest.cc ('k') | mojo/public/cpp/bindings/type_converter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698