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

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

Issue 1968623002: Mojo C++ bindings: expose public <struct>DataView and StringDataView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@25_totally_new
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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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/public/cpp/bindings/string_traits_wtf.h" 5 #include "mojo/public/cpp/bindings/string_traits_wtf.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "mojo/public/cpp/bindings/lib/array_internal.h" 10 #include "mojo/public/cpp/bindings/lib/array_internal.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 return ToAdaptor(input, context)->utf8_adaptor.length(); 59 return ToAdaptor(input, context)->utf8_adaptor.length();
60 } 60 }
61 61
62 // static 62 // static
63 const char* StringTraits<WTF::String>::GetData(const WTF::String& input, 63 const char* StringTraits<WTF::String>::GetData(const WTF::String& input,
64 void* context) { 64 void* context) {
65 return ToAdaptor(input, context)->utf8_adaptor.data(); 65 return ToAdaptor(input, context)->utf8_adaptor.data();
66 } 66 }
67 67
68 // static 68 // static
69 bool StringTraits<WTF::String>::Read(internal::String_Data* input, 69 bool StringTraits<WTF::String>::Read(StringDataView input,
70 WTF::String* output) { 70 WTF::String* output) {
71 if (input) { 71 if (!input.is_null()) {
72 WTF::String result = WTF::String::fromUTF8(input->storage(), input->size()); 72 WTF::String result = WTF::String::fromUTF8(input.storage(), input.size());
73 output->swap(result); 73 output->swap(result);
74 } else if (!output->isNull()) { 74 } else if (!output->isNull()) {
75 WTF::String result; 75 WTF::String result;
76 output->swap(result); 76 output->swap(result);
77 } 77 }
78 return true; 78 return true;
79 } 79 }
80 80
81 } // namespace mojo 81 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/string_serialization.h ('k') | mojo/public/cpp/bindings/string_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698