Chromium Code Reviews| Index: content/public/browser/file_descriptor_info.h |
| diff --git a/content/public/browser/file_descriptor_info.h b/content/public/browser/file_descriptor_info.h |
| index 2248eb690f1b942aac9a4901f86ed6e825d65403..fce7ce5b32467d8dd93b2ce5fd16027aa6258bd9 100644 |
| --- a/content/public/browser/file_descriptor_info.h |
| +++ b/content/public/browser/file_descriptor_info.h |
| @@ -5,23 +5,50 @@ |
| #ifndef CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_ |
| #define CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_ |
| -#include "base/file_descriptor_posix.h" |
| +#include "base/files/file.h" |
| +#include "base/memory/scoped_vector.h" |
| +#include "base/process/launch.h" |
| +#include "content/common/content_export.h" |
| namespace content { |
| -// This struct is used when passing files that should be mapped in a process |
| -// that is been created and allows to associate that file with a specific ID. |
| -// It also provides a way to know if the actual file descriptor should be |
| -// closed with the FileDescriptor.auto_close field. |
| - |
| -struct FileDescriptorInfo { |
| - FileDescriptorInfo(int id, const base::FileDescriptor& file_descriptor) |
| - : id(id), |
| - fd(file_descriptor) { |
| - } |
| - |
| - int id; |
| - base::FileDescriptor fd; |
| +// FileDescriptorInfo is a collection of file descriptors which is |
|
jam
2014/09/23 05:16:09
this doesn't conform to the content api http://www
|
| +// needed to launch a process. You should to tell FileDescriptorInfo |
| +// which FD should be closed and which isn't so that it can take care |
| +// of the lifetime of FDs. |
| +// |
| +// See base/process/launcher.h for more details about launching a |
| +// process. |
| +class CONTENT_EXPORT FileDescriptorInfo { |
| + public: |
| + FileDescriptorInfo(); |
| + ~FileDescriptorInfo(); |
| + |
| + // Add and FD associated with an ID, without delegating the ownerhip |
| + // of ID. |
| + void Share(int id, base::PlatformFile fd); |
| + // Add an FD associated with an ID, passing the FD ownership to |
| + // FileDescriptorInfo. |
| + void Transfer(int id, base::ScopedFD fd); |
| + // Just delegating a lifetime of an FD. This is needed as some FDs |
| + // are transferred to another process without key mapping. |
| + void TransferWithoutMapping(base::ScopedFD fd); |
| + // A vecotr-backed map from registered ID-FD pair. |
| + const base::FileHandleMappingVector& GetMapping() const; |
| + // A GetMapping() variant what adjusts the ID value by |delta|. |
| + // Some environments need this trick. |
| + base::FileHandleMappingVector GetMappingWithIDAdjustment(int delta) const; |
| + |
| + // API for iterating registerd ID-FD pair. |
| + base::PlatformFile GetFDAt(size_t i) const; |
| + int GetIDAt(size_t i) const; |
| + size_t GetMappingSize() const { return mapping_.size(); } |
| + |
| + private: |
| + void AddToMapping(int id, base::PlatformFile fd); |
| + |
| + base::FileHandleMappingVector mapping_; |
| + ScopedVector<base::ScopedFD> owned_descriptors_; |
| }; |
| } |