summaryrefslogtreecommitdiffstats
path: root/chrome/common/ipc_message_utils.h
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-07 00:39:26 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-07 00:39:26 +0000
commit526776cf6ba5d6370ef28c9b483141fb0e4b1ae6 (patch)
tree5dd943dee4f2c74661c97f09a04b2358b16e3185 /chrome/common/ipc_message_utils.h
parent95284326ea69903454907a200ad43ec41d158105 (diff)
downloadchromium_src-526776cf6ba5d6370ef28c9b483141fb0e4b1ae6.zip
chromium_src-526776cf6ba5d6370ef28c9b483141fb0e4b1ae6.tar.gz
chromium_src-526776cf6ba5d6370ef28c9b483141fb0e4b1ae6.tar.bz2
FileDescriptor: passing fds over IPC
This patch introduces a FileDescriptor object which can be included in IPC messages and will perform the magic needed to pass file descriptors over IPC. After some consideration, Windows will continue to do the current DuplicateHandle tricks. Review URL: http://codereview.chromium.org/20027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9369 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/ipc_message_utils.h')
-rw-r--r--chrome/common/ipc_message_utils.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/chrome/common/ipc_message_utils.h b/chrome/common/ipc_message_utils.h
index 64f5653..7887dcc 100644
--- a/chrome/common/ipc_message_utils.h
+++ b/chrome/common/ipc_message_utils.h
@@ -12,6 +12,9 @@
#include "base/file_path.h"
#include "base/string_util.h"
#include "base/tuple.h"
+#if defined(OS_POSIX)
+#include "chrome/common/file_descriptor_posix.h"
+#endif
#include "chrome/common/ipc_sync_message.h"
#include "chrome/common/thumbnail_score.h"
#include "webkit/glue/cache_manager.h"
@@ -662,6 +665,35 @@ struct ParamTraits<gfx::Size> {
static void Log(const param_type& p, std::wstring* l);
};
+#if defined(OS_POSIX)
+
+template<>
+struct ParamTraits<FileDescriptor> {
+ typedef FileDescriptor param_type;
+ static void Write(Message* m, const param_type& p) {
+ if (p.auto_close) {
+ m->descriptor_set()->AddAndAutoClose(p.fd);
+ } else {
+ m->descriptor_set()->Add(p.fd);
+ }
+ }
+ static bool Read(const Message* m, void** iter, param_type* r) {
+ r->auto_close = false;
+ r->fd = m->descriptor_set()->NextDescriptor();
+
+ return r->fd >= 0;
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ if (p.auto_close) {
+ l->append(StringPrintf(L"FD(%d auto-close)", p.fd));
+ } else {
+ l->append(StringPrintf(L"FD(%d)", p.fd));
+ }
+ }
+};
+
+#endif // defined(OS_POSIX)
+
template<>
struct ParamTraits<ThumbnailScore> {
typedef ThumbnailScore param_type;