summaryrefslogtreecommitdiffstats
path: root/gpu/ipc
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-04 22:46:03 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-04 22:46:03 +0000
commit1aca0098c408047b8ddedfc306e8b8163b7b4ec2 (patch)
tree34e3cc762575da0f6a0243642a3a8d1dc3dc6773 /gpu/ipc
parent35fb693d6565cf0435a11d238df29b62c5668315 (diff)
downloadchromium_src-1aca0098c408047b8ddedfc306e8b8163b7b4ec2.zip
chromium_src-1aca0098c408047b8ddedfc306e8b8163b7b4ec2.tar.gz
chromium_src-1aca0098c408047b8ddedfc306e8b8163b7b4ec2.tar.bz2
Move Mailbox from cc to gpu, and its traits to gpu/ipc
Mailbox is safer to IPC than coaxing it into a string, because otherwise we need to validate the size when coming from untrusted sources. This is to enable passing Mailbox through IPC without having to depend on cc. Among others I will need it to move Pepper to mailboxes, and pepper can't depend on cc. BUG=164095 Review URL: https://chromiumcodereview.appspot.com/12378053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186006 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/ipc')
-rw-r--r--gpu/ipc/gpu_command_buffer_traits.cc22
-rw-r--r--gpu/ipc/gpu_command_buffer_traits.h12
2 files changed, 34 insertions, 0 deletions
diff --git a/gpu/ipc/gpu_command_buffer_traits.cc b/gpu/ipc/gpu_command_buffer_traits.cc
index b502b0fd..d9fc17d 100644
--- a/gpu/ipc/gpu_command_buffer_traits.cc
+++ b/gpu/ipc/gpu_command_buffer_traits.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "gpu/ipc/gpu_command_buffer_traits.h"
+#include "gpu/command_buffer/common/mailbox.h"
namespace IPC {
@@ -38,4 +39,25 @@ void ParamTraits<gpu::CommandBuffer::State> ::Log(const param_type& p,
l->append("<CommandBuffer::State>");
}
+void ParamTraits<gpu::Mailbox>::Write(Message* m, const param_type& p) {
+ m->WriteBytes(p.name, sizeof(p.name));
+}
+
+bool ParamTraits<gpu::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<gpu::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]);
+}
+
+
} // namespace IPC
diff --git a/gpu/ipc/gpu_command_buffer_traits.h b/gpu/ipc/gpu_command_buffer_traits.h
index ac267db..6b2531f 100644
--- a/gpu/ipc/gpu_command_buffer_traits.h
+++ b/gpu/ipc/gpu_command_buffer_traits.h
@@ -9,6 +9,10 @@
#include "gpu/command_buffer/common/command_buffer.h"
#include "gpu/gpu_export.h"
+namespace gpu {
+struct Mailbox;
+}
+
namespace IPC {
template <>
@@ -19,6 +23,14 @@ struct GPU_EXPORT ParamTraits<gpu::CommandBuffer::State> {
static void Log(const param_type& p, std::string* l);
};
+template<>
+struct GPU_EXPORT ParamTraits<gpu::Mailbox> {
+ typedef gpu::Mailbox param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, PickleIterator* iter, param_type* p);
+ static void Log(const param_type& p, std::string* l);
+};
+
} // namespace IPC
#endif // GPU_IPC_GPU_PARAM_TRAITS_H_