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

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

Issue 585203002: Turn FileDescriptorInfo a collection class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Landing Created 6 years, 2 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 "base/file_descriptor_posix.h" 8 #include "base/files/file.h"
9 #include "base/process/launch.h"
9 10
10 namespace content { 11 namespace content {
11 12
12 // This struct is used when passing files that should be mapped in a process 13 // FileDescriptorInfo is a collection of file descriptors which is
13 // that is been created and allows to associate that file with a specific ID. 14 // needed to launch a process. You should tell FileDescriptorInfo
14 // It also provides a way to know if the actual file descriptor should be 15 // which FD should be closed and which shouldn't so that it can take care
15 // closed with the FileDescriptor.auto_close field. 16 // of the lifetime of FDs.
17 //
18 // See base/process/launcher.h for more details about launching a
19 // process.
20 class FileDescriptorInfo {
21 public:
22 virtual ~FileDescriptorInfo() {}
16 23
17 struct FileDescriptorInfo { 24 // Add an FD associated with an ID, without delegating the ownerhip
18 FileDescriptorInfo(int id, const base::FileDescriptor& file_descriptor) 25 // of ID.
19 : id(id), 26 virtual void Share(int id, base::PlatformFile fd) = 0;
20 fd(file_descriptor) {
21 }
22 27
23 int id; 28 // Add an FD associated with an ID, passing the FD ownership to
24 base::FileDescriptor fd; 29 // FileDescriptorInfo.
30 virtual void Transfer(int id, base::ScopedFD fd) = 0;
31
32 // A vecotr backed map of registered ID-FD pairs.
33 virtual const base::FileHandleMappingVector& GetMapping() const = 0;
34
35 // A GetMapping() variant what adjusts the ID value by |delta|.
36 // Some environments need this trick.
37 virtual base::FileHandleMappingVector GetMappingWithIDAdjustment(
38 int delta) const = 0;
39
40 // API for iterating registered ID-FD pairs.
41 virtual base::PlatformFile GetFDAt(size_t i) const = 0;
42 virtual int GetIDAt(size_t i) const = 0;
43 virtual size_t GetMappingSize() const = 0;
25 }; 44 };
26 45
27 } 46 }
28 47
29 #endif // CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_ 48 #endif // CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_
OLDNEW
« no previous file with comments | « content/public/browser/content_browser_client.h ('k') | content/shell/browser/shell_content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698