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

Unified Diff: media/cast/test/utility/udp_proxy.cc

Issue 308713005: Cast: Synthetic benchmark tool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge + minor fix Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/cast/test/utility/test_util.cc ('k') | media/cast/video_sender/fake_software_video_encoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « media/cast/test/utility/test_util.cc ('k') | media/cast/video_sender/fake_software_video_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698