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_serialization.cc

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix windows bustage Created 6 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 | Annotate | Revision Log
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 #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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698