Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 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/lib/string_serialization.h" | |
| 6 | |
| 7 #include <string.h> | |
| 8 | |
| 9 #include "mojo/public/cpp/bindings/lib/array_internal.h" | |
|
yzshen1
2014/05/27 22:16:59
nit: the .h file has already included it.
| |
| 10 | |
| 11 namespace mojo { | |
| 12 | |
| 13 size_t GetSerializedSize_(const String& input) { | |
| 14 return internal::Align(sizeof(internal::String_Data) + input.size()); | |
| 15 } | |
| 16 | |
| 17 void Serialize_(const String& input, internal::Buffer* buf, | |
| 18 internal::String_Data** output) { | |
| 19 internal::String_Data* result = internal::String_Data::New(input.size(), buf); | |
|
yzshen1
2014/05/27 22:16:59
Maybe we need to check whether input is null and s
| |
| 20 memcpy(result->storage(), input.data(), input.size()); | |
| 21 *output = result; | |
| 22 } | |
| 23 | |
| 24 void Deserialize_(internal::String_Data* input, String* output) { | |
| 25 if (input) { | |
| 26 String result(input->storage(), input->size()); | |
| 27 result.Swap(output); | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 } // namespace mojo | |
| OLD | NEW |