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

Unified Diff: mojo/common/common_type_converters.cc

Issue 562483002: mojo: Create a basic clipboard. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes to the gn files. 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
« no previous file with comments | « mojo/common/common_type_converters.h ('k') | mojo/common/common_type_converters_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/common/common_type_converters.cc
diff --git a/mojo/common/common_type_converters.cc b/mojo/common/common_type_converters.cc
index ffc190716b2d0d2d72259322a29838a638885816..114b409d7488232a4c4cb39c1859aca7cd0c0823 100644
--- a/mojo/common/common_type_converters.cc
+++ b/mojo/common/common_type_converters.cc
@@ -46,4 +46,20 @@ GURL TypeConverter<GURL, String>::Convert(const String& input) {
return GURL(input.get());
}
+std::string TypeConverter<std::string, Array<uint8_t> >::Convert(
+ const Array<uint8_t>& input) {
+ if (input.is_null())
+ return std::string();
+
+ return std::string(reinterpret_cast<const char*>(&input.front()),
+ input.size());
+}
+
+Array<uint8_t> TypeConverter<Array<uint8_t>, std::string>::Convert(
+ const std::string& input) {
+ Array<uint8_t> result(input.size());
+ memcpy(&result.front(), input.c_str(), input.size());
+ return result.Pass();
+}
+
} // namespace mojo
« no previous file with comments | « mojo/common/common_type_converters.h ('k') | mojo/common/common_type_converters_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698