Index: cc/ipc/cc_param_traits.cc |
diff --git a/cc/ipc/cc_param_traits.cc b/cc/ipc/cc_param_traits.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9575c01b50e9c93817ced918a02d1f226b968883 |
--- /dev/null |
+++ b/cc/ipc/cc_param_traits.cc |
@@ -0,0 +1,82 @@ |
+// Copyright (c) 2012 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 "cc/ipc/cc_param_traits.h" |
+ |
+#include "base/stringprintf.h" |
+#include "cc/ipc/cc_render_pass_traits.h" |
+#include "content/common/view_messages.h" |
+ |
+namespace IPC { |
+ |
+void ParamTraits<cc::Mailbox>::Write(Message* m, const param_type& p) { |
+ m->WriteBytes(p.name, sizeof(p.name)); |
+} |
+ |
+bool ParamTraits<cc::Mailbox>::Read(const Message* m, |
+ PickleIterator* iter, |
+ param_type* p) { |
+ const char* bytes = NULL; |
+ if (!m->ReadBytes(iter, &bytes, sizeof(p->name))) |
+ return false; |
+ DCHECK(bytes); |
+ memcpy(p->name, bytes, sizeof(p->name)); |
+ return true; |
+} |
+ |
+void ParamTraits<cc::Mailbox>::Log(const param_type& p, std::string* l) { |
+ for (size_t i = 0; i < sizeof(p.name); ++i) |
+ *l += base::StringPrintf("%02x", p.name[i]); |
+} |
+ |
+void ParamTraits<cc::CompositorFrame>::Write(Message* m, const param_type& p) { |
+ WriteParam(m, p.size); |
+ WriteParam(m, p.resources); |
+ WriteParam(m, p.render_passes.size()); |
+ for (size_t i = 0; i < p.render_passes.size(); ++i) |
+ WriteParam(m, *p.render_passes[i]); |
+} |
+ |
+bool ParamTraits<cc::CompositorFrame>::Read(const Message* m, |
+ PickleIterator* iter, |
+ param_type* p) { |
+ size_t render_passes; |
+ if (!ReadParam(m, iter, &p->size) || |
+ !ReadParam(m, iter, &p->resources) || |
+ !ReadParam(m, iter, &render_passes)) |
+ return false; |
+ for (size_t i = 0; i < render_passes; ++i) { |
+ cc::CCRenderPass* render_pass = ParamTraits<cc::CCRenderPass>::ReadRenderPass(m, iter); |
+ if (!render_pass) { |
+ // TODO: leak |
+ return false; |
+ } |
+ p->render_passes.push_back(render_pass); |
+ } |
+ return true; |
+} |
+ |
+void ParamTraits<cc::CompositorFrame>::Log(const param_type& p, |
+ std::string* l) { |
+ LogParam(p.size, l); |
+ LogParam(p.resources, l); |
+} |
+ |
+void ParamTraits<cc::CompositorFrameAck>::Write(Message* m, |
+ const param_type& p) { |
+ WriteParam(m, p.resources); |
+} |
+ |
+bool ParamTraits<cc::CompositorFrameAck>::Read(const Message* m, |
+ PickleIterator* iter, |
+ param_type* p) { |
+ return ReadParam(m, iter, &p->resources); |
+} |
+ |
+void ParamTraits<cc::CompositorFrameAck>::Log(const param_type& p, |
+ std::string* l) { |
+ LogParam(p.resources, l); |
+} |
+ |
+} // namespace IPC |