Move StrongAlias to rtc_base
It's useful for other parts of WebRTC and there is no real reason why it should be located in net/dcsctp. Bug: None Change-Id: Iccaed4e943e21ddaea8603182d693114b2da9f6b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232606 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Victor Boivie <boivie@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35055}
This commit is contained in:
parent
68dc02b32f
commit
b918230640
@ -10,7 +10,7 @@ import("../../../webrtc.gni")
|
|||||||
|
|
||||||
rtc_source_set("internal_types") {
|
rtc_source_set("internal_types") {
|
||||||
deps = [
|
deps = [
|
||||||
"../public:strong_alias",
|
"../../../rtc_base:rtc_base_approved",
|
||||||
"../public:types",
|
"../public:types",
|
||||||
]
|
]
|
||||||
sources = [ "internal_types.h" ]
|
sources = [ "internal_types.h" ]
|
||||||
|
|||||||
@ -13,31 +13,32 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "net/dcsctp/public/strong_alias.h"
|
|
||||||
#include "net/dcsctp/public/types.h"
|
#include "net/dcsctp/public/types.h"
|
||||||
|
#include "rtc_base/strong_alias.h"
|
||||||
|
|
||||||
namespace dcsctp {
|
namespace dcsctp {
|
||||||
|
|
||||||
// Stream Sequence Number (SSN)
|
// Stream Sequence Number (SSN)
|
||||||
using SSN = StrongAlias<class SSNTag, uint16_t>;
|
using SSN = webrtc::StrongAlias<class SSNTag, uint16_t>;
|
||||||
|
|
||||||
// Message Identifier (MID)
|
// Message Identifier (MID)
|
||||||
using MID = StrongAlias<class MIDTag, uint32_t>;
|
using MID = webrtc::StrongAlias<class MIDTag, uint32_t>;
|
||||||
|
|
||||||
// Fragment Sequence Number (FSN)
|
// Fragment Sequence Number (FSN)
|
||||||
using FSN = StrongAlias<class FSNTag, uint32_t>;
|
using FSN = webrtc::StrongAlias<class FSNTag, uint32_t>;
|
||||||
|
|
||||||
// Transmission Sequence Number (TSN)
|
// Transmission Sequence Number (TSN)
|
||||||
using TSN = StrongAlias<class TSNTag, uint32_t>;
|
using TSN = webrtc::StrongAlias<class TSNTag, uint32_t>;
|
||||||
|
|
||||||
// Reconfiguration Request Sequence Number
|
// Reconfiguration Request Sequence Number
|
||||||
using ReconfigRequestSN = StrongAlias<class ReconfigRequestSNTag, uint32_t>;
|
using ReconfigRequestSN =
|
||||||
|
webrtc::StrongAlias<class ReconfigRequestSNTag, uint32_t>;
|
||||||
|
|
||||||
// Verification Tag, used for packet validation.
|
// Verification Tag, used for packet validation.
|
||||||
using VerificationTag = StrongAlias<class VerificationTagTag, uint32_t>;
|
using VerificationTag = webrtc::StrongAlias<class VerificationTagTag, uint32_t>;
|
||||||
|
|
||||||
// Tie Tag, used as a nonce when connecting.
|
// Tie Tag, used as a nonce when connecting.
|
||||||
using TieTag = StrongAlias<class TieTagTag, uint64_t>;
|
using TieTag = webrtc::StrongAlias<class TieTagTag, uint64_t>;
|
||||||
|
|
||||||
} // namespace dcsctp
|
} // namespace dcsctp
|
||||||
#endif // NET_DCSCTP_COMMON_INTERNAL_TYPES_H_
|
#endif // NET_DCSCTP_COMMON_INTERNAL_TYPES_H_
|
||||||
|
|||||||
@ -26,7 +26,7 @@ namespace dcsctp {
|
|||||||
// need to be unwrapped in order, as long as the difference to the previous one
|
// need to be unwrapped in order, as long as the difference to the previous one
|
||||||
// is not larger than half the range of the wrapped sequence number.
|
// is not larger than half the range of the wrapped sequence number.
|
||||||
//
|
//
|
||||||
// The WrappedType must be a StrongAlias type.
|
// The WrappedType must be a webrtc::StrongAlias type.
|
||||||
template <typename WrappedType>
|
template <typename WrappedType>
|
||||||
class UnwrappedSequenceNumber {
|
class UnwrappedSequenceNumber {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
namespace dcsctp {
|
namespace dcsctp {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using Wrapped = StrongAlias<class WrappedTag, uint16_t>;
|
using Wrapped = webrtc::StrongAlias<class WrappedTag, uint16_t>;
|
||||||
using TestSequence = UnwrappedSequenceNumber<Wrapped>;
|
using TestSequence = UnwrappedSequenceNumber<Wrapped>;
|
||||||
|
|
||||||
TEST(SequenceNumbersTest, SimpleUnwrapping) {
|
TEST(SequenceNumbersTest, SimpleUnwrapping) {
|
||||||
|
|||||||
@ -24,7 +24,7 @@ namespace dcsctp {
|
|||||||
class AnyDataChunk : public Chunk {
|
class AnyDataChunk : public Chunk {
|
||||||
public:
|
public:
|
||||||
// Represents the "immediate ack" flag on DATA/I-DATA, from RFC7053.
|
// Represents the "immediate ack" flag on DATA/I-DATA, from RFC7053.
|
||||||
using ImmediateAckFlag = StrongAlias<class ImmediateAckFlagTag, bool>;
|
using ImmediateAckFlag = webrtc::StrongAlias<class ImmediateAckFlagTag, bool>;
|
||||||
|
|
||||||
// Data chunk options.
|
// Data chunk options.
|
||||||
// See https://tools.ietf.org/html/rfc4960#section-3.3.1
|
// See https://tools.ietf.org/html/rfc4960#section-3.3.1
|
||||||
|
|||||||
@ -34,11 +34,11 @@ namespace dcsctp {
|
|||||||
struct Data {
|
struct Data {
|
||||||
// Indicates if a chunk is the first in a fragmented message and maps to the
|
// Indicates if a chunk is the first in a fragmented message and maps to the
|
||||||
// "beginning" flag in DATA/I-DATA chunk.
|
// "beginning" flag in DATA/I-DATA chunk.
|
||||||
using IsBeginning = StrongAlias<class IsBeginningTag, bool>;
|
using IsBeginning = webrtc::StrongAlias<class IsBeginningTag, bool>;
|
||||||
|
|
||||||
// Indicates if a chunk is the last in a fragmented message and maps to the
|
// Indicates if a chunk is the last in a fragmented message and maps to the
|
||||||
// "end" flag in DATA/I-DATA chunk.
|
// "end" flag in DATA/I-DATA chunk.
|
||||||
using IsEnd = StrongAlias<class IsEndTag, bool>;
|
using IsEnd = webrtc::StrongAlias<class IsEndTag, bool>;
|
||||||
|
|
||||||
Data(StreamID stream_id,
|
Data(StreamID stream_id,
|
||||||
SSN ssn,
|
SSN ssn,
|
||||||
|
|||||||
@ -8,13 +8,9 @@
|
|||||||
|
|
||||||
import("../../../webrtc.gni")
|
import("../../../webrtc.gni")
|
||||||
|
|
||||||
rtc_source_set("strong_alias") {
|
|
||||||
sources = [ "strong_alias.h" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
rtc_source_set("types") {
|
rtc_source_set("types") {
|
||||||
deps = [
|
deps = [
|
||||||
":strong_alias",
|
"../../../rtc_base:rtc_base_approved",
|
||||||
"../../../api:array_view",
|
"../../../api:array_view",
|
||||||
]
|
]
|
||||||
sources = [
|
sources = [
|
||||||
@ -27,7 +23,7 @@ rtc_source_set("types") {
|
|||||||
|
|
||||||
rtc_source_set("socket") {
|
rtc_source_set("socket") {
|
||||||
deps = [
|
deps = [
|
||||||
":strong_alias",
|
"../../../rtc_base:rtc_base_approved",
|
||||||
":types",
|
":types",
|
||||||
"../../../api:array_view",
|
"../../../api:array_view",
|
||||||
"../../../rtc_base",
|
"../../../rtc_base",
|
||||||
@ -91,17 +87,14 @@ if (rtc_include_tests) {
|
|||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
":mocks",
|
":mocks",
|
||||||
":strong_alias",
|
|
||||||
":types",
|
":types",
|
||||||
"../../../rtc_base:checks",
|
"../../../rtc_base:checks",
|
||||||
"../../../rtc_base:gunit_helpers",
|
"../../../rtc_base:gunit_helpers",
|
||||||
"../../../rtc_base:rtc_base_approved",
|
"../../../rtc_base:rtc_base_approved",
|
||||||
"../../../rtc_base/containers:flat_map",
|
|
||||||
"../../../test:test_support",
|
"../../../test:test_support",
|
||||||
]
|
]
|
||||||
sources = [
|
sources = [
|
||||||
"mock_dcsctp_socket_test.cc",
|
"mock_dcsctp_socket_test.cc",
|
||||||
"strong_alias_test.cc",
|
|
||||||
"types_test.cc",
|
"types_test.cc",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "net/dcsctp/public/strong_alias.h"
|
#include "rtc_base/strong_alias.h"
|
||||||
|
|
||||||
namespace dcsctp {
|
namespace dcsctp {
|
||||||
|
|
||||||
@ -101,15 +101,15 @@ enum class HandoverUnreadinessReason : uint32_t {
|
|||||||
// state in which a snapshot of the state can be made by
|
// state in which a snapshot of the state can be made by
|
||||||
// `GetHandoverStateAndClose()`.
|
// `GetHandoverStateAndClose()`.
|
||||||
class HandoverReadinessStatus
|
class HandoverReadinessStatus
|
||||||
: public StrongAlias<class HandoverReadinessStatusTag, uint32_t> {
|
: public webrtc::StrongAlias<class HandoverReadinessStatusTag, uint32_t> {
|
||||||
public:
|
public:
|
||||||
// Constructs an empty `HandoverReadinessStatus` which represents ready state.
|
// Constructs an empty `HandoverReadinessStatus` which represents ready state.
|
||||||
constexpr HandoverReadinessStatus()
|
constexpr HandoverReadinessStatus()
|
||||||
: StrongAlias<class HandoverReadinessStatusTag, uint32_t>(0) {}
|
: webrtc::StrongAlias<class HandoverReadinessStatusTag, uint32_t>(0) {}
|
||||||
// Constructs status object that contains a single reason for not being
|
// Constructs status object that contains a single reason for not being
|
||||||
// handover ready.
|
// handover ready.
|
||||||
constexpr explicit HandoverReadinessStatus(HandoverUnreadinessReason reason)
|
constexpr explicit HandoverReadinessStatus(HandoverUnreadinessReason reason)
|
||||||
: StrongAlias<class HandoverReadinessStatusTag, uint32_t>(
|
: webrtc::StrongAlias<class HandoverReadinessStatusTag, uint32_t>(
|
||||||
static_cast<uint32_t>(reason)) {}
|
static_cast<uint32_t>(reason)) {}
|
||||||
|
|
||||||
// Convenience methods
|
// Convenience methods
|
||||||
|
|||||||
@ -14,28 +14,28 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include "net/dcsctp/public/strong_alias.h"
|
#include "rtc_base/strong_alias.h"
|
||||||
|
|
||||||
namespace dcsctp {
|
namespace dcsctp {
|
||||||
|
|
||||||
// Stream Identifier
|
// Stream Identifier
|
||||||
using StreamID = StrongAlias<class StreamIDTag, uint16_t>;
|
using StreamID = webrtc::StrongAlias<class StreamIDTag, uint16_t>;
|
||||||
|
|
||||||
// Payload Protocol Identifier (PPID)
|
// Payload Protocol Identifier (PPID)
|
||||||
using PPID = StrongAlias<class PPIDTag, uint32_t>;
|
using PPID = webrtc::StrongAlias<class PPIDTag, uint32_t>;
|
||||||
|
|
||||||
// Timeout Identifier
|
// Timeout Identifier
|
||||||
using TimeoutID = StrongAlias<class TimeoutTag, uint64_t>;
|
using TimeoutID = webrtc::StrongAlias<class TimeoutTag, uint64_t>;
|
||||||
|
|
||||||
// Indicates if a message is allowed to be received out-of-order compared to
|
// Indicates if a message is allowed to be received out-of-order compared to
|
||||||
// other messages on the same stream.
|
// other messages on the same stream.
|
||||||
using IsUnordered = StrongAlias<class IsUnorderedTag, bool>;
|
using IsUnordered = webrtc::StrongAlias<class IsUnorderedTag, bool>;
|
||||||
|
|
||||||
// Duration, as milliseconds. Overflows after 24 days.
|
// Duration, as milliseconds. Overflows after 24 days.
|
||||||
class DurationMs : public StrongAlias<class DurationMsTag, int32_t> {
|
class DurationMs : public webrtc::StrongAlias<class DurationMsTag, int32_t> {
|
||||||
public:
|
public:
|
||||||
constexpr explicit DurationMs(const UnderlyingType& v)
|
constexpr explicit DurationMs(const UnderlyingType& v)
|
||||||
: StrongAlias<class DurationMsTag, int32_t>(v) {}
|
: webrtc::StrongAlias<class DurationMsTag, int32_t>(v) {}
|
||||||
|
|
||||||
// Convenience methods for working with time.
|
// Convenience methods for working with time.
|
||||||
constexpr DurationMs& operator+=(DurationMs d) {
|
constexpr DurationMs& operator+=(DurationMs d) {
|
||||||
@ -72,10 +72,10 @@ constexpr inline int32_t operator/(DurationMs lhs, DurationMs rhs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Represents time, in milliseconds since a client-defined epoch.
|
// Represents time, in milliseconds since a client-defined epoch.
|
||||||
class TimeMs : public StrongAlias<class TimeMsTag, int64_t> {
|
class TimeMs : public webrtc::StrongAlias<class TimeMsTag, int64_t> {
|
||||||
public:
|
public:
|
||||||
constexpr explicit TimeMs(const UnderlyingType& v)
|
constexpr explicit TimeMs(const UnderlyingType& v)
|
||||||
: StrongAlias<class TimeMsTag, int64_t>(v) {}
|
: webrtc::StrongAlias<class TimeMsTag, int64_t>(v) {}
|
||||||
|
|
||||||
// Convenience methods for working with time.
|
// Convenience methods for working with time.
|
||||||
constexpr TimeMs& operator+=(DurationMs d) {
|
constexpr TimeMs& operator+=(DurationMs d) {
|
||||||
|
|||||||
@ -17,7 +17,6 @@ rtc_library("timer") {
|
|||||||
"../../../rtc_base/containers:flat_map",
|
"../../../rtc_base/containers:flat_map",
|
||||||
"../../../rtc_base/containers:flat_set",
|
"../../../rtc_base/containers:flat_set",
|
||||||
"../public:socket",
|
"../public:socket",
|
||||||
"../public:strong_alias",
|
|
||||||
"../public:types",
|
"../public:types",
|
||||||
]
|
]
|
||||||
sources = [
|
sources = [
|
||||||
@ -41,7 +40,6 @@ rtc_library("task_queue_timeout") {
|
|||||||
"../../../rtc_base/task_utils:pending_task_safety_flag",
|
"../../../rtc_base/task_utils:pending_task_safety_flag",
|
||||||
"../../../rtc_base/task_utils:to_queued_task",
|
"../../../rtc_base/task_utils:to_queued_task",
|
||||||
"../public:socket",
|
"../public:socket",
|
||||||
"../public:strong_alias",
|
|
||||||
"../public:types",
|
"../public:types",
|
||||||
]
|
]
|
||||||
sources = [
|
sources = [
|
||||||
|
|||||||
@ -21,13 +21,13 @@
|
|||||||
|
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#include "absl/types/optional.h"
|
#include "absl/types/optional.h"
|
||||||
#include "net/dcsctp/public/strong_alias.h"
|
|
||||||
#include "net/dcsctp/public/timeout.h"
|
#include "net/dcsctp/public/timeout.h"
|
||||||
|
#include "rtc_base/strong_alias.h"
|
||||||
|
|
||||||
namespace dcsctp {
|
namespace dcsctp {
|
||||||
|
|
||||||
using TimerID = StrongAlias<class TimerIDTag, uint32_t>;
|
using TimerID = webrtc::StrongAlias<class TimerIDTag, uint32_t>;
|
||||||
using TimerGeneration = StrongAlias<class TimerGenerationTag, uint32_t>;
|
using TimerGeneration = webrtc::StrongAlias<class TimerGenerationTag, uint32_t>;
|
||||||
|
|
||||||
enum class TimerBackoffAlgorithm {
|
enum class TimerBackoffAlgorithm {
|
||||||
// The base duration will be used for any restart.
|
// The base duration will be used for any restart.
|
||||||
|
|||||||
@ -136,6 +136,7 @@ rtc_library("rtc_base_approved") {
|
|||||||
"rate_statistics.h",
|
"rate_statistics.h",
|
||||||
"rate_tracker.cc",
|
"rate_tracker.cc",
|
||||||
"rate_tracker.h",
|
"rate_tracker.h",
|
||||||
|
"strong_alias.h",
|
||||||
"swap_queue.h",
|
"swap_queue.h",
|
||||||
"timestamp_aligner.cc",
|
"timestamp_aligner.cc",
|
||||||
"timestamp_aligner.h",
|
"timestamp_aligner.h",
|
||||||
@ -1371,6 +1372,7 @@ if (rtc_include_tests) {
|
|||||||
"string_utils_unittest.cc",
|
"string_utils_unittest.cc",
|
||||||
"strings/string_builder_unittest.cc",
|
"strings/string_builder_unittest.cc",
|
||||||
"strings/string_format_unittest.cc",
|
"strings/string_format_unittest.cc",
|
||||||
|
"strong_alias_unittest.cc",
|
||||||
"swap_queue_unittest.cc",
|
"swap_queue_unittest.cc",
|
||||||
"thread_annotations_unittest.cc",
|
"thread_annotations_unittest.cc",
|
||||||
"time_utils_unittest.cc",
|
"time_utils_unittest.cc",
|
||||||
@ -1404,6 +1406,7 @@ if (rtc_include_tests) {
|
|||||||
":socket_server",
|
":socket_server",
|
||||||
":stringutils",
|
":stringutils",
|
||||||
":testclient",
|
":testclient",
|
||||||
|
"containers:flat_map",
|
||||||
":threading",
|
":threading",
|
||||||
"../api:array_view",
|
"../api:array_view",
|
||||||
"../api:scoped_refptr",
|
"../api:scoped_refptr",
|
||||||
|
|||||||
@ -8,13 +8,13 @@
|
|||||||
* in the file PATENTS. All contributing project authors may
|
* in the file PATENTS. All contributing project authors may
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
#ifndef NET_DCSCTP_PUBLIC_STRONG_ALIAS_H_
|
#ifndef RTC_BASE_STRONG_ALIAS_H_
|
||||||
#define NET_DCSCTP_PUBLIC_STRONG_ALIAS_H_
|
#define RTC_BASE_STRONG_ALIAS_H_
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace dcsctp {
|
namespace webrtc {
|
||||||
|
|
||||||
// This is a copy of
|
// This is a copy of
|
||||||
// https://source.chromium.org/chromium/chromium/src/+/main:base/types/strong_alias.h
|
// https://source.chromium.org/chromium/chromium/src/+/main:base/types/strong_alias.h
|
||||||
@ -71,6 +71,6 @@ class StrongAlias {
|
|||||||
UnderlyingType value_;
|
UnderlyingType value_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dcsctp
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // NET_DCSCTP_PUBLIC_STRONG_ALIAS_H_
|
#endif // RTC_BASE_STRONG_ALIAS_H_
|
||||||
@ -8,7 +8,7 @@
|
|||||||
* in the file PATENTS. All contributing project authors may
|
* in the file PATENTS. All contributing project authors may
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
#include "net/dcsctp/public/strong_alias.h"
|
#include "rtc_base/strong_alias.h"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -26,7 +26,7 @@
|
|||||||
// but adapted to use WebRTC's includes, remove unit tests that test the ostream
|
// but adapted to use WebRTC's includes, remove unit tests that test the ostream
|
||||||
// operator (it's removed in this port) and other adaptations to pass lint.
|
// operator (it's removed in this port) and other adaptations to pass lint.
|
||||||
|
|
||||||
namespace dcsctp {
|
namespace webrtc {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// For test correctnenss, it's important that these getters return lexically
|
// For test correctnenss, it's important that these getters return lexically
|
||||||
@ -359,4 +359,4 @@ TEST(StrongAliasTest, BooleansAreEvaluatedAsBooleans) {
|
|||||||
EXPECT_TRUE(*happy);
|
EXPECT_TRUE(*happy);
|
||||||
EXPECT_FALSE(*sad);
|
EXPECT_FALSE(*sad);
|
||||||
}
|
}
|
||||||
} // namespace dcsctp
|
} // namespace webrtc
|
||||||
Loading…
x
Reference in New Issue
Block a user