Format /rtc_base

git ls-files | grep -e  "\(\.h\|\.cc\)$" | grep -e  "^rtc_base/" | xargs clang-format -i ; git cl format
after landing: add to .git-blame-ignore-revs

Bug: webrtc:15082
Change-Id: I152228f7c7926adf95d2f3fbbe4178556fd75d0d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/302061
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39914}
This commit is contained in:
Jared Siskin 2023-04-19 17:35:28 -07:00 committed by WebRTC LUCI CQ
parent 6f86f6af00
commit 802e8e5fdb
26 changed files with 584 additions and 555 deletions

View file

@ -152,29 +152,29 @@ void AsyncResolver::Start(const SocketAddress& addr, int family) {
RTC_DCHECK_RUN_ON(&sequence_checker_);
RTC_DCHECK(!destroy_called_);
addr_ = addr;
auto thread_function =
[this, addr, family, caller_task_queue = webrtc::TaskQueueBase::Current(),
state = state_] {
std::vector<IPAddress> addresses;
int error = ResolveHostname(addr.hostname(), family, &addresses);
webrtc::MutexLock lock(&state->mutex);
if (state->status == State::Status::kLive) {
caller_task_queue->PostTask(
[this, error, addresses = std::move(addresses), state] {
bool live;
{
// ResolveDone can lead to instance destruction, so make sure
// we don't deadlock.
webrtc::MutexLock lock(&state->mutex);
live = state->status == State::Status::kLive;
}
if (live) {
RTC_DCHECK_RUN_ON(&sequence_checker_);
ResolveDone(std::move(addresses), error);
}
});
}
};
auto thread_function = [this, addr, family,
caller_task_queue = webrtc::TaskQueueBase::Current(),
state = state_] {
std::vector<IPAddress> addresses;
int error = ResolveHostname(addr.hostname(), family, &addresses);
webrtc::MutexLock lock(&state->mutex);
if (state->status == State::Status::kLive) {
caller_task_queue->PostTask(
[this, error, addresses = std::move(addresses), state] {
bool live;
{
// ResolveDone can lead to instance destruction, so make sure
// we don't deadlock.
webrtc::MutexLock lock(&state->mutex);
live = state->status == State::Status::kLive;
}
if (live) {
RTC_DCHECK_RUN_ON(&sequence_checker_);
ResolveDone(std::move(addresses), error);
}
});
}
};
#if defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
PostTaskToGlobalQueue(
std::make_unique<absl::AnyInvocable<void() &&>>(thread_function));

View file

@ -61,8 +61,7 @@ Socket* AsyncTCPSocketBase::ConnectSocket(
return owned_socket.release();
}
AsyncTCPSocketBase::AsyncTCPSocketBase(Socket* socket,
size_t max_packet_size)
AsyncTCPSocketBase::AsyncTCPSocketBase(Socket* socket, size_t max_packet_size)
: socket_(socket),
max_insize_(max_packet_size),
max_outsize_(max_packet_size) {

View file

@ -7,11 +7,12 @@
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "rtc_base/callback_list.h"
#include <string>
#include <type_traits>
#include "api/function_view.h"
#include "rtc_base/callback_list.h"
#include "test/gtest.h"
namespace webrtc {
@ -25,7 +26,7 @@ TEST(CallbackList, NoReceiverSingleMessageTest) {
TEST(CallbackList, MultipleParameterMessageTest) {
CallbackList<const std::string&, std::string, std::string&&, int, int*,
std::string&>
std::string&>
c;
std::string str = "messege";
int i = 10;

View file

@ -411,22 +411,20 @@ RTC_NORETURN RTC_EXPORT void UnreachableCodeReached();
::rtc::webrtc_checks_impl::LogStreamer<>() << (val1) << (val2)
#else
#define RTC_CHECK(condition) \
(condition) \
? static_cast<void>(0) \
: true ? ::rtc::webrtc_checks_impl::FatalLogCall<false>(__FILE__, \
__LINE__, "") & \
::rtc::webrtc_checks_impl::LogStreamer<>() \
: ::rtc::webrtc_checks_impl::FatalLogCall<false>("", 0, "") & \
::rtc::webrtc_checks_impl::LogStreamer<>()
(condition) ? static_cast<void>(0) \
: true ? ::rtc::webrtc_checks_impl::FatalLogCall<false>(__FILE__, __LINE__, \
"") & \
::rtc::webrtc_checks_impl::LogStreamer<>() \
: ::rtc::webrtc_checks_impl::FatalLogCall<false>("", 0, "") & \
::rtc::webrtc_checks_impl::LogStreamer<>()
#define RTC_CHECK_OP(name, op, val1, val2) \
::rtc::Safe##name((val1), (val2)) \
? static_cast<void>(0) \
: true ? ::rtc::webrtc_checks_impl::FatalLogCall<true>(__FILE__, \
__LINE__, "") & \
::rtc::webrtc_checks_impl::LogStreamer<>() \
: ::rtc::webrtc_checks_impl::FatalLogCall<false>("", 0, "") & \
::rtc::webrtc_checks_impl::LogStreamer<>()
::rtc::Safe##name((val1), (val2)) ? static_cast<void>(0) \
: true ? ::rtc::webrtc_checks_impl::FatalLogCall<true>(__FILE__, __LINE__, \
"") & \
::rtc::webrtc_checks_impl::LogStreamer<>() \
: ::rtc::webrtc_checks_impl::FatalLogCall<false>("", 0, "") & \
::rtc::webrtc_checks_impl::LogStreamer<>()
#endif
#define RTC_CHECK_EQ(val1, val2) RTC_CHECK_OP(Eq, ==, val1, val2)

View file

@ -61,17 +61,11 @@ TEST(EventTracerTest, ScopedTraceEvent) {
[](const char* /*name*/) {
return reinterpret_cast<const unsigned char*>("test");
},
[](char /*phase*/,
const unsigned char* /*category_enabled*/,
const char* /*name*/,
unsigned long long /*id*/,
int /*num_args*/,
const char** /*arg_names*/,
const unsigned char* /*arg_types*/,
[](char /*phase*/, const unsigned char* /*category_enabled*/,
const char* /*name*/, unsigned long long /*id*/, int /*num_args*/,
const char** /*arg_names*/, const unsigned char* /*arg_types*/,
const unsigned long long* /*arg_values*/,
unsigned char /*flags*/) {
TestStatistics::Get()->Increment();
});
unsigned char /*flags*/) { TestStatistics::Get()->Increment(); });
{ TRACE_EVENT0("test", "ScopedTraceEvent"); }
EXPECT_EQ(2, TestStatistics::Get()->Count());
TestStatistics::Get()->Reset();

View file

@ -96,9 +96,9 @@ class BalancedDegradationSettings {
int pixels = 0; // Video frame size.
// If the frame size is less than or equal to `pixels`:
int fps = 0; // Min framerate to be used.
int kbps = 0; // Min bitrate needed to adapt up (resolution/fps).
int kbps_res = 0; // Min bitrate needed to adapt up in resolution.
int fps = 0; // Min framerate to be used.
int kbps = 0; // Min bitrate needed to adapt up (resolution/fps).
int kbps_res = 0; // Min bitrate needed to adapt up in resolution.
int fps_diff = kNoFpsDiff; // Min fps reduction needed (input fps - `fps`)
// w/o triggering a new subsequent downgrade
// check.

View file

@ -21,40 +21,39 @@ namespace {
void VerifyIsDefault(
const std::vector<BalancedDegradationSettings::Config>& config) {
EXPECT_THAT(config, ::testing::ElementsAre(
BalancedDegradationSettings::Config{
320 * 240,
7,
0,
0,
BalancedDegradationSettings::kNoFpsDiff,
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}},
BalancedDegradationSettings::Config{
480 * 360,
10,
0,
0,
1,
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}},
BalancedDegradationSettings::Config{
640 * 480,
15,
0,
0,
1,
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}}));
EXPECT_THAT(config,
::testing::ElementsAre(
BalancedDegradationSettings::Config{
320 * 240,
7,
0,
0,
BalancedDegradationSettings::kNoFpsDiff,
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}},
BalancedDegradationSettings::Config{480 * 360,
10,
0,
0,
1,
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}},
BalancedDegradationSettings::Config{640 * 480,
15,
0,
0,
1,
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}}));
}
} // namespace

