Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Unified Diff: chrome/common/ipc_message.h

Issue 20275: POSIX: Clean up DescriptorSet (Closed)
Patch Set: ... Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/ipc_channel_posix.cc ('k') | chrome/common/ipc_message.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/ipc_message.h
diff --git a/chrome/common/ipc_message.h b/chrome/common/ipc_message.h
index 8aedbe3b47007578306a03b59b6074909301d0b6..acdee24ea8b01e80ceb2d7c81da83062d86cee41 100644
--- a/chrome/common/ipc_message.h
+++ b/chrome/common/ipc_message.h
@@ -17,9 +17,15 @@
#define IPC_MESSAGE_LOG_ENABLED
#endif
#elif defined(OS_POSIX)
-#include "chrome/common/descriptor_set_posix.h"
+#include "base/ref_counted.h"
#endif
+namespace base {
+class FileDescriptor;
+}
+
+class DescriptorSet;
+
namespace IPC {
//------------------------------------------------------------------------------
@@ -162,7 +168,14 @@ class Message : public Pickle {
}
#if defined(OS_POSIX)
- DescriptorSet* descriptor_set() const { return &descriptor_set_; }
+ // On POSIX, a message supports reading / writing FileDescriptor objects.
+ // This is used to pass a file descriptor to the peer of an IPC channel.
+
+ // Add a descriptor to the end of the set. Returns false iff the set is full.
+ bool WriteFileDescriptor(const base::FileDescriptor& descriptor);
+ // Get a file descriptor from the message. Returns false on error.
+ // iter: a Pickle iterator to the current location in the message.
+ bool ReadFileDescriptor(void** iter, base::FileDescriptor* descriptor) const;
#endif
#ifdef IPC_MESSAGE_LOG_ENABLED
@@ -227,7 +240,18 @@ class Message : public Pickle {
#if defined(OS_POSIX)
// The set of file descriptors associated with this message.
- mutable DescriptorSet descriptor_set_;
+ scoped_refptr<DescriptorSet> descriptor_set_;
+
+ // Ensure that a DescriptorSet is allocated
+ void EnsureDescriptorSet();
+
+ DescriptorSet* descriptor_set() {
+ EnsureDescriptorSet();
+ return descriptor_set_.get();
+ }
+ const DescriptorSet* descriptor_set() const {
+ return descriptor_set_.get();
+ }
#endif
#ifdef IPC_MESSAGE_LOG_ENABLED
« no previous file with comments | « chrome/common/ipc_channel_posix.cc ('k') | chrome/common/ipc_message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698