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

Unified Diff: mojo/public/cpp/bindings/tests/pickled_struct_chromium.cc

Issue 1526533002: [mojo] Add pickling support for native-only structs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bindings-4-bool-deserialize
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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/tests/pickled_struct_chromium.cc
diff --git a/mojo/public/cpp/bindings/tests/pickled_struct_chromium.cc b/mojo/public/cpp/bindings/tests/pickled_struct_chromium.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d45a44a51f837945155555688c60d1929983a884
--- /dev/null
+++ b/mojo/public/cpp/bindings/tests/pickled_struct_chromium.cc
@@ -0,0 +1,45 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/public/cpp/bindings/tests/pickled_struct_chromium.h"
+
+#include "base/pickle.h"
+
+namespace mojo {
+namespace test {
+
+PickledStructChromium::PickledStructChromium() {}
+
+PickledStructChromium::PickledStructChromium(int foo, int bar)
+ : foo_(foo), bar_(bar) {
+}
+
+PickledStructChromium::~PickledStructChromium() {}
+
+} // namespace test
+} // namespace mojo
+
+namespace IPC {
+
+void ParamTraits<mojo::test::PickledStructChromium>::Write(
+ base::Pickle* m,
+ const param_type& p) {
+ m->WriteInt(p.foo());
+ m->WriteInt(p.bar());
+}
+
+bool ParamTraits<mojo::test::PickledStructChromium>::Read(
+ const base::Pickle* m,
+ base::PickleIterator* iter,
+ param_type* p) {
+ int foo, bar;
+ if (!iter->ReadInt(&foo) || !iter->ReadInt(&bar))
+ return false;
+
+ p->set_foo(foo);
+ p->set_bar(bar);
+ return true;
+}
+
+} // namespace IPC

Powered by Google App Engine
This is Rietveld 408576698