Bug 1928110 - Vendor libwebrtc from 8652855872
Upstream commit: https://webrtc.googlesource.com/src/+/865285587267a7bdbf0a9e680b9544154b37e306 Allow RTC_LOG and RTC_CHECK to accept types that implements absl stringify Bug: None Change-Id: If99eb0e3e285c13d81cd2bbb56163c2c2311d43a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/364201 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43119}
This commit is contained in:
3
third_party/libwebrtc/README.moz-ff-commit
vendored
3
third_party/libwebrtc/README.moz-ff-commit
vendored
@@ -33150,3 +33150,6 @@ d79a1859e0
|
||||
# MOZ_LIBWEBRTC_SRC=/home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
|
||||
# base of lastest vendoring
|
||||
789a54a0c4
|
||||
# MOZ_LIBWEBRTC_SRC=/home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc MOZ_LIBWEBRTC_BRANCH=mozpatches bash dom/media/webrtc/third_party_build/fast-forward-libwebrtc.sh
|
||||
# base of lastest vendoring
|
||||
8652855872
|
||||
|
||||
2
third_party/libwebrtc/README.mozilla
vendored
2
third_party/libwebrtc/README.mozilla
vendored
@@ -22126,3 +22126,5 @@ libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc
|
||||
libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-11-19T17:42:52.476803.
|
||||
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
|
||||
libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-11-19T17:43:47.345510.
|
||||
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
|
||||
libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2024-11-19T17:44:42.458973.
|
||||
|
||||
10
third_party/libwebrtc/moz-patch-stack/0003.patch
vendored
10
third_party/libwebrtc/moz-patch-stack/0003.patch
vendored
@@ -1543,10 +1543,10 @@ index 0073380520..c2dc03efda 100644
|
||||
const bool enable_svc_for_simulcast_;
|
||||
std::optional<SimulcastToSvcConverter> simulcast_to_svc_converter_;
|
||||
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
|
||||
index e1282d7293..ef2a93fbb8 100644
|
||||
index fc2fc093cb..e34460946a 100644
|
||||
--- a/rtc_base/BUILD.gn
|
||||
+++ b/rtc_base/BUILD.gn
|
||||
@@ -444,6 +444,12 @@ rtc_library("logging") {
|
||||
@@ -445,6 +445,12 @@ rtc_library("logging") {
|
||||
"//third_party/abseil-cpp/absl/strings:string_view",
|
||||
]
|
||||
|
||||
@@ -1606,10 +1606,10 @@ index 61a3c667ba..ad2303735e 100644
|
||||
// The list of logging streams currently configured.
|
||||
// Note: we explicitly do not clean this up, because of the uncertain ordering
|
||||
diff --git a/rtc_base/logging.h b/rtc_base/logging.h
|
||||
index 165a83b467..4280f32125 100644
|
||||
index acff13ba12..0095db65fd 100644
|
||||
--- a/rtc_base/logging.h
|
||||
+++ b/rtc_base/logging.h
|
||||
@@ -581,6 +581,12 @@ class LogMessage {
|
||||
@@ -589,6 +589,12 @@ class LogMessage {
|
||||
}
|
||||
#endif // RTC_LOG_ENABLED()
|
||||
|
||||
@@ -1622,7 +1622,7 @@ index 165a83b467..4280f32125 100644
|
||||
private:
|
||||
friend class LogMessageForTesting;
|
||||
|
||||
@@ -636,6 +642,9 @@ class LogMessage {
|
||||
@@ -644,6 +650,9 @@ class LogMessage {
|
||||
|
||||
// The stringbuilder that buffers the formatted message before output
|
||||
rtc::StringBuilder print_stream_;
|
||||
|
||||
@@ -16,7 +16,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/8d832e832ffe51324
|
||||
1 file changed, 13 insertions(+)
|
||||
|
||||
diff --git a/rtc_base/logging.h b/rtc_base/logging.h
|
||||
index 4280f32125..14785920b4 100644
|
||||
index 0095db65fd..adf22d6e07 100644
|
||||
--- a/rtc_base/logging.h
|
||||
+++ b/rtc_base/logging.h
|
||||
@@ -48,6 +48,14 @@
|
||||
@@ -34,7 +34,7 @@ index 4280f32125..14785920b4 100644
|
||||
#include <errno.h>
|
||||
|
||||
#include <atomic>
|
||||
@@ -764,4 +772,9 @@ inline const char* AdaptString(const std::string& str) {
|
||||
@@ -772,4 +780,9 @@ inline const char* AdaptString(const std::string& str) {
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
|
||||
34
third_party/libwebrtc/moz-patch-stack/0032.patch
vendored
34
third_party/libwebrtc/moz-patch-stack/0032.patch
vendored
@@ -1046,7 +1046,7 @@ index 29a7bea9d9..a8994aaa68 100644
|
||||
"/config/external/nspr",
|
||||
"/nsprpub/lib/ds",
|
||||
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
|
||||
index ef2a93fbb8..ec03bc2680 100644
|
||||
index e34460946a..fdabcf6268 100644
|
||||
--- a/rtc_base/BUILD.gn
|
||||
+++ b/rtc_base/BUILD.gn
|
||||
@@ -316,6 +316,7 @@ rtc_library("sample_counter") {
|
||||
@@ -1065,7 +1065,7 @@ index ef2a93fbb8..ec03bc2680 100644
|
||||
|
||||
rtc_library("zero_memory") {
|
||||
visibility = [ "*" ]
|
||||
@@ -833,7 +835,9 @@ rtc_library("rtc_json") {
|
||||
@@ -835,7 +837,9 @@ rtc_library("rtc_json") {
|
||||
":stringutils",
|
||||
"//third_party/abseil-cpp/absl/strings:string_view",
|
||||
]
|
||||
@@ -1075,7 +1075,7 @@ index ef2a93fbb8..ec03bc2680 100644
|
||||
if (rtc_build_json) {
|
||||
deps += [ "//third_party/jsoncpp" ]
|
||||
} else {
|
||||
@@ -1186,6 +1190,7 @@ if (!build_with_chromium) {
|
||||
@@ -1188,6 +1192,7 @@ if (!build_with_chromium) {
|
||||
}
|
||||
|
||||
rtc_library("network") {
|
||||
@@ -1083,7 +1083,7 @@ index ef2a93fbb8..ec03bc2680 100644
|
||||
visibility = [ "*" ]
|
||||
sources = [
|
||||
"network.cc",
|
||||
@@ -1223,16 +1228,20 @@ rtc_library("network") {
|
||||
@@ -1225,16 +1230,20 @@ rtc_library("network") {
|
||||
deps += [ ":win32" ]
|
||||
}
|
||||
}
|
||||
@@ -1104,7 +1104,7 @@ index ef2a93fbb8..ec03bc2680 100644
|
||||
visibility = [ "*" ]
|
||||
sources = [
|
||||
"net_helper.cc",
|
||||
@@ -1243,8 +1252,10 @@ rtc_library("net_helper") {
|
||||
@@ -1245,8 +1254,10 @@ rtc_library("net_helper") {
|
||||
"//third_party/abseil-cpp/absl/strings:string_view",
|
||||
]
|
||||
}
|
||||
@@ -1115,7 +1115,7 @@ index ef2a93fbb8..ec03bc2680 100644
|
||||
visibility = [ "*" ]
|
||||
sources = [
|
||||
"socket_adapters.cc",
|
||||
@@ -1263,6 +1274,7 @@ rtc_library("socket_adapters") {
|
||||
@@ -1265,6 +1276,7 @@ rtc_library("socket_adapters") {
|
||||
"//third_party/abseil-cpp/absl/strings:string_view",
|
||||
]
|
||||
}
|
||||
@@ -1123,7 +1123,7 @@ index ef2a93fbb8..ec03bc2680 100644
|
||||
|
||||
rtc_library("network_route") {
|
||||
sources = [
|
||||
@@ -1277,6 +1289,7 @@ rtc_library("network_route") {
|
||||
@@ -1279,6 +1291,7 @@ rtc_library("network_route") {
|
||||
}
|
||||
|
||||
rtc_library("async_tcp_socket") {
|
||||
@@ -1131,7 +1131,7 @@ index ef2a93fbb8..ec03bc2680 100644
|
||||
sources = [
|
||||
"async_tcp_socket.cc",
|
||||
"async_tcp_socket.h",
|
||||
@@ -1294,8 +1307,10 @@ rtc_library("async_tcp_socket") {
|
||||
@@ -1296,8 +1309,10 @@ rtc_library("async_tcp_socket") {
|
||||
"network:sent_packet",
|
||||
]
|
||||
}
|
||||
@@ -1142,7 +1142,7 @@ index ef2a93fbb8..ec03bc2680 100644
|
||||
visibility = [ "*" ]
|
||||
sources = [
|
||||
"async_udp_socket.cc",
|
||||
@@ -1318,8 +1333,10 @@ rtc_library("async_udp_socket") {
|
||||
@@ -1320,8 +1335,10 @@ rtc_library("async_udp_socket") {
|
||||
"system:no_unique_address",
|
||||
]
|
||||
}
|
||||
@@ -1153,7 +1153,7 @@ index ef2a93fbb8..ec03bc2680 100644
|
||||
visibility = [ "*" ]
|
||||
sources = [
|
||||
"async_packet_socket.cc",
|
||||
@@ -1339,6 +1356,7 @@ rtc_library("async_packet_socket") {
|
||||
@@ -1341,6 +1358,7 @@ rtc_library("async_packet_socket") {
|
||||
"third_party/sigslot",
|
||||
]
|
||||
}
|
||||
@@ -1161,7 +1161,7 @@ index ef2a93fbb8..ec03bc2680 100644
|
||||
|
||||
if (rtc_include_tests) {
|
||||
rtc_library("async_packet_socket_unittest") {
|
||||
@@ -1393,6 +1411,7 @@ rtc_library("data_rate_limiter") {
|
||||
@@ -1395,6 +1413,7 @@ rtc_library("data_rate_limiter") {
|
||||
}
|
||||
|
||||
rtc_library("unique_id_generator") {
|
||||
@@ -1169,7 +1169,7 @@ index ef2a93fbb8..ec03bc2680 100644
|
||||
sources = [
|
||||
"unique_id_generator.cc",
|
||||
"unique_id_generator.h",
|
||||
@@ -1407,6 +1426,7 @@ rtc_library("unique_id_generator") {
|
||||
@@ -1409,6 +1428,7 @@ rtc_library("unique_id_generator") {
|
||||
"//third_party/abseil-cpp/absl/strings:string_view",
|
||||
]
|
||||
}
|
||||
@@ -1177,7 +1177,7 @@ index ef2a93fbb8..ec03bc2680 100644
|
||||
|
||||
rtc_library("crc32") {
|
||||
sources = [
|
||||
@@ -1440,6 +1460,7 @@ rtc_library("stream") {
|
||||
@@ -1442,6 +1462,7 @@ rtc_library("stream") {
|
||||
}
|
||||
|
||||
rtc_library("rtc_certificate_generator") {
|
||||
@@ -1185,7 +1185,7 @@ index ef2a93fbb8..ec03bc2680 100644
|
||||
visibility = [ "*" ]
|
||||
sources = [
|
||||
"rtc_certificate_generator.cc",
|
||||
@@ -1454,6 +1475,7 @@ rtc_library("rtc_certificate_generator") {
|
||||
@@ -1456,6 +1477,7 @@ rtc_library("rtc_certificate_generator") {
|
||||
"//third_party/abseil-cpp/absl/functional:any_invocable",
|
||||
]
|
||||
}
|
||||
@@ -1193,7 +1193,7 @@ index ef2a93fbb8..ec03bc2680 100644
|
||||
|
||||
rtc_source_set("ssl_header") {
|
||||
visibility = [ "*" ]
|
||||
@@ -1510,6 +1532,7 @@ rtc_library("crypto_random") {
|
||||
@@ -1512,6 +1534,7 @@ rtc_library("crypto_random") {
|
||||
}
|
||||
|
||||
rtc_library("ssl") {
|
||||
@@ -1201,7 +1201,7 @@ index ef2a93fbb8..ec03bc2680 100644
|
||||
visibility = [ "*" ]
|
||||
sources = [
|
||||
"openssl_key_pair.cc",
|
||||
@@ -1583,6 +1606,7 @@ rtc_library("ssl") {
|
||||
@@ -1585,6 +1608,7 @@ rtc_library("ssl") {
|
||||
deps += [ ":win32" ]
|
||||
}
|
||||
}
|
||||
@@ -1209,7 +1209,7 @@ index ef2a93fbb8..ec03bc2680 100644
|
||||
|
||||
rtc_library("ssl_adapter") {
|
||||
visibility = [ "*" ]
|
||||
@@ -2192,7 +2216,7 @@ if (rtc_include_tests) {
|
||||
@@ -2194,7 +2218,7 @@ if (rtc_include_tests) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,10 +29,10 @@ index 7e6be706f8..bacc3ca87a 100644
|
||||
rtc_library("task_queue_test") {
|
||||
visibility = [ "*" ]
|
||||
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
|
||||
index ec03bc2680..db74b5a811 100644
|
||||
index fdabcf6268..7311558ab0 100644
|
||||
--- a/rtc_base/BUILD.gn
|
||||
+++ b/rtc_base/BUILD.gn
|
||||
@@ -696,10 +696,14 @@ if (is_mac || is_ios) {
|
||||
@@ -698,10 +698,14 @@ if (is_mac || is_ios) {
|
||||
if (is_win) {
|
||||
rtc_library("rtc_task_queue_win") {
|
||||
visibility = [ "../api/task_queue:default_task_queue_factory" ]
|
||||
|
||||
@@ -13,10 +13,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/4e7b3c485e549e7e3
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
|
||||
index db74b5a811..6f8e2d1d98 100644
|
||||
index 7311558ab0..c4a6e3233d 100644
|
||||
--- a/rtc_base/BUILD.gn
|
||||
+++ b/rtc_base/BUILD.gn
|
||||
@@ -999,6 +999,12 @@ rtc_library("threading") {
|
||||
@@ -1001,6 +1001,12 @@ rtc_library("threading") {
|
||||
"thread.cc",
|
||||
"thread.h",
|
||||
]
|
||||
|
||||
@@ -9,10 +9,10 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ee2f06666bcc6d22c
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
|
||||
index 6f8e2d1d98..c659427577 100644
|
||||
index c4a6e3233d..2be83946ab 100644
|
||||
--- a/rtc_base/BUILD.gn
|
||||
+++ b/rtc_base/BUILD.gn
|
||||
@@ -1619,6 +1619,7 @@ if (!build_with_mozilla) {
|
||||
@@ -1621,6 +1621,7 @@ if (!build_with_mozilla) {
|
||||
}
|
||||
|
||||
rtc_library("ssl_adapter") {
|
||||
@@ -20,7 +20,7 @@ index 6f8e2d1d98..c659427577 100644
|
||||
visibility = [ "*" ]
|
||||
sources = [
|
||||
"openssl_adapter.cc",
|
||||
@@ -1668,6 +1669,7 @@ rtc_library("ssl_adapter") {
|
||||
@@ -1670,6 +1671,7 @@ rtc_library("ssl_adapter") {
|
||||
configs += [ "..:external_ssl_library" ]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -675,7 +675,7 @@ index 706f7bda2b..eb36784430 100644
|
||||
|
||||
if (rtc_build_libsrtp) {
|
||||
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
|
||||
index c659427577..ab656fc85c 100644
|
||||
index 2be83946ab..2e7ddd111e 100644
|
||||
--- a/rtc_base/BUILD.gn
|
||||
+++ b/rtc_base/BUILD.gn
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
2
third_party/libwebrtc/rtc_base/BUILD.gn
vendored
2
third_party/libwebrtc/rtc_base/BUILD.gn
vendored
@@ -443,6 +443,7 @@ rtc_library("logging") {
|
||||
"synchronization:mutex",
|
||||
"//third_party/abseil-cpp/absl/base:core_headers",
|
||||
"//third_party/abseil-cpp/absl/meta:type_traits",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/strings:string_view",
|
||||
]
|
||||
|
||||
@@ -497,6 +498,7 @@ rtc_library("checks") {
|
||||
"system:inline",
|
||||
"system:rtc_export",
|
||||
"//third_party/abseil-cpp/absl/meta:type_traits",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/strings:string_view",
|
||||
]
|
||||
if (build_with_chromium) {
|
||||
|
||||
8
third_party/libwebrtc/rtc_base/DEPS
vendored
8
third_party/libwebrtc/rtc_base/DEPS
vendored
@@ -6,6 +6,10 @@ include_rules = [
|
||||
]
|
||||
|
||||
specific_include_rules = {
|
||||
"checks.h": [
|
||||
"+absl/strings/has_absl_stringify.h",
|
||||
"+absl/strings/str_cat.h",
|
||||
],
|
||||
"protobuf_utils.h": [
|
||||
"+third_party/protobuf",
|
||||
],
|
||||
@@ -18,6 +22,10 @@ specific_include_rules = {
|
||||
"event_tracer\.cc": [
|
||||
"+third_party/perfetto",
|
||||
],
|
||||
"logging.h": [
|
||||
"+absl/strings/has_absl_stringify.h",
|
||||
"+absl/strings/str_cat.h",
|
||||
],
|
||||
"trace_event\.h": [
|
||||
"+third_party/perfetto",
|
||||
],
|
||||
|
||||
8
third_party/libwebrtc/rtc_base/checks.h
vendored
8
third_party/libwebrtc/rtc_base/checks.h
vendored
@@ -55,6 +55,8 @@ RTC_NORETURN void rtc_FatalMessage(const char* file, int line, const char* msg);
|
||||
#include <string>
|
||||
|
||||
#include "absl/meta/type_traits.h"
|
||||
#include "absl/strings/has_absl_stringify.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "rtc_base/numerics/safe_compare.h"
|
||||
@@ -220,6 +222,12 @@ ToStringVal MakeVal(const T& x) {
|
||||
return {ToLogString(x)};
|
||||
}
|
||||
|
||||
template <typename T,
|
||||
std::enable_if_t<absl::HasAbslStringify<T>::value>* = nullptr>
|
||||
ToStringVal MakeVal(const T& x) {
|
||||
return {absl::StrCat(x)};
|
||||
}
|
||||
|
||||
// Ephemeral type that represents the result of the logging << operator.
|
||||
template <typename... Ts>
|
||||
class LogStreamer;
|
||||
|
||||
@@ -10,8 +10,14 @@
|
||||
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
#include "test/gmock.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
namespace {
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
using ::testing::Not;
|
||||
|
||||
TEST(ChecksTest, ExpressionNotEvaluatedWhenCheckPassing) {
|
||||
int i = 0;
|
||||
RTC_CHECK(true) << "i=" << ++i;
|
||||
@@ -19,6 +25,14 @@ TEST(ChecksTest, ExpressionNotEvaluatedWhenCheckPassing) {
|
||||
}
|
||||
|
||||
#if GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
|
||||
|
||||
struct StructWithStringfy {
|
||||
template <typename Sink>
|
||||
friend void AbslStringify(Sink& sink, const StructWithStringfy& /*self*/) {
|
||||
sink.Append("absl-stringify");
|
||||
}
|
||||
};
|
||||
|
||||
TEST(ChecksDeathTest, Checks) {
|
||||
#if RTC_CHECK_MSG_ENABLED
|
||||
EXPECT_DEATH(RTC_FATAL() << "message",
|
||||
@@ -44,6 +58,9 @@ TEST(ChecksDeathTest, Checks) {
|
||||
"# last system error: \\w+\n"
|
||||
"# Check failed: false\n"
|
||||
"# Hi there!");
|
||||
|
||||
StructWithStringfy t;
|
||||
EXPECT_DEATH(RTC_CHECK(false) << t, HasSubstr("absl-stringify"));
|
||||
#else
|
||||
EXPECT_DEATH(RTC_FATAL() << "message",
|
||||
"\n\n#\n"
|
||||
@@ -68,6 +85,12 @@ TEST(ChecksDeathTest, Checks) {
|
||||
"# last system error: \\w+\n"
|
||||
"# Check failed.\n"
|
||||
"# ");
|
||||
|
||||
// Should compile, but shouldn't try to stringify 't'
|
||||
StructWithStringfy t;
|
||||
EXPECT_DEATH(RTC_CHECK(false) << t, Not(HasSubstr("absl-stringify")));
|
||||
#endif // RTC_CHECK_MSG_ENABLED
|
||||
}
|
||||
#endif // GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
|
||||
|
||||
} // namespace
|
||||
|
||||
26
third_party/libwebrtc/rtc_base/logging.h
vendored
26
third_party/libwebrtc/rtc_base/logging.h
vendored
@@ -67,6 +67,8 @@
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "absl/meta/type_traits.h"
|
||||
#include "absl/strings/has_absl_stringify.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/units/timestamp.h"
|
||||
#include "rtc_base/platform_thread_types.h"
|
||||
@@ -348,20 +350,26 @@ ToStringVal MakeVal(const T& x) {
|
||||
return {ToLogString(x)};
|
||||
}
|
||||
|
||||
template <typename T,
|
||||
std::enable_if_t<absl::HasAbslStringify<T>::value>* = nullptr>
|
||||
ToStringVal MakeVal(const T& x) {
|
||||
return {absl::StrCat(x)};
|
||||
}
|
||||
|
||||
// Handle arbitrary types other than the above by falling back to stringstream.
|
||||
// TODO(bugs.webrtc.org/9278): Get rid of this overload when callers don't need
|
||||
// it anymore. No in-tree caller does, but some external callers still do.
|
||||
template <
|
||||
typename T,
|
||||
typename T1 = absl::decay_t<T>,
|
||||
absl::enable_if_t<std::is_class<T1>::value &&
|
||||
!std::is_same<T1, std::string>::value &&
|
||||
!std::is_same<T1, LogMetadata>::value &&
|
||||
!has_to_log_string<T1>::value &&
|
||||
template <typename T,
|
||||
typename T1 = absl::decay_t<T>,
|
||||
std::enable_if_t<std::is_class<T1>::value && //
|
||||
!std::is_same<T1, std::string>::value && //
|
||||
!std::is_same<T1, LogMetadata>::value && //
|
||||
!has_to_log_string<T1>::value && //
|
||||
!absl::HasAbslStringify<T1>::value &&
|
||||
#ifdef WEBRTC_ANDROID
|
||||
!std::is_same<T1, LogMetadataTag>::value &&
|
||||
!std::is_same<T1, LogMetadataTag>::value && //
|
||||
#endif
|
||||
!std::is_same<T1, LogMetadataErr>::value>* = nullptr>
|
||||
!std::is_same<T1, LogMetadataErr>::value>* = nullptr>
|
||||
ToStringVal MakeVal(const T& x) {
|
||||
std::ostringstream os; // no-presubmit-check TODO(webrtc:8982)
|
||||
os << x;
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace rtc {
|
||||
|
||||
namespace {
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
|
||||
#if defined(WEBRTC_WIN)
|
||||
constexpr char kFakeFilePath[] = "some\\path\\myfile.cc";
|
||||
#else
|
||||
@@ -367,6 +369,26 @@ TEST(LogTest, NoopSeverityDoesNotRunStringFormatting) {
|
||||
EXPECT_FALSE(was_called);
|
||||
}
|
||||
|
||||
struct StructWithStringfy {
|
||||
template <typename Sink>
|
||||
friend void AbslStringify(Sink& sink, const StructWithStringfy& /*self*/) {
|
||||
sink.Append("absl-stringify");
|
||||
}
|
||||
};
|
||||
|
||||
TEST(LogTest, UseAbslStringForCustomTypes) {
|
||||
std::string str;
|
||||
LogSinkImpl stream(&str);
|
||||
LogMessage::AddLogToStream(&stream, LS_INFO);
|
||||
StructWithStringfy t;
|
||||
|
||||
RTC_LOG(LS_INFO) << t;
|
||||
|
||||
EXPECT_THAT(str, HasSubstr("absl-stringify"));
|
||||
|
||||
LogMessage::RemoveLogToStream(&stream);
|
||||
}
|
||||
|
||||
struct TestStruct {};
|
||||
std::string ToLogString(TestStruct foo) {
|
||||
return "bar";
|
||||
|
||||
Reference in New Issue
Block a user