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

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

Issue 667923003: Standardize usage of virtual/override/final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « net/quic/crypto/quic_crypto_server_config_test.cc ('k') | net/quic/quic_alarm_test.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 "net/quic/crypto/quic_random.h" 5 #include "net/quic/crypto/quic_random.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "crypto/random.h" 9 #include "crypto/random.h"
10 10
11 namespace net { 11 namespace net {
12 12
13 namespace { 13 namespace {
14 14
15 class DefaultRandom : public QuicRandom { 15 class DefaultRandom : public QuicRandom {
16 public: 16 public:
17 static DefaultRandom* GetInstance(); 17 static DefaultRandom* GetInstance();
18 18
19 // QuicRandom implementation 19 // QuicRandom implementation
20 virtual void RandBytes(void* data, size_t len) override; 20 void RandBytes(void* data, size_t len) override;
21 virtual uint64 RandUint64() override; 21 uint64 RandUint64() override;
22 virtual void Reseed(const void* additional_entropy, 22 void Reseed(const void* additional_entropy, size_t entropy_len) override;
23 size_t entropy_len) override;
24 23
25 private: 24 private:
26 DefaultRandom() {}; 25 DefaultRandom() {};
27 virtual ~DefaultRandom() {} 26 ~DefaultRandom() override {}
28 27
29 friend struct DefaultSingletonTraits<DefaultRandom>; 28 friend struct DefaultSingletonTraits<DefaultRandom>;
30 DISALLOW_COPY_AND_ASSIGN(DefaultRandom); 29 DISALLOW_COPY_AND_ASSIGN(DefaultRandom);
31 }; 30 };
32 31
33 DefaultRandom* DefaultRandom::GetInstance() { 32 DefaultRandom* DefaultRandom::GetInstance() {
34 return Singleton<DefaultRandom>::get(); 33 return Singleton<DefaultRandom>::get();
35 } 34 }
36 35
37 void DefaultRandom::RandBytes(void* data, size_t len) { 36 void DefaultRandom::RandBytes(void* data, size_t len) {
38 crypto::RandBytes(data, len); 37 crypto::RandBytes(data, len);
39 } 38 }
40 39
41 uint64 DefaultRandom::RandUint64() { 40 uint64 DefaultRandom::RandUint64() {
42 uint64 value; 41 uint64 value;
43 RandBytes(&value, sizeof(value)); 42 RandBytes(&value, sizeof(value));
44 return value; 43 return value;
45 } 44 }
46 45
47 void DefaultRandom::Reseed(const void* additional_entropy, size_t entropy_len) { 46 void DefaultRandom::Reseed(const void* additional_entropy, size_t entropy_len) {
48 // No such function exists in crypto/random.h. 47 // No such function exists in crypto/random.h.
49 } 48 }
50 49
51 } // namespace 50 } // namespace
52 51
53 // static 52 // static
54 QuicRandom* QuicRandom::GetInstance() { return DefaultRandom::GetInstance(); } 53 QuicRandom* QuicRandom::GetInstance() { return DefaultRandom::GetInstance(); }
55 54
56 } // namespace net 55 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/quic_crypto_server_config_test.cc ('k') | net/quic/quic_alarm_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698