Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / public / browser / file_descriptor_info.h
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_
6 #define CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_
7
8 #include "base/files/file.h"
9 #include "base/process/launch.h"
10
11 namespace content {
12
13 // FileDescriptorInfo is a collection of file descriptors which is
14 // needed to launch a process. You should tell FileDescriptorInfo
15 // which FD should be closed and which shouldn't so that it can take care
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() {}
23
24   // Add an FD associated with an ID, without delegating the ownerhip
25   // of ID.
26   virtual void Share(int id, base::PlatformFile fd) = 0;
27
28   // Add an FD associated with an ID, passing the FD ownership to
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;
44 };
45
46 }
47
48 #endif  // CONTENT_PUBLIC_BROWSER_FILE_DESCRIPTOR_INFO_H_