| OLD | NEW |
| 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 #ifndef NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ | 5 #ifndef NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ |
| 6 #define NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ | 6 #define NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ |
| 7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 8 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" |
| 9 #include "net/quic/crypto/quic_random.h" | 13 #include "net/quic/crypto/quic_random.h" |
| 10 | 14 |
| 11 namespace net { | 15 namespace net { |
| 12 namespace test { | 16 namespace test { |
| 13 | 17 |
| 14 class MockRandom : public QuicRandom { | 18 class MockRandom : public QuicRandom { |
| 15 public: | 19 public: |
| 16 // Initializes base_ to 0xDEADBEEF. | 20 // Initializes base_ to 0xDEADBEEF. |
| 17 MockRandom(); | 21 MockRandom(); |
| 18 explicit MockRandom(uint32 base); | 22 explicit MockRandom(uint32_t base); |
| 19 | 23 |
| 20 // QuicRandom: | 24 // QuicRandom: |
| 21 // Fills the |data| buffer with a repeating byte, initially 'r'. | 25 // Fills the |data| buffer with a repeating byte, initially 'r'. |
| 22 void RandBytes(void* data, size_t len) override; | 26 void RandBytes(void* data, size_t len) override; |
| 23 // Returns base + the current increment. | 27 // Returns base + the current increment. |
| 24 uint64 RandUint64() override; | 28 uint64_t RandUint64() override; |
| 25 // Does nothing. | 29 // Does nothing. |
| 26 void Reseed(const void* additional_entropy, size_t entropy_len) override; | 30 void Reseed(const void* additional_entropy, size_t entropy_len) override; |
| 27 | 31 |
| 28 // ChangeValue increments |increment_|. This causes the value returned by | 32 // ChangeValue increments |increment_|. This causes the value returned by |
| 29 // |RandUint64| and the byte that |RandBytes| fills with, to change. | 33 // |RandUint64| and the byte that |RandBytes| fills with, to change. |
| 30 void ChangeValue(); | 34 void ChangeValue(); |
| 31 | 35 |
| 32 private: | 36 private: |
| 33 uint32 base_; | 37 uint32_t base_; |
| 34 uint8 increment_; | 38 uint8_t increment_; |
| 35 | 39 |
| 36 DISALLOW_COPY_AND_ASSIGN(MockRandom); | 40 DISALLOW_COPY_AND_ASSIGN(MockRandom); |
| 37 }; | 41 }; |
| 38 | 42 |
| 39 } // namespace test | 43 } // namespace test |
| 40 } // namespace net | 44 } // namespace net |
| 41 | 45 |
| 42 #endif // NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ | 46 #endif // NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ |
| OLD | NEW |