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

Side by Side Diff: mojo/common/common_type_converters.cc

Issue 2047703003: Revert of Implement ui::ClipboardMus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « mojo/common/common_type_converters.h ('k') | ui/base/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.empty()) 54 if (!input.empty())
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 Array<uint8_t> TypeConverter<Array<uint8_t>, base::StringPiece>::Convert(
60 const base::StringPiece& input) {
61 Array<uint8_t> result(input.size());
62 if (!input.empty())
63 memcpy(&result.front(), input.data(), input.size());
64 return result;
65 }
66
67 base::string16 TypeConverter<base::string16, Array<uint8_t>>::Convert( 59 base::string16 TypeConverter<base::string16, Array<uint8_t>>::Convert(
68 const Array<uint8_t>& input) { 60 const Array<uint8_t>& input) {
69 if (input.is_null() || input.empty()) 61 if (input.is_null() || input.empty())
70 return base::string16(); 62 return base::string16();
71 63
72 return base::string16(reinterpret_cast<const base::char16*>(&input.front()), 64 return base::string16(reinterpret_cast<const base::char16*>(&input.front()),
73 input.size() / sizeof(base::char16)); 65 input.size() / sizeof(base::char16));
74 } 66 }
75 67
76 Array<uint8_t> TypeConverter<Array<uint8_t>, base::string16>::Convert( 68 Array<uint8_t> TypeConverter<Array<uint8_t>, base::string16>::Convert(
77 const base::string16& input) { 69 const base::string16& input) {
78 Array<uint8_t> result(input.size() * sizeof(base::char16)); 70 Array<uint8_t> result(input.size() * sizeof(base::char16));
79 if (!input.empty()) 71 if (!input.empty())
80 memcpy(&result.front(), input.c_str(), input.size() * sizeof(base::char16)); 72 memcpy(&result.front(), input.c_str(), input.size() * sizeof(base::char16));
81 return result; 73 return result;
82 } 74 }
83 75
84 } // namespace mojo 76 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/common/common_type_converters.h ('k') | ui/base/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698