| Index: media/cast/test/utility/udp_proxy.cc
|
| diff --git a/media/cast/test/utility/udp_proxy.cc b/media/cast/test/utility/udp_proxy.cc
|
| index 05c3b93891aaf93a46fd52e0d490949f12ccf172..9fc3b4a44db21e67f84d069e086c6e0a721c543f 100644
|
| --- a/media/cast/test/utility/udp_proxy.cc
|
| +++ b/media/cast/test/utility/udp_proxy.cc
|
| @@ -2,6 +2,8 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include <stdlib.h>
|
| +
|
| #include "media/cast/test/utility/udp_proxy.h"
|
|
|
| #include "base/logging.h"
|
| @@ -48,7 +50,10 @@ class Buffer : public PacketPipe {
|
| : buffer_size_(0),
|
| max_buffer_size_(buffer_size),
|
| max_megabits_per_second_(max_megabits_per_second),
|
| - weak_factory_(this) {}
|
| + weak_factory_(this) {
|
| + CHECK_GT(max_buffer_size_, 0UL);
|
| + CHECK_GT(max_megabits_per_second, 0);
|
| + }
|
|
|
| virtual void Send(scoped_ptr<transport::Packet> packet) OVERRIDE {
|
| if (packet->size() + buffer_size_ <= max_buffer_size_) {
|
| @@ -95,17 +100,17 @@ scoped_ptr<PacketPipe> NewBuffer(size_t buffer_size, double bandwidth) {
|
|
|
| class RandomDrop : public PacketPipe {
|
| public:
|
| - RandomDrop(double drop_fraction) : drop_fraction_(drop_fraction) {
|
| - }
|
| + RandomDrop(double drop_fraction)
|
| + : drop_fraction_(static_cast<int>(drop_fraction * RAND_MAX)) {}
|
|
|
| virtual void Send(scoped_ptr<transport::Packet> packet) OVERRIDE {
|
| - if (base::RandDouble() >= drop_fraction_) {
|
| + if (rand() > drop_fraction_) {
|
| pipe_->Send(packet.Pass());
|
| }
|
| }
|
|
|
| private:
|
| - double drop_fraction_;
|
| + int drop_fraction_;
|
| };
|
|
|
| scoped_ptr<PacketPipe> NewRandomDrop(double drop_fraction) {
|
|
|