OLD | NEW |
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 Loading... |
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 |
OLD | NEW |