Index: ipc/file_descriptor_set_posix.h |
diff --git a/ipc/file_descriptor_set_posix.h b/ipc/file_descriptor_set_posix.h |
index b413b4a2212abc214e5b09f4557ac7652ad54c9d..9d0ea352f6c603c04e3d3f702bbb5b2eb7c14160 100644 |
--- a/ipc/file_descriptor_set_posix.h |
+++ b/ipc/file_descriptor_set_posix.h |
@@ -8,8 +8,9 @@ |
#include <vector> |
#include "base/basictypes.h" |
-#include "base/file_descriptor_posix.h" |
+#include "base/files/file.h" |
#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_vector.h" |
#include "ipc/ipc_export.h" |
// ----------------------------------------------------------------------------- |
@@ -36,10 +37,10 @@ class IPC_EXPORT FileDescriptorSet |
// Interfaces for building during message serialisation... |
// Add a descriptor to the end of the set. Returns false iff the set is full. |
- bool Add(int fd); |
+ bool AddToBorrow(base::PlatformFile fd); |
// Add a descriptor to the end of the set and automatically close it after |
// transmission. Returns false iff the set is full. |
- bool AddAndAutoClose(int fd); |
+ bool AddToOwn(base::File fd); |
// --------------------------------------------------------------------------- |
@@ -48,9 +49,12 @@ class IPC_EXPORT FileDescriptorSet |
// Interfaces for accessing during message deserialisation... |
// Return the number of descriptors |
- unsigned size() const { return descriptors_.size(); } |
+ unsigned size() const { |
+ return owned_descriptors_.size() + borrowed_descriptors_.size(); |
+ } |
+ |
// Return true if no unconsumed descriptors remain |
- bool empty() const { return descriptors_.empty(); } |
+ bool empty() const { return 0 == size(); } |
// Fetch the nth descriptor from the beginning of the set. Code using this |
// /must/ access the descriptors in order, except that it may wrap from the |
// end to index 0 again. |
@@ -58,7 +62,7 @@ class IPC_EXPORT FileDescriptorSet |
// This interface is designed for the deserialising code as it doesn't |
// support close flags. |
// returns: file descriptor, or -1 on error |
- int GetDescriptorAt(unsigned n) const; |
+ base::PlatformFile TakeDescriptorAt(unsigned n); |
// --------------------------------------------------------------------------- |
@@ -79,7 +83,7 @@ class IPC_EXPORT FileDescriptorSet |
bool ContainsDirectoryDescriptor() const; |
// Fetch all filedescriptors with the "auto close" property. |
// Used instead of CommitAll() when closing must be handled manually. |
- void ReleaseFDsToClose(std::vector<int>* fds); |
+ void ReleaseFDsToClose(std::vector<base::PlatformFile>* fds); |
// --------------------------------------------------------------------------- |
@@ -90,7 +94,7 @@ class IPC_EXPORT FileDescriptorSet |
// Set the contents of the set from the given buffer. This set must be empty |
// before calling. The auto-close flag is set on all the descriptors so that |
// unconsumed descriptors are closed on destruction. |
- void SetDescriptors(const int* buffer, unsigned count); |
+ void SetDescriptors(const base::PlatformFile* buffer, unsigned count); |
// --------------------------------------------------------------------------- |
@@ -103,7 +107,8 @@ class IPC_EXPORT FileDescriptorSet |
// these descriptors are sent as control data. After sending, any descriptors |
// with a true flag are closed. If this message has been received, then these |
// are the descriptors which were received and all close flags are true. |
- std::vector<base::FileDescriptor> descriptors_; |
+ std::vector<base::PlatformFile> borrowed_descriptors_; |
+ ScopedVector<base::File> owned_descriptors_; |
// This contains the index of the next descriptor which should be consumed. |
// It's used in a couple of ways. Firstly, at destruction we can check that |