summaryrefslogtreecommitdiffstats
path: root/media/cast/congestion_control
diff options
context:
space:
mode:
authorpwestin@google.com <pwestin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-09 10:02:15 +0000
committerpwestin@google.com <pwestin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-09 10:02:15 +0000
commitdec0b43f15e7486fed7a2720bdc0dad6e2cfaddc (patch)
tree1486b2998ecaddb6f767a9d43e26341a33ac93bc /media/cast/congestion_control
parent1304307943923d398cc12375a1a66c13334d3b3c (diff)
downloadchromium_src-dec0b43f15e7486fed7a2720bdc0dad6e2cfaddc.zip
chromium_src-dec0b43f15e7486fed7a2720bdc0dad6e2cfaddc.tar.gz
chromium_src-dec0b43f15e7486fed7a2720bdc0dad6e2cfaddc.tar.bz2
Cleanup how we handle the fake clock.
BUG= Review URL: https://codereview.chromium.org/25124002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227712 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/cast/congestion_control')
-rw-r--r--media/cast/congestion_control/congestion_control.cc10
-rw-r--r--media/cast/congestion_control/congestion_control.h13
-rw-r--r--media/cast/congestion_control/congestion_control_unittest.cc6
3 files changed, 12 insertions, 17 deletions
diff --git a/media/cast/congestion_control/congestion_control.cc b/media/cast/congestion_control/congestion_control.cc
index 791842a..35687e7 100644
--- a/media/cast/congestion_control/congestion_control.cc
+++ b/media/cast/congestion_control/congestion_control.cc
@@ -20,16 +20,16 @@ static const int kCongestionControlMaxBitrateIncreasePerMillisecond = 1200;
static const int64 kMaxElapsedTimeMs = kCongestionControlMaxChangeIntervalMs;
-CongestionControl::CongestionControl(float congestion_control_back_off,
+CongestionControl::CongestionControl(base::TickClock* clock,
+ float congestion_control_back_off,
uint32 max_bitrate_configured,
uint32 min_bitrate_configured,
uint32 start_bitrate)
- : congestion_control_back_off_(congestion_control_back_off),
+ : clock_(clock),
+ congestion_control_back_off_(congestion_control_back_off),
max_bitrate_configured_(max_bitrate_configured),
min_bitrate_configured_(min_bitrate_configured),
- bitrate_(start_bitrate),
- default_tick_clock_(new base::DefaultTickClock()),
- clock_(default_tick_clock_.get()) {
+ bitrate_(start_bitrate) {
DCHECK_GT(congestion_control_back_off, 0.0f) << "Invalid config";
DCHECK_LT(congestion_control_back_off, 1.0f) << "Invalid config";
DCHECK_GE(max_bitrate_configured, min_bitrate_configured) << "Invalid config";
diff --git a/media/cast/congestion_control/congestion_control.h b/media/cast/congestion_control/congestion_control.h
index 8da124a..df88151 100644
--- a/media/cast/congestion_control/congestion_control.h
+++ b/media/cast/congestion_control/congestion_control.h
@@ -7,7 +7,6 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
-#include "base/time/default_tick_clock.h"
#include "base/time/tick_clock.h"
#include "base/time/time.h"
@@ -16,7 +15,8 @@ namespace cast {
class CongestionControl {
public:
- CongestionControl(float congestion_control_back_off,
+ CongestionControl(base::TickClock* clock,
+ float congestion_control_back_off,
uint32 max_bitrate_configured,
uint32 min_bitrate_configured,
uint32 start_bitrate);
@@ -30,11 +30,9 @@ class CongestionControl {
// Returns true if the bitrate have changed.
bool OnNack(base::TimeDelta rtt_ms, uint32* new_bitrate);
- void set_clock(base::TickClock* clock) {
- clock_ = clock;
- }
private:
+ base::TickClock* const clock_; // Not owned by this class.
const float congestion_control_back_off_;
const uint32 max_bitrate_configured_;
const uint32 min_bitrate_configured_;
@@ -42,13 +40,10 @@ class CongestionControl {
base::TimeTicks time_last_increase_;
base::TimeTicks time_last_decrease_;
- scoped_ptr<base::TickClock> default_tick_clock_;
- base::TickClock* clock_;
-
DISALLOW_COPY_AND_ASSIGN(CongestionControl);
};
} // namespace cast
} // namespace media
-#endif // MEDIA_CAST_CONGESTION_CONTROL_CONGESTION_CONTROL_H_
+#endif // MEDIA_CAST_CONGESTION_CONTROL_CONGESTION_CONTROL_H_
diff --git a/media/cast/congestion_control/congestion_control_unittest.cc b/media/cast/congestion_control/congestion_control_unittest.cc
index eff0a8c..1fd5efb 100644
--- a/media/cast/congestion_control/congestion_control_unittest.cc
+++ b/media/cast/congestion_control/congestion_control_unittest.cc
@@ -13,7 +13,7 @@ namespace cast {
static const uint32 kMaxBitrateConfigured = 5000000;
static const uint32 kMinBitrateConfigured = 500000;
static const uint32 kStartBitrate = 2000000;
-static const int64 kStartMillisecond = 123456789;
+static const int64 kStartMillisecond = GG_INT64_C(12345678900000);
static const int64 kRttMs = 20;
static const int64 kAckRateMs = 33;
static const int64 kNackRateMs = 10;
@@ -21,13 +21,13 @@ static const int64 kNackRateMs = 10;
class CongestionControlTest : public ::testing::Test {
protected:
CongestionControlTest()
- : congestion_control_(kDefaultCongestionControlBackOff,
+ : congestion_control_(&testing_clock_,
+ kDefaultCongestionControlBackOff,
kMaxBitrateConfigured,
kMinBitrateConfigured,
kStartBitrate) {
testing_clock_.Advance(
base::TimeDelta::FromMilliseconds(kStartMillisecond));
- congestion_control_.set_clock(&testing_clock_);
}
base::SimpleTestTickClock testing_clock_;