[Android WebView] Fix webview perf bot switchover to use org.chromium.webview_shell...
[chromium-blink-merge.git] / net / quic / crypto / quic_random.cc
blob6b344659c3337092e7a4553befc46059961a0c56
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 void RandBytes(void* data, size_t len) override;
21 uint64 RandUint64() override;
22 void Reseed(const void* additional_entropy, size_t entropy_len) override;
24 private:
25 DefaultRandom() {};
26 ~DefaultRandom() override {}
28 friend struct DefaultSingletonTraits<DefaultRandom>;
29 DISALLOW_COPY_AND_ASSIGN(DefaultRandom);
32 DefaultRandom* DefaultRandom::GetInstance() {
33 return Singleton<DefaultRandom>::get();
36 void DefaultRandom::RandBytes(void* data, size_t len) {
37 crypto::RandBytes(data, len);
40 uint64 DefaultRandom::RandUint64() {
41 uint64 value;
42 RandBytes(&value, sizeof(value));
43 return value;
46 void DefaultRandom::Reseed(const void* additional_entropy, size_t entropy_len) {
47 // No such function exists in crypto/random.h.
50 } // namespace
52 // static
53 QuicRandom* QuicRandom::GetInstance() { return DefaultRandom::GetInstance(); }
55 } // namespace net