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

Side by Side Diff: mojo/public/cpp/bindings/lib/string_traits_string16.cc

Issue 1913043002: Convert ManifestManager IPCs to Mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "mojo/public/cpp/bindings/string_traits_string16.h"
6
7 #include <string.h>
8
9 #include "base/logging.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "mojo/public/cpp/bindings/lib/array_internal.h"
12
13 namespace mojo {
14 namespace {
15
16 std::string* ToStdString(const base::string16& input, void* context) {
17 return static_cast<std::string*>(context);
18 }
19
20 } // namespace
21
22 // static
23 void StringTraits<base::string16>::SetToNull(base::string16* output) {
24 output->clear();
25 }
26
27 // static
28 void* StringTraits<base::string16>::SetUpContext(const base::string16& input) {
29 return new std::string(base::UTF16ToUTF8(input));
30 }
31
32 // static
33 void StringTraits<base::string16>::TearDownContext(const base::string16& input,
34 void* context) {
35 delete ToStdString(input, context);
36 }
37
38 // static
39 size_t StringTraits<base::string16>::GetSize(const base::string16& input,
40 void* context) {
41 return ToStdString(input, context)->length();
42 }
43
44 // static
45 const char* StringTraits<base::string16>::GetData(const base::string16& input,
46 void* context) {
47 return ToStdString(input, context)->data();
48 }
49
50 // static
51 bool StringTraits<base::string16>::Read(StringDataView input,
52 base::string16* output) {
53 return base::UTF8ToUTF16(input.storage(), input.size(), output);
54 }
55
56 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698