Chromium Code Reviews| 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 // |
| 20 // See base/process/launcher.h for more details about launching a process. | 22 // See base/process/launcher.h for more details about launching a process. |
| 21 class FileDescriptorInfo { | 23 class FileDescriptorInfo { |
| 22 public: | 24 public: |
| 23 virtual ~FileDescriptorInfo() {} | 25 virtual ~FileDescriptorInfo() {} |
| 24 | 26 #if !defined(OS_WIN) |
|
boliu
2017/01/13 19:00:56
maybe should just compile this out of windows alto
Jay Civelli
2017/01/17 17:50:03
Yep, this is not compiled on Windows.
Removed the
| |
| 25 // Adds an FD associated with an ID, without delegating the ownerhip of ID. | 27 // Adds an FD associated with an ID, without delegating the ownerhip of ID. |
| 26 virtual void Share(int id, base::PlatformFile fd) = 0; | 28 virtual void Share(int id, base::PlatformFile fd) = 0; |
| 27 | 29 |
| 28 // Similar to Share but also provides a region in that file that should be | 30 // Similar to Share but also provides a region in that file that should be |
| 29 // read in the launched process (accessible with GetRegionAt()). | 31 // read in the launched process (accessible with GetRegionAt()). |
| 30 virtual void ShareWithRegion( | 32 virtual void ShareWithRegion( |
| 31 int id, | 33 int id, |
| 32 base::PlatformFile fd, | 34 base::PlatformFile fd, |
| 33 const base::MemoryMappedFile::Region& region) = 0; | 35 const base::MemoryMappedFile::Region& region) = 0; |
| 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; |
| 59 #endif // !defined(OS_WIN) | |
| 57 }; | 60 }; |
| 58 | 61 |
| 59 } | 62 } |
| 60 | 63 |
| 61 #endif // CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_ | 64 #endif // CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_ |
| OLD | NEW |