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

Side by Side Diff: base/files/dir_reader_linux.h

Issue 1526253003: Linux: Correctly count the number of open file descriptors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 5 years 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/files/dir_reader_fallback.h ('k') | base/process/process_metrics_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_FILES_DIR_READER_LINUX_H_ 5 #ifndef BASE_FILES_DIR_READER_LINUX_H_
6 #define BASE_FILES_DIR_READER_LINUX_H_ 6 #define BASE_FILES_DIR_READER_LINUX_H_
7 7
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 DPLOG(FATAL) << "getdents64 returned an error: " << errno; 63 DPLOG(FATAL) << "getdents64 returned an error: " << errno;
64 return false; 64 return false;
65 } 65 }
66 size_ = r; 66 size_ = r;
67 offset_ = 0; 67 offset_ = 0;
68 return true; 68 return true;
69 } 69 }
70 70
71 const char* name() const { 71 const char* name() const {
72 if (!size_) 72 if (!size_)
73 return NULL; 73 return nullptr;
74 74
75 const linux_dirent* dirent = 75 const linux_dirent* dirent =
76 reinterpret_cast<const linux_dirent*>(&buf_[offset_]); 76 reinterpret_cast<const linux_dirent*>(&buf_[offset_]);
77 return dirent->d_name; 77 return dirent->d_name;
78 } 78 }
79 79
80 int fd() const { 80 int fd() const {
81 return fd_; 81 return fd_;
82 } 82 }
83 83
84 static bool IsFallback() { 84 static bool IsFallback() {
85 return false; 85 return false;
86 } 86 }
87 87
88 private: 88 private:
89 const int fd_; 89 const int fd_;
90 unsigned char buf_[512]; 90 unsigned char buf_[512];
91 size_t offset_, size_; 91 size_t offset_;
92 size_t size_;
92 93
93 DISALLOW_COPY_AND_ASSIGN(DirReaderLinux); 94 DISALLOW_COPY_AND_ASSIGN(DirReaderLinux);
94 }; 95 };
95 96
96 } // namespace base 97 } // namespace base
97 98
98 #endif // BASE_FILES_DIR_READER_LINUX_H_ 99 #endif // BASE_FILES_DIR_READER_LINUX_H_
OLDNEW
« no previous file with comments | « base/files/dir_reader_fallback.h ('k') | base/process/process_metrics_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698