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

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: Fixing android build error 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 to tell FileDescriptorInfo
jam 2014/09/24 20:45:47 nit: You should tell
Hajime Morrita 2014/09/24 23:08:56 Done.
14 // It also provides a way to know if the actual file descriptor should be 15 // which FD should be closed and which isn't so that it can take care
mdempsky 2014/09/24 21:16:45 nit: "and which *shouldn't*"
Hajime Morrita 2014/09/24 23:08:56 Done.
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 and FD associated with an ID, without delegating the ownerhip
jam 2014/09/24 20:45:47 nit: "Add an" also leave a blank line between eac
Hajime Morrita 2014/09/24 23:08:56 Done.
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) { 27 // Add an FD associated with an ID, passing the FD ownership to
21 } 28 // FileDescriptorInfo.
29 virtual void Transfer(int id, base::ScopedFD fd) = 0;
30 // Just delegating a lifetime of an FD. This is needed as some FDs
31 // are transferred to another process without key mapping.
32 virtual void TransferWithoutMapping(base::ScopedFD fd) = 0;
33 // A vecotr-backed map from registered ID-FD pair.
mdempsky 2014/09/24 21:16:44 nit: "A *vector*-backed map *of* registered ID-FD
Hajime Morrita 2014/09/24 23:08:56 Done.
34 virtual const base::FileHandleMappingVector& GetMapping() const = 0;
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;
22 39
23 int id; 40 // API for iterating registerd ID-FD pair.
mdempsky 2014/09/24 21:16:45 nit: "registered" and "pairs"
Hajime Morrita 2014/09/24 23:08:56 Done.
24 base::FileDescriptor fd; 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

Powered by Google App Engine
This is Rietveld 408576698