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

Side by Side Diff: base/rand_util_posix.cc

Issue 468253002: Move file_util to base/files/ directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Forgot to add forwarding header to patch Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « base/process/process_metrics_linux.cc ('k') | base/security_unittest.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 #include "base/rand_util.h" 5 #include "base/rand_util.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
11 #include "base/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 14
15 namespace { 15 namespace {
16 16
17 // We keep the file descriptor for /dev/urandom around so we don't need to 17 // We keep the file descriptor for /dev/urandom around so we don't need to
18 // reopen it (which is expensive), and since we may not even be able to reopen 18 // reopen it (which is expensive), and since we may not even be able to reopen
19 // it if we are later put in a sandbox. This class wraps the file descriptor so 19 // it if we are later put in a sandbox. This class wraps the file descriptor so
20 // we can use LazyInstance to handle opening it on the first access. 20 // we can use LazyInstance to handle opening it on the first access.
21 class URandomFd { 21 class URandomFd {
(...skipping 28 matching lines...) Expand all
50 const bool success = 50 const bool success =
51 ReadFromFD(urandom_fd, static_cast<char*>(output), output_length); 51 ReadFromFD(urandom_fd, static_cast<char*>(output), output_length);
52 CHECK(success); 52 CHECK(success);
53 } 53 }
54 54
55 int GetUrandomFD(void) { 55 int GetUrandomFD(void) {
56 return g_urandom_fd.Pointer()->fd(); 56 return g_urandom_fd.Pointer()->fd();
57 } 57 }
58 58
59 } // namespace base 59 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_metrics_linux.cc ('k') | base/security_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698