From f7ffd94ad2741586577da7d5b972a3fe0cd545d0 Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Mon, 16 Apr 2018 11:46:42 +0200 Subject: [PATCH] Removes abbreviated seconds functions on network time classes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Having only one name for seconds makes the interface more consistent. The non-abbreviated was chosen since it's used less frequently than ms() and us(). Bug: None Change-Id: Ia29ff2f9f18f3dddcde9bac4f041695cef2c8f0f Reviewed-on: https://webrtc-review.googlesource.com/69817 Commit-Queue: Sebastian Jansson Reviewed-by: Björn Terelius Reviewed-by: Benjamin Wright Cr-Commit-Position: refs/heads/master@{#22877} --- .../goog_cc/goog_cc_network_control.cc | 2 +- .../network_control/units/data_rate_unittest.cc | 2 +- .../network_control/units/time_delta.h | 5 ++--- .../network_control/units/time_delta_unittest.cc | 12 ++++++------ .../network_control/units/timestamp.h | 5 ++--- .../network_control/units/timestamp_unittest.cc | 10 +++++----- 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc index 733f667e41..89aa88a976 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc @@ -429,7 +429,7 @@ PacerConfig GoogCcNetworkController::UpdatePacingRates(Timestamp at_time) { DataRate padding_rate = std::min(max_padding_rate_, last_bandwidth_); PacerConfig msg; msg.at_time = at_time; - msg.time_window = TimeDelta::s(1); + msg.time_window = TimeDelta::seconds(1); msg.data_window = pacing_rate * msg.time_window; msg.pad_window = padding_rate * msg.time_window; return msg; diff --git a/modules/congestion_controller/network_control/units/data_rate_unittest.cc b/modules/congestion_controller/network_control/units/data_rate_unittest.cc index f3c5bd5989..abc339fdd4 100644 --- a/modules/congestion_controller/network_control/units/data_rate_unittest.cc +++ b/modules/congestion_controller/network_control/units/data_rate_unittest.cc @@ -83,7 +83,7 @@ TEST(UnitConversionTest, DataRateAndDataSizeAndTimeDelta) { EXPECT_EQ((delta_a * rate_b).bytes(), kValueA * kValueB); EXPECT_EQ((rate_b * delta_a).bytes(), kValueA * kValueB); EXPECT_EQ((size_c / delta_a).bytes_per_second(), kValueC / kValueA); - EXPECT_EQ((size_c / rate_b).s(), kValueC / kValueB); + EXPECT_EQ((size_c / rate_b).seconds(), kValueC / kValueB); } #if GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) diff --git a/modules/congestion_controller/network_control/units/time_delta.h b/modules/congestion_controller/network_control/units/time_delta.h index 3a54e002b9..7c570c7c34 100644 --- a/modules/congestion_controller/network_control/units/time_delta.h +++ b/modules/congestion_controller/network_control/units/time_delta.h @@ -43,8 +43,7 @@ class TimeDelta { static TimeDelta MinusInfinity() { return TimeDelta(timedelta_impl::kMinusInfinityVal); } - static TimeDelta seconds(int64_t seconds) { return TimeDelta::s(seconds); } - static TimeDelta s(int64_t seconds) { + static TimeDelta seconds(int64_t seconds) { return TimeDelta::us(seconds * 1000000); } static TimeDelta ms(int64_t milliseconds) { @@ -57,7 +56,7 @@ class TimeDelta { RTC_DCHECK(microseconds != timedelta_impl::kSignedNotInitializedVal); return TimeDelta(microseconds); } - int64_t s() const { + int64_t seconds() const { return (us() + (us() >= 0 ? 500000 : -500000)) / 1000000; } int64_t ms() const { return (us() + (us() >= 0 ? 500 : -500)) / 1000; } diff --git a/modules/congestion_controller/network_control/units/time_delta_unittest.cc b/modules/congestion_controller/network_control/units/time_delta_unittest.cc index d771cd26a8..c1384a4ad9 100644 --- a/modules/congestion_controller/network_control/units/time_delta_unittest.cc +++ b/modules/congestion_controller/network_control/units/time_delta_unittest.cc @@ -21,21 +21,21 @@ TEST(TimeDeltaTest, GetBackSameValues) { int64_t value = kValue * sign; EXPECT_EQ(TimeDelta::ms(value).ms(), value); EXPECT_EQ(TimeDelta::us(value).us(), value); - EXPECT_EQ(TimeDelta::s(value).s(), value); - EXPECT_EQ(TimeDelta::seconds(value).s(), value); + EXPECT_EQ(TimeDelta::seconds(value).seconds(), value); + EXPECT_EQ(TimeDelta::seconds(value).seconds(), value); } EXPECT_EQ(TimeDelta::Zero().us(), 0); } TEST(TimeDeltaTest, GetDifferentPrefix) { const int64_t kValue = 3000000; - EXPECT_EQ(TimeDelta::us(kValue).s(), kValue / 1000000); - EXPECT_EQ(TimeDelta::ms(kValue).s(), kValue / 1000); + EXPECT_EQ(TimeDelta::us(kValue).seconds(), kValue / 1000000); + EXPECT_EQ(TimeDelta::ms(kValue).seconds(), kValue / 1000); EXPECT_EQ(TimeDelta::us(kValue).ms(), kValue / 1000); EXPECT_EQ(TimeDelta::ms(kValue).us(), kValue * 1000); - EXPECT_EQ(TimeDelta::s(kValue).ms(), kValue * 1000); - EXPECT_EQ(TimeDelta::s(kValue).us(), kValue * 1000000); + EXPECT_EQ(TimeDelta::seconds(kValue).ms(), kValue * 1000); + EXPECT_EQ(TimeDelta::seconds(kValue).us(), kValue * 1000000); } TEST(TimeDeltaTest, IdentityChecks) { diff --git a/modules/congestion_controller/network_control/units/timestamp.h b/modules/congestion_controller/network_control/units/timestamp.h index ae22a68848..59e8fe69ae 100644 --- a/modules/congestion_controller/network_control/units/timestamp.h +++ b/modules/congestion_controller/network_control/units/timestamp.h @@ -36,8 +36,7 @@ class Timestamp { static Timestamp Infinity() { return Timestamp(timestamp_impl::kPlusInfinityVal); } - static Timestamp seconds(int64_t seconds) { return Timestamp::s(seconds); } - static Timestamp s(int64_t seconds) { + static Timestamp seconds(int64_t seconds) { return Timestamp::us(seconds * 1000000); } static Timestamp ms(int64_t millis) { return Timestamp::us(millis * 1000); } @@ -45,7 +44,7 @@ class Timestamp { RTC_DCHECK_GE(micros, 0); return Timestamp(micros); } - int64_t s() const { return (us() + 500000) / 1000000; } + int64_t seconds() const { return (us() + 500000) / 1000000; } int64_t ms() const { return (us() + 500) / 1000; } int64_t us() const { RTC_DCHECK(IsFinite()); diff --git a/modules/congestion_controller/network_control/units/timestamp_unittest.cc b/modules/congestion_controller/network_control/units/timestamp_unittest.cc index eeddc7da2b..d12a732378 100644 --- a/modules/congestion_controller/network_control/units/timestamp_unittest.cc +++ b/modules/congestion_controller/network_control/units/timestamp_unittest.cc @@ -17,18 +17,18 @@ TEST(TimestampTest, GetBackSameValues) { const int64_t kValue = 499; EXPECT_EQ(Timestamp::ms(kValue).ms(), kValue); EXPECT_EQ(Timestamp::us(kValue).us(), kValue); - EXPECT_EQ(Timestamp::s(kValue).s(), kValue); + EXPECT_EQ(Timestamp::seconds(kValue).seconds(), kValue); } TEST(TimestampTest, GetDifferentPrefix) { const int64_t kValue = 3000000; - EXPECT_EQ(Timestamp::us(kValue).s(), kValue / 1000000); - EXPECT_EQ(Timestamp::ms(kValue).s(), kValue / 1000); + EXPECT_EQ(Timestamp::us(kValue).seconds(), kValue / 1000000); + EXPECT_EQ(Timestamp::ms(kValue).seconds(), kValue / 1000); EXPECT_EQ(Timestamp::us(kValue).ms(), kValue / 1000); EXPECT_EQ(Timestamp::ms(kValue).us(), kValue * 1000); - EXPECT_EQ(Timestamp::s(kValue).ms(), kValue * 1000); - EXPECT_EQ(Timestamp::s(kValue).us(), kValue * 1000000); + EXPECT_EQ(Timestamp::seconds(kValue).ms(), kValue * 1000); + EXPECT_EQ(Timestamp::seconds(kValue).us(), kValue * 1000000); } TEST(TimestampTest, IdentityChecks) {