View file

@ -14,7 +14,6 @@
#include <vector>
#include "absl/types/optional.h"
#include "rtc_base/experiments/field_trial_parser.h"
namespace webrtc {

View file

@ -123,7 +123,7 @@ template <typename T>
struct LambdaTypeTraits : public LambdaTypeTraits<decltype(&T::operator())> {};
template <typename ClassType, typename RetType, typename SourceType>
struct LambdaTypeTraits<RetType* (ClassType::*)(SourceType*)const> {
struct LambdaTypeTraits<RetType* (ClassType::*)(SourceType*) const> {
using ret = RetType;
using src = SourceType;
};

View file

@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "rtc_base/experiments/struct_parameters_parser.h"
#include "rtc_base/gunit.h"
namespace webrtc {

View file

@ -22,9 +22,8 @@
#include <netdb.h>
#endif
#include "rtc_base/ip_address.h"
#include "rtc_base/byte_order.h"
#include "rtc_base/ip_address.h"
#include "rtc_base/net_helpers.h"
#include "rtc_base/string_utils.h"

View file

@ -366,9 +366,8 @@ void LogMessage::OutputToDebug(const LogLineRef& log_line) {
CFStringRef domain = CFBundleGetIdentifier(CFBundleGetMainBundle());
if (domain != nullptr) {
Boolean exists_and_is_valid;
Boolean should_log =
CFPreferencesGetAppBooleanValue(CFSTR("logToStdErr"), domain,
&exists_and_is_valid);
Boolean should_log = CFPreferencesGetAppBooleanValue(
CFSTR("logToStdErr"), domain, &exists_and_is_valid);
// If the key doesn't exist or is invalid or is false, we will not log to
// stderr.
log_to_stderr = exists_and_is_valid && should_log;

View file

@ -20,8 +20,8 @@ bool RouteEndpoint::operator==(const RouteEndpoint& other) const {
bool NetworkRoute::operator==(const NetworkRoute& other) const {
return connected == other.connected && local == other.local &&
remote == other.remote && packet_overhead == other.packet_overhead &&
last_sent_packet_id == other.last_sent_packet_id;
remote == other.remote && packet_overhead == other.packet_overhead &&
last_sent_packet_id == other.last_sent_packet_id;
}
} // namespace rtc

View file

@ -14,6 +14,7 @@
#include <cmath>
#include <cstdint>
#include <limits>
#include "absl/types/optional.h"
namespace rtc {

View file

@ -325,9 +325,9 @@ R2 SafeClamp(T x, L min, H max) {
static_assert(IsIntlike<L>::value || std::is_floating_point<L>::value,
"The third argument must be integral or floating-point");
RTC_DCHECK_LE(min, max);
return SafeLe(x, min)
? static_cast<R2>(min)
: SafeGe(x, max) ? static_cast<R2>(max) : static_cast<R2>(x);
return SafeLe(x, min) ? static_cast<R2>(min)
: SafeGe(x, max) ? static_cast<R2>(max)
: static_cast<R2>(x);
}
} // namespace rtc

View file

@ -184,7 +184,6 @@ enum ssl_verify_result_t DummyVerifyCallback(SSL* ssl, uint8_t* out_alert) {
// The server is deallocated. This client will have a peer certificate available
// and is thus suitable for testing VerifyPeerCertMatchesHost.
SSL* CreateSSLWithPeerCertificate(const unsigned char* cert, size_t cert_len) {
const unsigned char* key_ptr = kFakeSSLPrivateKey;
EVP_PKEY* key = d2i_PrivateKey(
EVP_PKEY_EC, nullptr, &key_ptr,

View file

@ -13,6 +13,7 @@
#include <stddef.h>
#include <memory>
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "rtc_base/socket_factory.h"

View file

@ -73,7 +73,7 @@ class RTC_EXPORT RateStatistics {
struct Bucket {
explicit Bucket(int64_t timestamp);
int64_t sum; // Sum of all samples in this bucket.
int64_t sum; // Sum of all samples in this bucket.
int num_samples; // Number of samples in this bucket.
const int64_t timestamp; // Timestamp this bucket corresponds to.
};

View file

@ -8,10 +8,10 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include <cstdarg>
#include "rtc_base/strings/string_format.h"
#include <cstdarg>
#include "rtc_base/checks.h"
namespace rtc {

View file

@ -62,8 +62,8 @@ TYPED_TEST(StrongAliasTest, ValueAccessesUnderlyingValue) {
// Const value getter.
const FooAlias const_alias(GetExampleValue<TypeParam>(1));
EXPECT_EQ(GetExampleValue<TypeParam>(1), const_alias.value());
static_assert(std::is_const<typename std::remove_reference<decltype(
const_alias.value())>::type>::value,
static_assert(std::is_const<typename std::remove_reference<
decltype(const_alias.value())>::type>::value,
"Reference returned by const value getter should be const.");
}

View file

@ -38,9 +38,7 @@ class RTC_LOCKABLE Mutex final {
Mutex(const Mutex&) = delete;
Mutex& operator=(const Mutex&) = delete;
void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION() {
impl_.Lock();
}
void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION() { impl_.Lock(); }
ABSL_MUST_USE_RESULT bool TryLock() RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) {
return impl_.TryLock();
}
@ -48,9 +46,7 @@ class RTC_LOCKABLE Mutex final {
// Otherwise, may report an error (typically by crashing with a diagnostic),
// or may return immediately.
void AssertHeld() const RTC_ASSERT_EXCLUSIVE_LOCK() { impl_.AssertHeld(); }
void Unlock() RTC_UNLOCK_FUNCTION() {
impl_.Unlock();
}
void Unlock() RTC_UNLOCK_FUNCTION() { impl_.Unlock(); }
private:
MutexImpl impl_;

View file

@ -738,11 +738,10 @@ TEST(ThreadPostTaskTest, InvokesAsynchronously) {
// thread. The second event ensures that the message is processed.
Event event_set_by_test_thread;
Event event_set_by_background_thread;
background_thread->PostTask(
[&event_set_by_test_thread, &event_set_by_background_thread] {
WaitAndSetEvent(&event_set_by_test_thread,
&event_set_by_background_thread);
});
background_thread->PostTask([&event_set_by_test_thread,
&event_set_by_background_thread] {
WaitAndSetEvent(&event_set_by_test_thread, &event_set_by_background_thread);
});
event_set_by_test_thread.Set();
event_set_by_background_thread.Wait(Event::kForever);
}

File diff suppressed because it is too large Load diff

View file

@ -141,10 +141,9 @@ class UnitBase {
template <typename T>
constexpr typename std::enable_if<std::is_floating_point<T>::value, T>::type
ToValue() const {
return IsPlusInfinity()
? std::numeric_limits<T>::infinity()
: IsMinusInfinity() ? -std::numeric_limits<T>::infinity()
: value_;
return IsPlusInfinity() ? std::numeric_limits<T>::infinity()
: IsMinusInfinity() ? -std::numeric_limits<T>::infinity()
: value_;
}
template <typename T>
constexpr T ToValueOr(T fallback_value) const {

View file

@ -11,6 +11,7 @@
#include "rtc_base/win/create_direct3d_device.h"
#include <libloaderapi.h>
#include <utility>
namespace {

View file

@ -25,10 +25,18 @@ ATOM Win32Window::window_class_ = 0;
Win32Window::Win32Window() : wnd_(nullptr) {}
Win32Window::~Win32Window() { RTC_DCHECK(nullptr == wnd_); }
Win32Window::~Win32Window() {
RTC_DCHECK(nullptr == wnd_);
}
bool Win32Window::Create(HWND parent, const wchar_t* title, DWORD style,
DWORD exstyle, int x, int y, int cx, int cy) {
bool Win32Window::Create(HWND parent,
const wchar_t* title,
DWORD style,
DWORD exstyle,
int x,
int y,
int cx,
int cy) {
if (wnd_) {
// Window already exists.
return false;
@ -83,7 +91,9 @@ void Win32Window::Shutdown() {
}
}
bool Win32Window::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam,
bool Win32Window::OnMessage(UINT uMsg,
WPARAM wParam,
LPARAM lParam,
LRESULT& result) {
switch (uMsg) {
case WM_CLOSE:
@ -96,13 +106,17 @@ bool Win32Window::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam,
return false;
}
bool Win32Window::OnClose() { return true; }
bool Win32Window::OnClose() {
return true;
}
void Win32Window::OnNcDestroy() {
// Do nothing. }
}
LRESULT Win32Window::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
LRESULT Win32Window::WndProc(HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam) {
Win32Window* that =
reinterpret_cast<Win32Window*>(::GetWindowLongPtr(hwnd, GWLP_USERDATA));