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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/common/common_type_converters.h" 5 #include "mojo/common/common_type_converters.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 Array<uint8_t> TypeConverter<Array<uint8_t>, std::string>::Convert( 51 Array<uint8_t> TypeConverter<Array<uint8_t>, std::string>::Convert(
52 const std::string& input) { 52 const std::string& input) {
53 Array<uint8_t> result(input.size()); 53 Array<uint8_t> result(input.size());
54 if (input.size() > 0) 54 if (input.size() > 0)
55 memcpy(&result.front(), input.c_str(), input.size()); 55 memcpy(&result.front(), input.c_str(), input.size());
56 return result; 56 return result;
57 } 57 }
58 58
59 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.
60 const Array<uint8_t>& input) {
61 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.
62 return base::string16();
63
64 return base::string16(reinterpret_cast<const base::char16*>(&input.front()),
65 input.size() / sizeof(base::char16));
66 }
67
68 Array<uint8_t> TypeConverter<Array<uint8_t>, base::string16>::Convert(
69 const base::string16& input) {
70 Array<uint8_t> result(input.size() * sizeof(base::char16));
71 if (input.size() > 0)
dcheng 2016/03/18 06:35:29 Nit: input.empty()
jam 2016/03/18 16:48:33 Done.
72 memcpy(&result.front(), input.c_str(), input.size() * sizeof(base::char16));
73 return result;
74 }
75
59 } // namespace mojo 76 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698