Don't preload rarely seen large images
[chromium-blink-merge.git] / base / file_descriptor_posix.h
blob376ad39e307addafe0cd7395d8578c3956a3a621
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_
8 #include "base/files/file.h"
9 #include "base/files/scoped_file.h"
11 namespace base {
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.
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) {}
24 FileDescriptor(int ifd, bool iauto_close) : fd(ifd), auto_close(iauto_close) {
27 FileDescriptor(File file) : fd(file.TakePlatformFile()), auto_close(true) {}
28 explicit FileDescriptor(ScopedFD fd) : fd(fd.release()), auto_close(true) {}
30 bool operator==(const FileDescriptor& other) const {
31 return (fd == other.fd && auto_close == other.auto_close);
34 bool operator!=(const FileDescriptor& other) const {
35 return !operator==(other);
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;
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;
50 } // namespace base
52 #endif // BASE_FILE_DESCRIPTOR_POSIX_H_