Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
4 : // Use of this source code is governed by a BSD-style license that can be
5 : // found in the LICENSE file.
6 :
7 : #ifndef BASE_FILE_DESCRIPTOR_POSIX_H_
8 : #define BASE_FILE_DESCRIPTOR_POSIX_H_
9 :
10 : namespace base {
11 :
12 : // -----------------------------------------------------------------------------
13 : // We introduct a special structure for file descriptors in order that we are
14 : // able to use template specialisation to special-case their handling.
15 : //
16 : // WARNING: (Chromium only) There are subtleties to consider if serialising
17 : // these objects over IPC. See comments in chrome/common/ipc_message_utils.h
18 : // above the template specialisation for this structure.
19 : // -----------------------------------------------------------------------------
20 : struct FileDescriptor {
21 465 : FileDescriptor()
22 465 : : fd(-1),
23 465 : auto_close(false) { }
24 :
25 30 : FileDescriptor(int ifd, bool iauto_close)
26 30 : : fd(ifd),
27 30 : auto_close(iauto_close) { }
28 :
29 0 : bool operator==(const FileDescriptor& aOther) const
30 : {
31 0 : return fd == aOther.fd && auto_close == aOther.auto_close;
32 : }
33 :
34 : int fd;
35 : // If true, this file descriptor should be closed after it has been used. For
36 : // example an IPC system might interpret this flag as indicating that the
37 : // file descriptor it has been given should be closed after use.
38 : bool auto_close;
39 : };
40 :
41 : } // namespace base
42 :
43 : #endif // BASE_FILE_DESCRIPTOR_POSIX_H_
|