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 |