Chromium Code Reviews| 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..5e7eb0f5871e0ab94a9a528ec3ea101f2c6d9bcd 100644 |
| --- a/mojo/common/common_type_converters.cc |
| +++ b/mojo/common/common_type_converters.cc |
| @@ -46,4 +46,24 @@ 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(); |
| + |
| + std::string result; |
| + result.reserve(input.size()); |
| + for (size_t i = 0; i < input.size(); ++i) |
|
sky
2014/09/15 23:16:51
Seems like there should be a better way to do thes
Elliot Glaysher
2014/09/15 23:30:14
I agree. But attempts at writing straight memcpys
|
| + result.push_back(input[i]); |
| + return result; |
| +} |
| + |
| +Array<uint8_t> TypeConverter<Array<uint8_t>, std::string>::Convert( |
| + const std::string& input) { |
| + Array<uint8_t> result(input.size()); |
| + for (size_t i = 0; i < input.size(); ++i) |
| + result[i] = input[i]; |
| + return result.Pass(); |
| +} |
| + |
| } // namespace mojo |