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

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

Issue 1520153002: [mojo] Allow value deserialization to fail (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bindings-3-misc-support
Patch Set: merge Created 5 years 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 2014 The Chromium Authors. All rights reserved. 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 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/lib/string_serialization.h" 5 #include "mojo/public/cpp/bindings/lib/string_serialization.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 namespace mojo { 9 namespace mojo {
10 10
(...skipping 10 matching lines...) Expand all
21 internal::String_Data* result = 21 internal::String_Data* result =
22 internal::String_Data::New(input.size(), buf); 22 internal::String_Data::New(input.size(), buf);
23 if (result) 23 if (result)
24 memcpy(result->storage(), input.data(), input.size()); 24 memcpy(result->storage(), input.data(), input.size());
25 *output = result; 25 *output = result;
26 } else { 26 } else {
27 *output = nullptr; 27 *output = nullptr;
28 } 28 }
29 } 29 }
30 30
31 void Deserialize_(internal::String_Data* input, 31 bool Deserialize_(internal::String_Data* input,
32 String* output, 32 String* output,
33 internal::SerializationContext* context) { 33 internal::SerializationContext* context) {
34 if (input) { 34 if (input) {
35 String result(input->storage(), input->size()); 35 String result(input->storage(), input->size());
36 result.Swap(output); 36 result.Swap(output);
37 } else { 37 } else {
38 output->reset(); 38 output->reset();
39 } 39 }
40 return true;
40 } 41 }
41 42
42 } // namespace mojo 43 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698