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

Side by Side Diff: net/quic/crypto/quic_random.cc

Issue 11476031: Add the QuicRandom interface with a default implementation that is (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Export QuicRandom for net_unittesrs Created 8 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 | « net/quic/crypto/quic_random.h ('k') | net/quic/crypto/quic_random_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
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 "net/quic/crypto/quic_random.h"
6
7 #include "base/logging.h"
8 #include "base/memory/singleton.h"
9 #include "crypto/random.h"
10
11 namespace net {
12
13 namespace {
14
15 class DefaultRandom : public QuicRandom {
16 public:
17 static DefaultRandom* GetInstance();
18
19 // QuicRandom implementation
20 virtual void RandBytes(void* data, size_t len);
21 virtual uint64 RandUint64();
22 virtual void Reseed(const void* additional_entropy, size_t entropy_len);
23
24 private:
25 DefaultRandom();
26 virtual ~DefaultRandom() {}
27
28 friend struct DefaultSingletonTraits<DefaultRandom>;
29 DISALLOW_COPY_AND_ASSIGN(DefaultRandom);
30 };
31
32 DefaultRandom* DefaultRandom::GetInstance() {
33 return Singleton<DefaultRandom>::get();
34 }
35
36 void DefaultRandom::RandBytes(void* data, size_t len) {
37 crypto::RandBytes(data, len);
38 }
39
40 uint64 DefaultRandom::RandUint64() {
41 uint64 value;
42 RandBytes(&value, sizeof(value));
43 return value;
44 }
45
46 void DefaultRandom::Reseed(const void* additional_entropy, size_t entropy_len) {
47 // No such function exists in crypto/random.h.
48 }
49
50 DefaultRandom::DefaultRandom() {
51 }
52
53 } // namespace
54
55 // static
56 QuicRandom* QuicRandom::GetInstance() {
57 return DefaultRandom::GetInstance();
58 }
59
60 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/quic_random.h ('k') | net/quic/crypto/quic_random_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698