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

Side by Side Diff: base/rand_util_posix.cc

Issue 89523002: Move Posix file utils to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « base/process/process_handle_linux.cc ('k') | base/sync_socket_posix.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
(...skipping 28 matching lines...) Expand all
39 39
40 } // namespace 40 } // namespace
41 41
42 namespace base { 42 namespace base {
43 43
44 // NOTE: This function must be cryptographically secure. http://crbug.com/140076 44 // NOTE: This function must be cryptographically secure. http://crbug.com/140076
45 uint64 RandUint64() { 45 uint64 RandUint64() {
46 uint64 number; 46 uint64 number;
47 47
48 int urandom_fd = g_urandom_fd.Pointer()->fd(); 48 int urandom_fd = g_urandom_fd.Pointer()->fd();
49 bool success = file_util::ReadFromFD(urandom_fd, 49 bool success = ReadFromFD(urandom_fd, reinterpret_cast<char*>(&number),
50 reinterpret_cast<char*>(&number), 50 sizeof(number));
51 sizeof(number));
52 CHECK(success); 51 CHECK(success);
53 52
54 return number; 53 return number;
55 } 54 }
56 55
57 int GetUrandomFD(void) { 56 int GetUrandomFD(void) {
58 return g_urandom_fd.Pointer()->fd(); 57 return g_urandom_fd.Pointer()->fd();
59 } 58 }
60 59
61 } // namespace base 60 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_handle_linux.cc ('k') | base/sync_socket_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698