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

Side by Side Diff: base/file_descriptor_posix.h

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « base/event_types.h ('k') | base/file_version_info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef BASE_FILE_DESCRIPTOR_POSIX_H_
6 #define BASE_FILE_DESCRIPTOR_POSIX_H_
7
8 #include "base/files/file.h"
9 #include "base/files/scoped_file.h"
10
11 namespace base {
12
13 // -----------------------------------------------------------------------------
14 // We introduct a special structure for file descriptors in order that we are
15 // able to use template specialisation to special-case their handling.
16 //
17 // WARNING: (Chromium only) There are subtleties to consider if serialising
18 // these objects over IPC. See comments in ipc/ipc_message_utils.h
19 // above the template specialisation for this structure.
20 // -----------------------------------------------------------------------------
21 struct FileDescriptor {
22 FileDescriptor() : fd(-1), auto_close(false) {}
23
24 FileDescriptor(int ifd, bool iauto_close) : fd(ifd), auto_close(iauto_close) {
25 }
26
27 FileDescriptor(File file) : fd(file.TakePlatformFile()), auto_close(true) {}
28 explicit FileDescriptor(ScopedFD fd) : fd(fd.release()), auto_close(true) {}
29
30 bool operator==(const FileDescriptor& other) const {
31 return (fd == other.fd && auto_close == other.auto_close);
32 }
33
34 bool operator!=(const FileDescriptor& other) const {
35 return !operator==(other);
36 }
37
38 // A comparison operator so that we can use these as keys in a std::map.
39 bool operator<(const FileDescriptor& other) const {
40 return other.fd < fd;
41 }
42
43 int fd;
44 // If true, this file descriptor should be closed after it has been used. For
45 // example an IPC system might interpret this flag as indicating that the
46 // file descriptor it has been given should be closed after use.
47 bool auto_close;
48 };
49
50 } // namespace base
51
52 #endif // BASE_FILE_DESCRIPTOR_POSIX_H_
OLDNEW
« no previous file with comments | « base/event_types.h ('k') | base/file_version_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698