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

Side by Side Diff: content/public/browser/file_descriptor_info.h

Issue 2613803003: Simplifying ContentBrowserClient::GetAdditionalMappedFiles...() (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
OLDNEW
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 "base/files/file.h" 10 #include "base/files/file.h"
11 #include "base/files/memory_mapped_file.h"
11 #include "base/process/launch.h" 12 #include "base/process/launch.h"
12 13
13 namespace content { 14 namespace content {
14 15
15 // FileDescriptorInfo is a collection of file descriptors which is 16 // FileDescriptorInfo is a collection of file descriptors which is needed to
16 // needed to launch a process. You should tell FileDescriptorInfo 17 // launch a process. You should tell FileDescriptorInfo which FDs should be
17 // which FD should be closed and which shouldn't so that it can take care 18 // closed and which shouldn't so that it can take care of the lifetime of FDs.
18 // of the lifetime of FDs.
19 // 19 //
20 // See base/process/launcher.h for more details about launching a 20 // See base/process/launcher.h for more details about launching a process.
21 // process.
22 class FileDescriptorInfo { 21 class FileDescriptorInfo {
23 public: 22 public:
24 virtual ~FileDescriptorInfo() {} 23 virtual ~FileDescriptorInfo() {}
25 24
26 // Add an FD associated with an ID, without delegating the ownerhip 25 // Adds an FD associated with an ID, without delegating the ownerhip of ID.
27 // of ID.
28 virtual void Share(int id, base::PlatformFile fd) = 0; 26 virtual void Share(int id, base::PlatformFile fd) = 0;
29 27
30 // Add an FD associated with an ID, passing the FD ownership to 28 // Similar to Share but also provides a region in that file that should be
29 // read in the launched process (accessible with GetRegionAt()).
30 virtual void ShareWithRegion(int id, base::PlatformFile fd,
jam 2017/01/06 01:28:45 nit: indentation is off per style guide. if the se
31 const base::MemoryMappedFile::Region& region) = 0;
32
33 // Adds an FD associated with an ID, passing the FD ownership to
31 // FileDescriptorInfo. 34 // FileDescriptorInfo.
32 virtual void Transfer(int id, base::ScopedFD fd) = 0; 35 virtual void Transfer(int id, base::ScopedFD fd) = 0;
33 36
34 // A vecotr backed map of registered ID-FD pairs. 37 // A vector backed map of registered ID-FD pairs.
35 virtual const base::FileHandleMappingVector& GetMapping() const = 0; 38 virtual const base::FileHandleMappingVector& GetMapping() const = 0;
36 39
37 // A GetMapping() variant what adjusts the ID value by |delta|. 40 // A GetMapping() variant that adjusts the ID value by |delta|.
38 // Some environments need this trick. 41 // Some environments need this trick.
39 virtual base::FileHandleMappingVector GetMappingWithIDAdjustment( 42 virtual base::FileHandleMappingVector GetMappingWithIDAdjustment(
40 int delta) const = 0; 43 int delta) const = 0;
41 44
42 // API for iterating registered ID-FD pairs. 45 // API for iterating over the registered ID-FD pairs.
43 virtual base::PlatformFile GetFDAt(size_t i) const = 0; 46 virtual base::PlatformFile GetFDAt(size_t i) const = 0;
44 virtual int GetIDAt(size_t i) const = 0; 47 virtual int GetIDAt(size_t i) const = 0;
48 virtual const base::MemoryMappedFile::Region& GetRegionAt(size_t i) const = 0;
45 virtual size_t GetMappingSize() const = 0; 49 virtual size_t GetMappingSize() const = 0;
46 50
47 // True if |this| has an ownership of |file|. 51 // Returns true if |this| has ownership of |file|.
48 virtual bool OwnsFD(base::PlatformFile file) const = 0; 52 virtual bool OwnsFD(base::PlatformFile file) const = 0;
49 // Assuming |OwnsFD(file)|, release the ownership. 53 // Assuming |OwnsFD(file)|, releases the ownership.
50 virtual base::ScopedFD ReleaseFD(base::PlatformFile file) = 0; 54 virtual base::ScopedFD ReleaseFD(base::PlatformFile file) = 0;
51 }; 55 };
52 56
53 } 57 }
54 58
55 #endif // CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_ 59 #endif // CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698