Index: net/quic/test_tools/quic_test_utils.h |
diff --git a/net/quic/test_tools/quic_test_utils.h b/net/quic/test_tools/quic_test_utils.h |
index 4c6fcf1c1780771235910d9556ab0bc5bc2f6ae0..6d1de91cdf785d62e8d7ce49db99f995b6d3f8cd 100644 |
--- a/net/quic/test_tools/quic_test_utils.h |
+++ b/net/quic/test_tools/quic_test_utils.h |
@@ -122,6 +122,25 @@ class ValueRestore { |
DISALLOW_COPY_AND_ASSIGN(ValueRestore); |
}; |
+// Simple random number generator used to compute random numbers suitable |
+// for pseudo-randomly dropping packets in tests. It works by computing |
+// the sha1 hash of the current seed, and using the first 64 bits as |
+// the next random number, and the next seed. |
+class SimpleRandom { |
+ public: |
+ SimpleRandom() : seed_(0) {} |
+ |
+ // Returns a random number in the range [0, kuint64max]. |
+ uint64 RandUint64(); |
+ |
+ void set_seed(uint64 seed) { seed_ = seed; } |
+ |
+ private: |
+ uint64 seed_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SimpleRandom); |
+}; |
+ |
class MockFramerVisitor : public QuicFramerVisitorInterface { |
public: |
MockFramerVisitor(); |