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

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

Issue 814543006: Move //mojo/{public, edk} underneath //third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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 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 namespace mojo {
10
11 size_t GetSerializedSize_(const String& input) {
12 if (!input)
13 return 0;
14 return internal::Align(sizeof(internal::String_Data) + input.size());
15 }
16
17 void Serialize_(const String& input,
18 internal::Buffer* buf,
19 internal::String_Data** output) {
20 if (input) {
21 internal::String_Data* result =
22 internal::String_Data::New(input.size(), buf);
23 if (result)
24 memcpy(result->storage(), input.data(), input.size());
25 *output = result;
26 } else {
27 *output = nullptr;
28 }
29 }
30
31 void Deserialize_(internal::String_Data* input, String* output) {
32 if (input) {
33 String result(input->storage(), input->size());
34 result.Swap(output);
35 } else {
36 output->reset();
37 }
38 }
39
40 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/string_serialization.h ('k') | mojo/public/cpp/bindings/lib/template_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698