Support using a Mojo message pipe in a ChannelHandle.
BUG=604282
Review-Url: https://codereview.chromium.org/2047233002
Cr-Commit-Position: refs/heads/master@{#402121}
CrOS-Libchrome-Original-Commit: 3618252c6bdc743f469b163c5b813d92ea6a064f
diff --git a/ipc/ipc_message_utils.cc b/ipc/ipc_message_utils.cc
index 302778e..60c12ab 100644
--- a/ipc/ipc_message_utils.cc
+++ b/ipc/ipc_message_utils.cc
@@ -18,6 +18,7 @@
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_message_attachment.h"
#include "ipc/ipc_message_attachment_set.h"
+#include "ipc/ipc_mojo_param_traits.h"
#if defined(OS_POSIX)
#include "ipc/ipc_platform_file_attachment_posix.h"
@@ -638,7 +639,8 @@
void ParamTraits<base::FileDescriptor>::GetSize(base::PickleSizer* sizer,
const param_type& p) {
GetParamSize(sizer, p.fd >= 0);
- sizer->AddAttachment();
+ if (p.fd >= 0)
+ sizer->AddAttachment();
}
void ParamTraits<base::FileDescriptor>::Write(base::Pickle* m,
@@ -1002,6 +1004,7 @@
#if defined(OS_POSIX)
GetParamSize(sizer, p.socket);
#endif
+ GetParamSize(sizer, p.mojo_handle);
}
void ParamTraits<IPC::ChannelHandle>::Write(base::Pickle* m,
@@ -1014,6 +1017,7 @@
#if defined(OS_POSIX)
WriteParam(m, p.socket);
#endif
+ WriteParam(m, p.mojo_handle);
}
bool ParamTraits<IPC::ChannelHandle>::Read(const base::Pickle* m,
@@ -1023,7 +1027,7 @@
#if defined(OS_POSIX)
&& ReadParam(m, iter, &r->socket)
#endif
- ;
+ && ReadParam(m, iter, &r->mojo_handle);
}
void ParamTraits<IPC::ChannelHandle>::Log(const param_type& p,
@@ -1033,6 +1037,8 @@
l->append(", ");
ParamTraits<base::FileDescriptor>::Log(p.socket, l);
#endif
+ l->append(", ");
+ LogParam(p.mojo_handle, l);
l->append(")");
}