Lots of random cleanups, mostly for native_theme_win.cc:
[chromium-blink-merge.git] / net / quic / crypto / quic_random.cc
blob6f4601306609db562e1ed6a97c220e4727f56bad
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.
5 #include "net/quic/crypto/quic_random.h"
7 #include "base/logging.h"
8 #include "base/memory/singleton.h"
9 #include "crypto/random.h"
11 namespace net {
13 namespace {
15 class DefaultRandom : public QuicRandom {
16 public:
17 static DefaultRandom* GetInstance();
19 // QuicRandom implementation
20 virtual void RandBytes(void* data, size_t len) OVERRIDE;
21 virtual uint64 RandUint64() OVERRIDE;
22 virtual void Reseed(const void* additional_entropy,
23 size_t entropy_len) OVERRIDE;
25 private:
26 DefaultRandom() {};
27 virtual ~DefaultRandom() {}
29 friend struct DefaultSingletonTraits<DefaultRandom>;
30 DISALLOW_COPY_AND_ASSIGN(DefaultRandom);
33 DefaultRandom* DefaultRandom::GetInstance() {
34 return Singleton<DefaultRandom>::get();
37 void DefaultRandom::RandBytes(void* data, size_t len) {
38 crypto::RandBytes(data, len);
41 uint64 DefaultRandom::RandUint64() {
42 uint64 value;
43 RandBytes(&value, sizeof(value));
44 return value;
47 void DefaultRandom::Reseed(const void* additional_entropy, size_t entropy_len) {
48 // No such function exists in crypto/random.h.
51 } // namespace
53 // static
54 QuicRandom* QuicRandom::GetInstance() { return DefaultRandom::GetInstance(); }
56 } // namespace net