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

Side by Side Diff: base/rand_util_nacl.cc

Issue 10795083: Enable some parts of base that were previously disabled in base_untrusted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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/os_compat_nacl.cc ('k') | base/threading/platform_thread_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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/rand_util.h"
6
7 #include <stdlib.h>
8
9 #include "base/lazy_instance.h"
10 #include "base/logging.h"
11 #include "ppapi/c/dev/ppb_crypto_dev.h"
12 #include "ppapi/cpp/module.h"
13
14 namespace {
15
16 class PepperCrypto {
17 public:
18 PepperCrypto() {
19 ppb_crypto_ = reinterpret_cast<const PPB_Crypto_Dev*>(
20 pp::Module::Get()->GetPluginInterface(PPB_CRYPTO_DEV_INTERFACE));
bradn 2012/07/24 23:02:29 Two questions: 1. I had the impression this interf
21 DCHECK(ppb_crypto_);
22 }
23
24 ~PepperCrypto() {
25 }
26
27 void GetRandomBytes(char* buffer, uint32_t num_bytes) {
28 ppb_crypto_->GetRandomBytes(buffer, num_bytes);
29 }
30
31 private:
32 const PPB_Crypto_Dev* ppb_crypto_;
33 };
34
35 base::LazyInstance<PepperCrypto> g_pepper_crypto = LAZY_INSTANCE_INITIALIZER;
36
37 } // namespace
38
39 namespace base {
40
41 uint64 RandUint64() {
42 uint64 result;
43 g_pepper_crypto.Pointer()->GetRandomBytes(
44 reinterpret_cast<char*>(&result), sizeof(result));
45 return result;
46 }
47
48 } // namespace base
OLDNEW
« no previous file with comments | « base/os_compat_nacl.cc ('k') | base/threading/platform_thread_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698