| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_ | 6 #define CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> |
| 11 |
| 10 #include "base/files/file.h" | 12 #include "base/files/file.h" |
| 11 #include "base/files/memory_mapped_file.h" | 13 #include "base/files/memory_mapped_file.h" |
| 12 #include "base/process/launch.h" | 14 #include "base/process/launch.h" |
| 13 | 15 |
| 14 namespace content { | 16 namespace content { |
| 15 | 17 |
| 16 // FileDescriptorInfo is a collection of file descriptors which is needed to | 18 // FileDescriptorInfo is a collection of file descriptors which is needed to |
| 17 // launch a process. You should tell FileDescriptorInfo which FDs should be | 19 // launch a process. You should tell FileDescriptorInfo which FDs should be |
| 18 // closed and which shouldn't so that it can take care of the lifetime of FDs. | 20 // closed and which shouldn't so that it can take care of the lifetime of FDs. |
| 19 // | 21 // |
| (...skipping 14 matching lines...) Expand all Loading... |
| 34 | 36 |
| 35 // Adds an FD associated with an ID, passing the FD ownership to | 37 // Adds an FD associated with an ID, passing the FD ownership to |
| 36 // FileDescriptorInfo. | 38 // FileDescriptorInfo. |
| 37 virtual void Transfer(int id, base::ScopedFD fd) = 0; | 39 virtual void Transfer(int id, base::ScopedFD fd) = 0; |
| 38 | 40 |
| 39 // A vector backed map of registered ID-FD pairs. | 41 // A vector backed map of registered ID-FD pairs. |
| 40 virtual const base::FileHandleMappingVector& GetMapping() const = 0; | 42 virtual const base::FileHandleMappingVector& GetMapping() const = 0; |
| 41 | 43 |
| 42 // A GetMapping() variant that adjusts the ID value by |delta|. | 44 // A GetMapping() variant that adjusts the ID value by |delta|. |
| 43 // Some environments need this trick. | 45 // Some environments need this trick. |
| 44 virtual base::FileHandleMappingVector GetMappingWithIDAdjustment( | 46 virtual std::unique_ptr<base::FileHandleMappingVector> |
| 45 int delta) const = 0; | 47 GetMappingWithIDAdjustment(int delta) const = 0; |
| 46 | 48 |
| 47 // API for iterating over the registered ID-FD pairs. | 49 // API for iterating over the registered ID-FD pairs. |
| 48 virtual base::PlatformFile GetFDAt(size_t i) const = 0; | 50 virtual base::PlatformFile GetFDAt(size_t i) const = 0; |
| 49 virtual int GetIDAt(size_t i) const = 0; | 51 virtual int GetIDAt(size_t i) const = 0; |
| 50 virtual const base::MemoryMappedFile::Region& GetRegionAt(size_t i) const = 0; | 52 virtual const base::MemoryMappedFile::Region& GetRegionAt(size_t i) const = 0; |
| 51 virtual size_t GetMappingSize() const = 0; | 53 virtual size_t GetMappingSize() const = 0; |
| 52 | 54 |
| 53 // Returns true if |this| has ownership of |file|. | 55 // Returns true if |this| has ownership of |file|. |
| 54 virtual bool OwnsFD(base::PlatformFile file) const = 0; | 56 virtual bool OwnsFD(base::PlatformFile file) const = 0; |
| 55 // Assuming |OwnsFD(file)|, releases the ownership. | 57 // Assuming |OwnsFD(file)|, releases the ownership. |
| 56 virtual base::ScopedFD ReleaseFD(base::PlatformFile file) = 0; | 58 virtual base::ScopedFD ReleaseFD(base::PlatformFile file) = 0; |
| 57 }; | 59 }; |
| 58 | 60 |
| 59 } | 61 } |
| 60 | 62 |
| 61 #endif // CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_ | 63 #endif // CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_ |
| OLD | NEW |