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:

committed by
WebRTC LUCI CQ

parent
68dc02b32f
commit
b918230640
@ -10,7 +10,7 @@ import("../../../webrtc.gni")
|
||||
|
||||
rtc_source_set("internal_types") {
|
||||
deps = [
|
||||
"../public:strong_alias",
|
||||
"../../../rtc_base:rtc_base_approved",
|
||||
"../public:types",
|
||||
]
|
||||
sources = [ "internal_types.h" ]
|
||||
|
@ -13,31 +13,32 @@
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
|
||||
#include "net/dcsctp/public/strong_alias.h"
|
||||
#include "net/dcsctp/public/types.h"
|
||||
#include "rtc_base/strong_alias.h"
|
||||
|
||||
namespace dcsctp {
|
||||
|
||||
// Stream Sequence Number (SSN)
|
||||
using SSN = StrongAlias<class SSNTag, uint16_t>;
|
||||
using SSN = webrtc::StrongAlias<class SSNTag, uint16_t>;
|
||||
|
||||
// Message Identifier (MID)
|
||||
using MID = StrongAlias<class MIDTag, uint32_t>;
|
||||
using MID = webrtc::StrongAlias<class MIDTag, uint32_t>;
|
||||
|
||||
// Fragment Sequence Number (FSN)
|
||||
using FSN = StrongAlias<class FSNTag, uint32_t>;
|
||||
using FSN = webrtc::StrongAlias<class FSNTag, uint32_t>;
|
||||
|
||||
// Transmission Sequence Number (TSN)
|
||||
using TSN = StrongAlias<class TSNTag, uint32_t>;
|
||||
using TSN = webrtc::StrongAlias<class TSNTag, uint32_t>;
|
||||
|
||||
// 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.
|
||||
using VerificationTag = StrongAlias<class VerificationTagTag, uint32_t>;
|
||||
using VerificationTag = webrtc::StrongAlias<class VerificationTagTag, uint32_t>;
|
||||
|
||||
// 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
|
||||
#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
|
||||
// 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>
|
||||
class UnwrappedSequenceNumber {
|
||||
public:
|
||||
|
@ -14,7 +14,7 @@
|
||||
namespace dcsctp {
|
||||
namespace {
|
||||
|
||||
using Wrapped = StrongAlias<class WrappedTag, uint16_t>;
|
||||
using Wrapped = webrtc::StrongAlias<class WrappedTag, uint16_t>;
|
||||
using TestSequence = UnwrappedSequenceNumber<Wrapped>;
|
||||
|
||||
TEST(SequenceNumbersTest, SimpleUnwrapping) {
|
||||
|
@ -24,7 +24,7 @@ namespace dcsctp {
|
||||
class AnyDataChunk : public Chunk {
|
||||
public:
|
||||
// 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.
|
||||
// See https://tools.ietf.org/html/rfc4960#section-3.3.1
|
||||
|
@ -34,11 +34,11 @@ namespace dcsctp {
|
||||
struct Data {
|
||||
// Indicates if a chunk is the first in a fragmented message and maps to the
|
||||
// "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
|
||||
// "end" flag in DATA/I-DATA chunk.
|
||||
using IsEnd = StrongAlias<class IsEndTag, bool>;
|
||||
using IsEnd = webrtc::StrongAlias<class IsEndTag, bool>;
|
||||
|
||||
Data(StreamID stream_id,
|
||||
SSN ssn,
|
||||
|
@ -8,13 +8,9 @@
|
||||
|
||||
import("../../../webrtc.gni")
|
||||
|
||||
rtc_source_set("strong_alias") {
|
||||
sources = [ "strong_alias.h" ]
|
||||
}
|
||||
|
||||
rtc_source_set("types") {
|
||||
deps = [
|
||||
":strong_alias",
|
||||
"../../../rtc_base:rtc_base_approved",
|
||||
"../../../api:array_view",
|
||||
]
|
||||
sources = [
|
||||
@ -27,7 +23,7 @@ rtc_source_set("types") {
|
||||
|
||||
rtc_source_set("socket") {
|
||||
deps = [
|
||||
":strong_alias",
|
||||
"../../../rtc_base:rtc_base_approved",
|
||||
":types",
|
||||
"../../../api:array_view",
|
||||
"../../../rtc_base",
|
||||
@ -91,17 +87,14 @@ if (rtc_include_tests) {
|
||||
|
||||
deps = [
|
||||
":mocks",
|
||||
":strong_alias",
|
||||
":types",
|
||||
"../../../rtc_base:checks",
|
||||
"../../../rtc_base:gunit_helpers",
|
||||
"../../../rtc_base:rtc_base_approved",
|
||||
"../../../rtc_base/containers:flat_map",
|
||||
"../../../test:test_support",
|
||||
]
|
||||
sources = [
|
||||
"mock_dcsctp_socket_test.cc",
|
||||
"strong_alias_test.cc",
|
||||
"types_test.cc",
|
||||
]
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "net/dcsctp/public/strong_alias.h"
|
||||
#include "rtc_base/strong_alias.h"
|
||||
|
||||
namespace dcsctp {
|
||||
|
||||
@ -101,15 +101,15 @@ enum class HandoverUnreadinessReason : uint32_t {
|
||||
// state in which a snapshot of the state can be made by
|
||||
// `GetHandoverStateAndClose()`.
|
||||
class HandoverReadinessStatus
|
||||
: public StrongAlias<class HandoverReadinessStatusTag, uint32_t> {
|
||||
: public webrtc::StrongAlias<class HandoverReadinessStatusTag, uint32_t> {
|
||||
public:
|
||||
// Constructs an empty `HandoverReadinessStatus` which represents ready state.
|
||||
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
|
||||
// handover ready.
|
||||
constexpr explicit HandoverReadinessStatus(HandoverUnreadinessReason reason)
|
||||
: StrongAlias<class HandoverReadinessStatusTag, uint32_t>(
|
||||
: webrtc::StrongAlias<class HandoverReadinessStatusTag, uint32_t>(
|
||||
static_cast<uint32_t>(reason)) {}
|
||||
|
||||
// Convenience methods
|
||||
|
@ -14,28 +14,28 @@
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
#include "net/dcsctp/public/strong_alias.h"
|
||||
#include "rtc_base/strong_alias.h"
|
||||
|
||||
namespace dcsctp {
|
||||
|
||||
// Stream Identifier
|
||||
using StreamID = StrongAlias<class StreamIDTag, uint16_t>;
|
||||
using StreamID = webrtc::StrongAlias<class StreamIDTag, uint16_t>;
|
||||
|
||||
// Payload Protocol Identifier (PPID)
|
||||
using PPID = StrongAlias<class PPIDTag, uint32_t>;
|
||||
using PPID = webrtc::StrongAlias<class PPIDTag, uint32_t>;
|
||||
|
||||
// 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
|
||||
// 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.
|
||||
class DurationMs : public StrongAlias<class DurationMsTag, int32_t> {
|
||||
class DurationMs : public webrtc::StrongAlias<class DurationMsTag, int32_t> {
|
||||
public:
|
||||
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.
|
||||
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.
|
||||
class TimeMs : public StrongAlias<class TimeMsTag, int64_t> {
|
||||
class TimeMs : public webrtc::StrongAlias<class TimeMsTag, int64_t> {
|
||||
public:
|
||||
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.
|
||||
constexpr TimeMs& operator+=(DurationMs d) {
|
||||
|
@ -17,7 +17,6 @@ rtc_library("timer") {
|
||||
"../../../rtc_base/containers:flat_map",
|
||||
"../../../rtc_base/containers:flat_set",
|
||||
"../public:socket",
|
||||
"../public:strong_alias",
|
||||
"../public:types",
|
||||
]
|
||||
sources = [
|
||||
@ -41,7 +40,6 @@ rtc_library("task_queue_timeout") {
|
||||
"../../../rtc_base/task_utils:pending_task_safety_flag",
|
||||
"../../../rtc_base/task_utils:to_queued_task",
|
||||
"../public:socket",
|
||||
"../public:strong_alias",
|
||||
"../public:types",
|
||||
]
|
||||
sources = [
|
||||
|
@ -21,13 +21,13 @@
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "net/dcsctp/public/strong_alias.h"
|
||||
#include "net/dcsctp/public/timeout.h"
|
||||
#include "rtc_base/strong_alias.h"
|
||||
|
||||
namespace dcsctp {
|
||||
|
||||
using TimerID = StrongAlias<class TimerIDTag, uint32_t>;
|
||||
using TimerGeneration = StrongAlias<class TimerGenerationTag, uint32_t>;
|
||||
using TimerID = webrtc::StrongAlias<class TimerIDTag, uint32_t>;
|
||||
using TimerGeneration = webrtc::StrongAlias<class TimerGenerationTag, uint32_t>;
|
||||
|
||||
enum class TimerBackoffAlgorithm {
|
||||
// The base duration will be used for any restart.
|
||||
|
@ -136,6 +136,7 @@ rtc_library("rtc_base_approved") {
|
||||
"rate_statistics.h",
|
||||
"rate_tracker.cc",
|
||||
"rate_tracker.h",
|
||||
"strong_alias.h",
|
||||
"swap_queue.h",
|
||||
"timestamp_aligner.cc",
|
||||
"timestamp_aligner.h",
|
||||
@ -1371,6 +1372,7 @@ if (rtc_include_tests) {
|
||||
"string_utils_unittest.cc",
|
||||
"strings/string_builder_unittest.cc",
|
||||
"strings/string_format_unittest.cc",
|
||||
"strong_alias_unittest.cc",
|
||||
"swap_queue_unittest.cc",
|
||||
"thread_annotations_unittest.cc",
|
||||
"time_utils_unittest.cc",
|
||||
@ -1404,6 +1406,7 @@ if (rtc_include_tests) {
|
||||
":socket_server",
|
||||
":stringutils",
|
||||
":testclient",
|
||||
"containers:flat_map",
|
||||
":threading",
|
||||
"../api:array_view",
|
||||
"../api:scoped_refptr",
|
||||
|
@ -8,13 +8,13 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef NET_DCSCTP_PUBLIC_STRONG_ALIAS_H_
|
||||
#define NET_DCSCTP_PUBLIC_STRONG_ALIAS_H_
|
||||
#ifndef RTC_BASE_STRONG_ALIAS_H_
|
||||
#define RTC_BASE_STRONG_ALIAS_H_
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace dcsctp {
|
||||
namespace webrtc {
|
||||
|
||||
// This is a copy of
|
||||
// https://source.chromium.org/chromium/chromium/src/+/main:base/types/strong_alias.h
|
||||
@ -71,6 +71,6 @@ class StrongAlias {
|
||||
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
|
||||
* 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 <map>
|
||||
@ -26,7 +26,7 @@
|
||||
// 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.
|
||||
|
||||
namespace dcsctp {
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
// For test correctnenss, it's important that these getters return lexically
|
||||
@ -359,4 +359,4 @@ TEST(StrongAliasTest, BooleansAreEvaluatedAsBooleans) {
|
||||
EXPECT_TRUE(*happy);
|
||||
EXPECT_FALSE(*sad);
|
||||
}
|
||||
} // namespace dcsctp
|
||||
} // namespace webrtc
|
Reference in New Issue
Block a user