1 // Copyright (c) 2006-2009 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.
5 #ifndef BASE_FILE_DESCRIPTOR_POSIX_H_
6 #define BASE_FILE_DESCRIPTOR_POSIX_H_
11 // -----------------------------------------------------------------------------
12 // We introduct a special structure for file descriptors in order that we are
13 // able to use template specialisation to special-case their handling.
15 // WARNING: (Chromium only) There are subtleties to consider if serialising
16 // these objects over IPC. See comments in ipc/ipc_message_utils.h
17 // above the template specialisation for this structure.
18 // -----------------------------------------------------------------------------
19 struct FileDescriptor
{
24 FileDescriptor(int ifd
, bool iauto_close
)
26 auto_close(iauto_close
) { }
28 bool operator==(const FileDescriptor
& other
) const {
29 return (fd
== other
.fd
&& auto_close
== other
.auto_close
);
32 // A comparison operator so that we can use these as keys in a std::map.
33 bool operator<(const FileDescriptor
& other
) const {
38 // If true, this file descriptor should be closed after it has been used. For
39 // example an IPC system might interpret this flag as indicating that the
40 // file descriptor it has been given should be closed after use.
46 #endif // BASE_FILE_DESCRIPTOR_POSIX_H_