diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-07 00:39:26 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-07 00:39:26 +0000 |
commit | 526776cf6ba5d6370ef28c9b483141fb0e4b1ae6 (patch) | |
tree | 5dd943dee4f2c74661c97f09a04b2358b16e3185 /chrome/common/ipc_channel_posix.h | |
parent | 95284326ea69903454907a200ad43ec41d158105 (diff) | |
download | chromium_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_channel_posix.h')
-rw-r--r-- | chrome/common/ipc_channel_posix.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/chrome/common/ipc_channel_posix.h b/chrome/common/ipc_channel_posix.h index cdc0db2..4f4e0ef 100644 --- a/chrome/common/ipc_channel_posix.h +++ b/chrome/common/ipc_channel_posix.h @@ -7,10 +7,14 @@ #include "chrome/common/ipc_channel.h" +#include <sys/socket.h> // for CMSG macros + #include <queue> #include <string> +#include <vector> #include "base/message_loop.h" +#include "chrome/common/file_descriptor_posix.h" namespace IPC { @@ -68,9 +72,20 @@ class Channel::ChannelImpl : public MessageLoopForIO::Watcher { // We read from the pipe into this buffer char input_buf_[Channel::kReadBufferSize]; + enum { + // We assume a worst case: kReadBufferSize bytes of messages, where each + // message has no payload and a full complement of descriptors. + MAX_READ_FDS = (Channel::kReadBufferSize / sizeof(IPC::Message::Header)) * + DescriptorSet::MAX_DESCRIPTORS_PER_MESSAGE, + }; + + // This is a control message buffer large enough to hold kMaxReadFDs + char input_cmsg_buf_[CMSG_SPACE(sizeof(int) * MAX_READ_FDS)]; + // Large messages that span multiple pipe buffers, get built-up using // this buffer. std::string input_overflow_buf_; + std::vector<int> input_overflow_fds_; // In server-mode, we have to wait for the client to connect before we // can begin reading. We make use of the input_state_ when performing |