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

Side by Side Diff: sandbox/linux/services/proc_util.cc

Issue 1849323003: Convert //sandbox to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixup nonsfi_sandbox_unittest.cc Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "sandbox/linux/services/proc_util.h" 5 #include "sandbox/linux/services/proc_util.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <string.h> 10 #include <string.h>
11 #include <sys/stat.h> 11 #include <sys/stat.h>
12 #include <sys/types.h> 12 #include <sys/types.h>
13 13
14 #include <memory>
15
14 #include "base/logging.h" 16 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/posix/eintr_wrapper.h" 17 #include "base/posix/eintr_wrapper.h"
17 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
18 19
19 namespace sandbox { 20 namespace sandbox {
20 namespace { 21 namespace {
21 22
22 struct DIRCloser { 23 struct DIRCloser {
23 void operator()(DIR* d) const { 24 void operator()(DIR* d) const {
24 DCHECK(d); 25 DCHECK(d);
25 PCHECK(0 == closedir(d)); 26 PCHECK(0 == closedir(d));
26 } 27 }
27 }; 28 };
28 29
29 typedef scoped_ptr<DIR, DIRCloser> ScopedDIR; 30 typedef std::unique_ptr<DIR, DIRCloser> ScopedDIR;
30 31
31 base::ScopedFD OpenDirectory(const char* path) { 32 base::ScopedFD OpenDirectory(const char* path) {
32 DCHECK(path); 33 DCHECK(path);
33 base::ScopedFD directory_fd( 34 base::ScopedFD directory_fd(
34 HANDLE_EINTR(open(path, O_RDONLY | O_DIRECTORY | O_CLOEXEC))); 35 HANDLE_EINTR(open(path, O_RDONLY | O_DIRECTORY | O_CLOEXEC)));
35 PCHECK(directory_fd.is_valid()); 36 PCHECK(directory_fd.is_valid());
36 return directory_fd; 37 return directory_fd;
37 } 38 }
38 39
39 } // namespace 40 } // namespace
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 HANDLE_EINTR(open("/proc/", O_DIRECTORY | O_RDONLY | O_CLOEXEC))); 111 HANDLE_EINTR(open("/proc/", O_DIRECTORY | O_RDONLY | O_CLOEXEC)));
111 return HasOpenDirectory(proc_fd.get()); 112 return HasOpenDirectory(proc_fd.get());
112 } 113 }
113 114
114 // static 115 // static
115 base::ScopedFD ProcUtil::OpenProc() { 116 base::ScopedFD ProcUtil::OpenProc() {
116 return OpenDirectory("/proc/"); 117 return OpenDirectory("/proc/");
117 } 118 }
118 119
119 } // namespace sandbox 120 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/linux/services/namespace_sandbox_unittest.cc ('k') | sandbox/linux/services/thread_helpers_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698