diff options
Diffstat (limited to 'third_party/libwebrtc/net/dcsctp/public')
-rw-r--r-- | third_party/libwebrtc/net/dcsctp/public/BUILD.gn | 2 | ||||
-rw-r--r-- | third_party/libwebrtc/net/dcsctp/public/dcsctp_socket.h | 15 | ||||
-rw-r--r-- | third_party/libwebrtc/net/dcsctp/public/types.h | 10 |
3 files changed, 26 insertions, 1 deletions
diff --git a/third_party/libwebrtc/net/dcsctp/public/BUILD.gn b/third_party/libwebrtc/net/dcsctp/public/BUILD.gn index 6cb289bf5b..8af0fd88c4 100644 --- a/third_party/libwebrtc/net/dcsctp/public/BUILD.gn +++ b/third_party/libwebrtc/net/dcsctp/public/BUILD.gn @@ -11,6 +11,7 @@ import("../../../webrtc.gni") rtc_source_set("types") { deps = [ "../../../api:array_view", + "../../../api/units:time_delta", "../../../rtc_base:strong_alias", ] sources = [ @@ -26,6 +27,7 @@ rtc_source_set("socket") { ":types", "../../../api:array_view", "../../../api/task_queue:task_queue", + "../../../api/units:timestamp", "../../../rtc_base:checks", "../../../rtc_base:strong_alias", ] diff --git a/third_party/libwebrtc/net/dcsctp/public/dcsctp_socket.h b/third_party/libwebrtc/net/dcsctp/public/dcsctp_socket.h index 3cfb8052f8..d0a81eaeb2 100644 --- a/third_party/libwebrtc/net/dcsctp/public/dcsctp_socket.h +++ b/third_party/libwebrtc/net/dcsctp/public/dcsctp_socket.h @@ -18,6 +18,7 @@ #include "absl/types/optional.h" #include "api/array_view.h" #include "api/task_queue/task_queue_base.h" +#include "api/units/timestamp.h" #include "net/dcsctp/public/dcsctp_handover_state.h" #include "net/dcsctp/public/dcsctp_message.h" #include "net/dcsctp/public/dcsctp_options.h" @@ -323,9 +324,21 @@ class DcSctpSocketCallbacks { // Returns the current time in milliseconds (from any epoch). // + // TODO(bugs.webrtc.org/15593): This method is deprecated, see `Now`. + // // Note that it's NOT ALLOWED to call into this library from within this // callback. - virtual TimeMs TimeMillis() = 0; + virtual TimeMs TimeMillis() { return TimeMs(0); } + + // Returns the current time (from any epoch). + // + // This callback will eventually replace `TimeMillis()`. + // + // Note that it's NOT ALLOWED to call into this library from within this + // callback. + virtual webrtc::Timestamp Now() { + return webrtc::Timestamp::Millis(*TimeMillis()); + } // Called when the library needs a random number uniformly distributed between // `low` (inclusive) and `high` (exclusive). The random numbers used by the diff --git a/third_party/libwebrtc/net/dcsctp/public/types.h b/third_party/libwebrtc/net/dcsctp/public/types.h index 7d69875d1a..02e2ce1e5e 100644 --- a/third_party/libwebrtc/net/dcsctp/public/types.h +++ b/third_party/libwebrtc/net/dcsctp/public/types.h @@ -14,6 +14,7 @@ #include <cstdint> #include <limits> +#include "api/units/time_delta.h" #include "rtc_base/strong_alias.h" namespace dcsctp { @@ -41,6 +42,10 @@ class DurationMs : public webrtc::StrongAlias<class DurationMsTag, int32_t> { constexpr explicit DurationMs(const UnderlyingType& v) : webrtc::StrongAlias<class DurationMsTag, int32_t>(v) {} + constexpr explicit DurationMs(webrtc::TimeDelta v) + : webrtc::StrongAlias<class DurationMsTag, int32_t>( + v.IsInfinite() ? InfiniteDuration() : DurationMs(v.ms())) {} + static constexpr DurationMs InfiniteDuration() { return DurationMs(std::numeric_limits<int32_t>::max()); } @@ -58,6 +63,11 @@ class DurationMs : public webrtc::StrongAlias<class DurationMsTag, int32_t> { value_ *= factor; return *this; } + constexpr webrtc::TimeDelta ToTimeDelta() const { + return *this == DurationMs::InfiniteDuration() + ? webrtc::TimeDelta::PlusInfinity() + : webrtc::TimeDelta::Millis(value_); + } }; constexpr inline DurationMs operator+(DurationMs lhs, DurationMs rhs) { |