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

Unified Diff: mojo/common/common_type_converters.cc

Issue 1814003002: Implement the renderer side of the mojo based local storage implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/common/common_type_converters.cc
diff --git a/mojo/common/common_type_converters.cc b/mojo/common/common_type_converters.cc
index 2740853c3d0836c8d33a7ebd23354b472c33ab7c..583ae8e0e819ccc86598bc072e3afa9869f0bde1 100644
--- a/mojo/common/common_type_converters.cc
+++ b/mojo/common/common_type_converters.cc
@@ -56,4 +56,21 @@ Array<uint8_t> TypeConverter<Array<uint8_t>, std::string>::Convert(
return result;
}
+base::string16 TypeConverter<base::string16, Array<uint8_t> >::Convert(
dcheng 2016/03/18 06:35:29 Nit: >>
jam 2016/03/18 16:48:33 Done.
+ const Array<uint8_t>& input) {
+ if (input.is_null() || input.size() == 0u)
dcheng 2016/03/18 06:35:29 Nit: input.empty()
jam 2016/03/18 16:48:33 Done.
+ return base::string16();
+
+ return base::string16(reinterpret_cast<const base::char16*>(&input.front()),
+ input.size() / sizeof(base::char16));
+}
+
+Array<uint8_t> TypeConverter<Array<uint8_t>, base::string16>::Convert(
+ const base::string16& input) {
+ Array<uint8_t> result(input.size() * sizeof(base::char16));
+ if (input.size() > 0)
dcheng 2016/03/18 06:35:29 Nit: input.empty()
jam 2016/03/18 16:48:33 Done.
+ memcpy(&result.front(), input.c_str(), input.size() * sizeof(base::char16));
+ return result;
+}
+
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698