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-12 04:05:28 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-12 04:05:28 +0000
commit7135bb043af7f66b5ed36e71775e9d1835da7420 (patch)
tree41c3ee7d52df762392ee36fd03cea80761b03015 /chrome/common/ipc_message_utils.h
parente707d5e60b2191d3ffde90edcbafc01d8d7f7590 (diff)
downloadchromium_src-7135bb043af7f66b5ed36e71775e9d1835da7420.zip
chromium_src-7135bb043af7f66b5ed36e71775e9d1835da7420.tar.gz
chromium_src-7135bb043af7f66b5ed36e71775e9d1835da7420.tar.bz2
POSIX: Clean up DescriptorSet
In general, the IPC Message objects are const and the iterator state is a void* kept by the code which is doing the deserialisation. However, now that we have an array of file descriptors, the index of the next file descriptor is part of the iteration state and is kept /inside/ the Message (in the DescriptorSet). This means that it's a mutable member, which is never too nice and also, since the logging functions want to parse a message multiple times, we've had to turn off returning an error when one runs off the end of the array. Also, the Message copy constructor and assignment function alters the /source/ Message, by stealing all of its descriptors This patch encodes the index of each file descriptor on the wire. So the state is moved from inside the DescriptorSet into the serialised data. Additionally, the DescriptorSet is made into a lazyily created scoped_refptr, solving the problems with copying messages. Review URL: http://codereview.chromium.org/20275 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9644 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/ipc_message_utils.h')
-rw-r--r--chrome/common/ipc_message_utils.h22
1 files changed, 5 insertions, 17 deletions
diff --git a/chrome/common/ipc_message_utils.h b/chrome/common/ipc_message_utils.h
index a87a594..fa65288 100644
--- a/chrome/common/ipc_message_utils.h
+++ b/chrome/common/ipc_message_utils.h
@@ -671,29 +671,17 @@ template<>
struct ParamTraits<base::FileDescriptor> {
typedef base::FileDescriptor param_type;
static void Write(Message* m, const param_type& p) {
- if (p.auto_close) {
- if (!m->descriptor_set()->AddAndAutoClose(p.fd))
- NOTREACHED();
- } else {
- if (!m->descriptor_set()->Add(p.fd))
- NOTREACHED();
- }
+ if (!m->WriteFileDescriptor(p))
+ NOTREACHED();
}
static bool Read(const Message* m, void** iter, param_type* r) {
- r->auto_close = false;
- r->fd = m->descriptor_set()->NextDescriptor();
-
- // We always return true here because some of the IPC message logging
- // functions want to parse the message multiple times. On the second and
- // later attempts, the descriptor_set will be empty and so will return -1,
- // however, failing to parse at log time is a fatal error.
- return true;
+ return m->ReadFileDescriptor(iter, r);
}
static void Log(const param_type& p, std::wstring* l) {
if (p.auto_close) {
- l->append(L"FD(auto-close)");
+ l->append(StringPrintf(L"FD(%d auto-close)", p.fd));
} else {
- l->append(L"FD");
+ l->append(StringPrintf(L"FD(%d)", p.fd));
}
}
};