From 6fae6ec2ee71a92ddd5164a60d483384dff42881 Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Tue, 8 May 2018 10:43:18 +0200 Subject: [PATCH] Moves network unit types to API. This prepares for being able to inject network congestion controllers. And makes it easier to use the units in other parts of the code. Bug: webrtc:9155 Change-Id: Ib8f9c1c97b06d791a01c3376046933d576ae46f9 Reviewed-on: https://webrtc-review.googlesource.com/70201 Reviewed-by: Karl Wiberg Commit-Queue: Sebastian Jansson Cr-Commit-Position: refs/heads/master@{#23168} --- api/BUILD.gn | 1 + .../network_control => api}/units/BUILD.gn | 20 +++++++++---------- .../units/data_rate.cc | 2 +- .../network_control => api}/units/data_rate.h | 11 +++++----- .../units/data_rate_unittest.cc | 2 +- .../units/data_size.cc | 2 +- .../network_control => api}/units/data_size.h | 6 +++--- .../units/data_size_unittest.cc | 2 +- .../units/time_delta.cc | 2 +- .../units/time_delta.h | 6 +++--- .../units/time_delta_unittest.cc | 2 +- .../units/timestamp.cc | 2 +- .../network_control => api}/units/timestamp.h | 8 ++++---- .../units/timestamp_unittest.cc | 2 +- modules/congestion_controller/bbr/BUILD.gn | 14 ++++++------- .../bbr/data_transfer_tracker.h | 7 ++++--- modules/congestion_controller/bbr/rtt_stats.h | 4 ++-- .../bbr/windowed_filter_unittest.cc | 4 ++-- .../network_control/BUILD.gn | 9 ++++----- .../network_control/include/network_types.h | 9 ++++----- rtc_base/timedelta.h | 1 + 21 files changed, 58 insertions(+), 58 deletions(-) rename {modules/congestion_controller/network_control => api}/units/BUILD.gn (75%) rename {modules/congestion_controller/network_control => api}/units/data_rate.cc (90%) rename {modules/congestion_controller/network_control => api}/units/data_rate.h (92%) rename {modules/congestion_controller/network_control => api}/units/data_rate_unittest.cc (98%) rename {modules/congestion_controller/network_control => api}/units/data_size.cc (90%) rename {modules/congestion_controller/network_control => api}/units/data_size.h (93%) rename {modules/congestion_controller/network_control => api}/units/data_size_unittest.cc (97%) rename {modules/congestion_controller/network_control => api}/units/time_delta.cc (91%) rename {modules/congestion_controller/network_control => api}/units/time_delta.h (95%) rename {modules/congestion_controller/network_control => api}/units/time_delta_unittest.cc (98%) rename {modules/congestion_controller/network_control => api}/units/timestamp.cc (92%) rename {modules/congestion_controller/network_control => api}/units/timestamp.h (91%) rename {modules/congestion_controller/network_control => api}/units/timestamp_unittest.cc (97%) diff --git a/api/BUILD.gn b/api/BUILD.gn index c3945846cd..989858f4bd 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -493,6 +493,7 @@ if (rtc_include_tests) { "../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_tests_utils", "../test:test_support", + "units:units_unittests", ] } } diff --git a/modules/congestion_controller/network_control/units/BUILD.gn b/api/units/BUILD.gn similarity index 75% rename from modules/congestion_controller/network_control/units/BUILD.gn rename to api/units/BUILD.gn index 214b4ca61c..7dbddf4e62 100644 --- a/modules/congestion_controller/network_control/units/BUILD.gn +++ b/api/units/BUILD.gn @@ -6,7 +6,7 @@ # in the file PATENTS. All contributing project authors may # be found in the AUTHORS file in the root of the source tree. -import("../../../../webrtc.gni") +import("../../webrtc.gni") rtc_source_set("data_rate") { sources = [ @@ -17,8 +17,8 @@ rtc_source_set("data_rate") { deps = [ ":data_size", ":time_delta", - "../../../../rtc_base:checks", - "../../../../rtc_base:rtc_base_approved", + "../../rtc_base:checks", + "../../rtc_base:rtc_base_approved", ] } @@ -29,8 +29,8 @@ rtc_source_set("data_size") { ] deps = [ - "../../../../rtc_base:checks", - "../../../../rtc_base:rtc_base_approved", + "../../rtc_base:checks", + "../../rtc_base:rtc_base_approved", ] } rtc_source_set("time_delta") { @@ -40,8 +40,8 @@ rtc_source_set("time_delta") { ] deps = [ - "../../../../rtc_base:checks", - "../../../../rtc_base:rtc_base_approved", + "../../rtc_base:checks", + "../../rtc_base:rtc_base_approved", ] } @@ -53,8 +53,8 @@ rtc_source_set("timestamp") { deps = [ ":time_delta", - "../../../../rtc_base:checks", - "../../../../rtc_base:rtc_base_approved", + "../../rtc_base:checks", + "../../rtc_base:rtc_base_approved", ] } @@ -72,7 +72,7 @@ if (rtc_include_tests) { ":data_size", ":time_delta", ":timestamp", - "../../../../test:test_support", + "../../test:test_support", ] } } diff --git a/modules/congestion_controller/network_control/units/data_rate.cc b/api/units/data_rate.cc similarity index 90% rename from modules/congestion_controller/network_control/units/data_rate.cc rename to api/units/data_rate.cc index b59fad4fd4..4e31d51f46 100644 --- a/modules/congestion_controller/network_control/units/data_rate.cc +++ b/api/units/data_rate.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "modules/congestion_controller/network_control/units/data_rate.h" +#include "api/units/data_rate.h" #include "rtc_base/strings/string_builder.h" diff --git a/modules/congestion_controller/network_control/units/data_rate.h b/api/units/data_rate.h similarity index 92% rename from modules/congestion_controller/network_control/units/data_rate.h rename to api/units/data_rate.h index d71e27392d..067b200105 100644 --- a/modules/congestion_controller/network_control/units/data_rate.h +++ b/api/units/data_rate.h @@ -8,9 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef MODULES_CONGESTION_CONTROLLER_NETWORK_CONTROL_UNITS_DATA_RATE_H_ -#define MODULES_CONGESTION_CONTROLLER_NETWORK_CONTROL_UNITS_DATA_RATE_H_ - +#ifndef API_UNITS_DATA_RATE_H_ +#define API_UNITS_DATA_RATE_H_ #include #include #include @@ -18,8 +17,8 @@ #include "rtc_base/checks.h" -#include "modules/congestion_controller/network_control/units/data_size.h" -#include "modules/congestion_controller/network_control/units/time_delta.h" +#include "api/units/data_size.h" +#include "api/units/time_delta.h" namespace webrtc { namespace data_rate_impl { @@ -131,4 +130,4 @@ std::string ToString(const DataRate& value); } // namespace webrtc -#endif // MODULES_CONGESTION_CONTROLLER_NETWORK_CONTROL_UNITS_DATA_RATE_H_ +#endif // API_UNITS_DATA_RATE_H_ diff --git a/modules/congestion_controller/network_control/units/data_rate_unittest.cc b/api/units/data_rate_unittest.cc similarity index 98% rename from modules/congestion_controller/network_control/units/data_rate_unittest.cc rename to api/units/data_rate_unittest.cc index 68375b1463..d4dd192d37 100644 --- a/modules/congestion_controller/network_control/units/data_rate_unittest.cc +++ b/api/units/data_rate_unittest.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "modules/congestion_controller/network_control/units/data_rate.h" +#include "api/units/data_rate.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/congestion_controller/network_control/units/data_size.cc b/api/units/data_size.cc similarity index 90% rename from modules/congestion_controller/network_control/units/data_size.cc rename to api/units/data_size.cc index cd78e894f9..4440f89d03 100644 --- a/modules/congestion_controller/network_control/units/data_size.cc +++ b/api/units/data_size.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "modules/congestion_controller/network_control/units/data_size.h" +#include "api/units/data_size.h" #include "rtc_base/strings/string_builder.h" diff --git a/modules/congestion_controller/network_control/units/data_size.h b/api/units/data_size.h similarity index 93% rename from modules/congestion_controller/network_control/units/data_size.h rename to api/units/data_size.h index fc0b60fa4a..74ab19e664 100644 --- a/modules/congestion_controller/network_control/units/data_size.h +++ b/api/units/data_size.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef MODULES_CONGESTION_CONTROLLER_NETWORK_CONTROL_UNITS_DATA_SIZE_H_ -#define MODULES_CONGESTION_CONTROLLER_NETWORK_CONTROL_UNITS_DATA_SIZE_H_ +#ifndef API_UNITS_DATA_SIZE_H_ +#define API_UNITS_DATA_SIZE_H_ #include #include @@ -102,4 +102,4 @@ std::string ToString(const DataSize& value); } // namespace webrtc -#endif // MODULES_CONGESTION_CONTROLLER_NETWORK_CONTROL_UNITS_DATA_SIZE_H_ +#endif // API_UNITS_DATA_SIZE_H_ diff --git a/modules/congestion_controller/network_control/units/data_size_unittest.cc b/api/units/data_size_unittest.cc similarity index 97% rename from modules/congestion_controller/network_control/units/data_size_unittest.cc rename to api/units/data_size_unittest.cc index febc170f12..35cff018ab 100644 --- a/modules/congestion_controller/network_control/units/data_size_unittest.cc +++ b/api/units/data_size_unittest.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "modules/congestion_controller/network_control/units/data_size.h" +#include "api/units/data_size.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/congestion_controller/network_control/units/time_delta.cc b/api/units/time_delta.cc similarity index 91% rename from modules/congestion_controller/network_control/units/time_delta.cc rename to api/units/time_delta.cc index f43223857d..398df77659 100644 --- a/modules/congestion_controller/network_control/units/time_delta.cc +++ b/api/units/time_delta.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "modules/congestion_controller/network_control/units/time_delta.h" +#include "api/units/time_delta.h" #include "rtc_base/strings/string_builder.h" diff --git a/modules/congestion_controller/network_control/units/time_delta.h b/api/units/time_delta.h similarity index 95% rename from modules/congestion_controller/network_control/units/time_delta.h rename to api/units/time_delta.h index 71859c14e6..826e1a3d0c 100644 --- a/modules/congestion_controller/network_control/units/time_delta.h +++ b/api/units/time_delta.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef MODULES_CONGESTION_CONTROLLER_NETWORK_CONTROL_UNITS_TIME_DELTA_H_ -#define MODULES_CONGESTION_CONTROLLER_NETWORK_CONTROL_UNITS_TIME_DELTA_H_ +#ifndef API_UNITS_TIME_DELTA_H_ +#define API_UNITS_TIME_DELTA_H_ #include #include @@ -142,4 +142,4 @@ inline TimeDelta operator/(const TimeDelta& delta, const int64_t& scalar) { std::string ToString(const TimeDelta& value); } // namespace webrtc -#endif // MODULES_CONGESTION_CONTROLLER_NETWORK_CONTROL_UNITS_TIME_DELTA_H_ +#endif // API_UNITS_TIME_DELTA_H_ diff --git a/modules/congestion_controller/network_control/units/time_delta_unittest.cc b/api/units/time_delta_unittest.cc similarity index 98% rename from modules/congestion_controller/network_control/units/time_delta_unittest.cc rename to api/units/time_delta_unittest.cc index c1384a4ad9..493c6bf4ba 100644 --- a/modules/congestion_controller/network_control/units/time_delta_unittest.cc +++ b/api/units/time_delta_unittest.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "modules/congestion_controller/network_control/units/time_delta.h" +#include "api/units/time_delta.h" #include "test/gtest.h" diff --git a/modules/congestion_controller/network_control/units/timestamp.cc b/api/units/timestamp.cc similarity index 92% rename from modules/congestion_controller/network_control/units/timestamp.cc rename to api/units/timestamp.cc index 40f421df5d..7ae084ca29 100644 --- a/modules/congestion_controller/network_control/units/timestamp.cc +++ b/api/units/timestamp.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "modules/congestion_controller/network_control/units/timestamp.h" +#include "api/units/timestamp.h" #include "rtc_base/strings/string_builder.h" diff --git a/modules/congestion_controller/network_control/units/timestamp.h b/api/units/timestamp.h similarity index 91% rename from modules/congestion_controller/network_control/units/timestamp.h rename to api/units/timestamp.h index 98dcd7c18b..af62b3b490 100644 --- a/modules/congestion_controller/network_control/units/timestamp.h +++ b/api/units/timestamp.h @@ -8,14 +8,14 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef MODULES_CONGESTION_CONTROLLER_NETWORK_CONTROL_UNITS_TIMESTAMP_H_ -#define MODULES_CONGESTION_CONTROLLER_NETWORK_CONTROL_UNITS_TIMESTAMP_H_ +#ifndef API_UNITS_TIMESTAMP_H_ +#define API_UNITS_TIMESTAMP_H_ #include #include #include -#include "modules/congestion_controller/network_control/units/time_delta.h" +#include "api/units/time_delta.h" #include "rtc_base/checks.h" namespace webrtc { @@ -92,4 +92,4 @@ std::string ToString(const Timestamp& value); } // namespace webrtc -#endif // MODULES_CONGESTION_CONTROLLER_NETWORK_CONTROL_UNITS_TIMESTAMP_H_ +#endif // API_UNITS_TIMESTAMP_H_ diff --git a/modules/congestion_controller/network_control/units/timestamp_unittest.cc b/api/units/timestamp_unittest.cc similarity index 97% rename from modules/congestion_controller/network_control/units/timestamp_unittest.cc rename to api/units/timestamp_unittest.cc index a6c45358f6..549a9c8e23 100644 --- a/modules/congestion_controller/network_control/units/timestamp_unittest.cc +++ b/api/units/timestamp_unittest.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "modules/congestion_controller/network_control/units/timestamp.h" +#include "api/units/timestamp.h" #include "test/gtest.h" namespace webrtc { diff --git a/modules/congestion_controller/bbr/BUILD.gn b/modules/congestion_controller/bbr/BUILD.gn index 0299505106..3abebaa36f 100644 --- a/modules/congestion_controller/bbr/BUILD.gn +++ b/modules/congestion_controller/bbr/BUILD.gn @@ -45,11 +45,11 @@ rtc_source_set("data_transfer_tracker") { "data_transfer_tracker.h", ] deps = [ + "../../../api/units:data_size", + "../../../api/units:time_delta", + "../../../api/units:timestamp", "../../../rtc_base:checks", "../../../rtc_base:rtc_base_approved", - "../network_control/units:data_size", - "../network_control/units:time_delta", - "../network_control/units:timestamp", ] } rtc_source_set("rtt_stats") { @@ -59,9 +59,9 @@ rtc_source_set("rtt_stats") { "rtt_stats.h", ] deps = [ + "../../../api/units:time_delta", + "../../../api/units:timestamp", "../../../rtc_base:rtc_base_approved", - "../network_control/units:time_delta", - "../network_control/units:timestamp", ] } rtc_source_set("windowed_filter") { @@ -85,10 +85,10 @@ if (rtc_include_tests) { ":data_transfer_tracker", ":rtt_stats", ":windowed_filter", + "../../../api/units:data_rate", + "../../../api/units:time_delta", "../../../test:test_support", "../network_control:network_control_test", - "../network_control/units:data_rate", - "../network_control/units:time_delta", ] if (!build_with_chromium && is_clang) { # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163). diff --git a/modules/congestion_controller/bbr/data_transfer_tracker.h b/modules/congestion_controller/bbr/data_transfer_tracker.h index 1de8c8a177..25e3997c8a 100644 --- a/modules/congestion_controller/bbr/data_transfer_tracker.h +++ b/modules/congestion_controller/bbr/data_transfer_tracker.h @@ -11,9 +11,10 @@ #define MODULES_CONGESTION_CONTROLLER_BBR_DATA_TRANSFER_TRACKER_H_ #include -#include "modules/congestion_controller/network_control/units/data_size.h" -#include "modules/congestion_controller/network_control/units/time_delta.h" -#include "modules/congestion_controller/network_control/units/timestamp.h" + +#include "api/units/data_size.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" namespace webrtc { namespace bbr { diff --git a/modules/congestion_controller/bbr/rtt_stats.h b/modules/congestion_controller/bbr/rtt_stats.h index 7f20949ed6..bb0bda1ee1 100644 --- a/modules/congestion_controller/bbr/rtt_stats.h +++ b/modules/congestion_controller/bbr/rtt_stats.h @@ -16,8 +16,8 @@ #include #include -#include "modules/congestion_controller/network_control/units/time_delta.h" -#include "modules/congestion_controller/network_control/units/timestamp.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "rtc_base/constructormagic.h" #include "rtc_base/logging.h" diff --git a/modules/congestion_controller/bbr/windowed_filter_unittest.cc b/modules/congestion_controller/bbr/windowed_filter_unittest.cc index e8cd64291b..3eb5177b11 100644 --- a/modules/congestion_controller/bbr/windowed_filter_unittest.cc +++ b/modules/congestion_controller/bbr/windowed_filter_unittest.cc @@ -10,8 +10,8 @@ #include "modules/congestion_controller/bbr/windowed_filter.h" -#include "modules/congestion_controller/network_control/units/data_rate.h" -#include "modules/congestion_controller/network_control/units/time_delta.h" +#include "api/units/data_rate.h" +#include "api/units/time_delta.h" #include "modules/congestion_controller/bbr/rtt_stats.h" #include "test/gtest.h" diff --git a/modules/congestion_controller/network_control/BUILD.gn b/modules/congestion_controller/network_control/BUILD.gn index a9c4d34cbb..190d6624a4 100644 --- a/modules/congestion_controller/network_control/BUILD.gn +++ b/modules/congestion_controller/network_control/BUILD.gn @@ -18,12 +18,12 @@ rtc_static_library("network_control") { deps = [ "../../:module_api", "../../../api:optional", + "../../../api/units:data_rate", + "../../../api/units:data_size", + "../../../api/units:time_delta", + "../../../api/units:timestamp", "../../../rtc_base:checks", "../../../rtc_base:rtc_base_approved", - "units:data_rate", - "units:data_size", - "units:time_delta", - "units:timestamp", ] } @@ -49,7 +49,6 @@ if (rtc_include_tests) { deps = [ ":network_control", "../../../test:test_support", - "units:units_unittests", ] } } diff --git a/modules/congestion_controller/network_control/include/network_types.h b/modules/congestion_controller/network_control/include/network_types.h index 59e9d5f8a9..8a1a16c557 100644 --- a/modules/congestion_controller/network_control/include/network_types.h +++ b/modules/congestion_controller/network_control/include/network_types.h @@ -12,13 +12,12 @@ #define MODULES_CONGESTION_CONTROLLER_NETWORK_CONTROL_INCLUDE_NETWORK_TYPES_H_ #include #include -#include "modules/congestion_controller/network_control/units/data_rate.h" -#include "modules/congestion_controller/network_control/units/data_size.h" -#include "modules/congestion_controller/network_control/units/time_delta.h" -#include "modules/congestion_controller/network_control/units/timestamp.h" +#include "api/units/data_rate.h" +#include "api/units/data_size.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "modules/include/module_common_types.h" - #include "rtc_base/constructormagic.h" namespace webrtc { diff --git a/rtc_base/timedelta.h b/rtc_base/timedelta.h index c8dcf03bd3..70d8877bb1 100644 --- a/rtc_base/timedelta.h +++ b/rtc_base/timedelta.h @@ -23,6 +23,7 @@ // https://code.google.com/p/chromium/codesearch#chromium/src/base/time/time.h namespace rtc { +// TODO(srte): Replace usage of this class with webrtc::TimeDelta. class TimeDelta { public: TimeDelta() : delta_(0) {}