Reformat the WebRTC code base

Running clang-format with chromium's style guide.

The goal is n-fold:
 * providing consistency and readability (that's what code guidelines are for)
 * preventing noise with presubmit checks and git cl format
 * building on the previous point: making it easier to automatically fix format issues
 * you name it

Please consider using git-hyper-blame to ignore this commit.

Bug: webrtc:9340
Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87
Reviewed-on: https://webrtc-review.googlesource.com/81185
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23660}
This commit is contained in:
Yves Gerey
2018-06-19 15:03:05 +02:00
parent b602123a5a
commit 665174fdbb
1569 changed files with 30495 additions and 30309 deletions

View File

@ -28,15 +28,14 @@
namespace rtc {
#if defined(WEBRTC_WIN)
const in_addr kInitialNextIPv4 = { { { 0x01, 0, 0, 0 } } };
const in_addr kInitialNextIPv4 = {{{0x01, 0, 0, 0}}};
#else
// This value is entirely arbitrary, hence the lack of concern about endianness.
const in_addr kInitialNextIPv4 = { 0x01000000 };
const in_addr kInitialNextIPv4 = {0x01000000};
#endif
// Starts at ::2 so as to not cause confusion with ::1.
const in6_addr kInitialNextIPv6 = { { {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2
} } };
const in6_addr kInitialNextIPv6 = {
{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2}}};
const uint16_t kFirstEphemeralPort = 49152;
const uint16_t kLastEphemeralPort = 65535;
@ -65,15 +64,13 @@ enum {
class Packet : public MessageData {
public:
Packet(const char* data, size_t size, const SocketAddress& from)
: size_(size), consumed_(0), from_(from) {
: size_(size), consumed_(0), from_(from) {
RTC_DCHECK(nullptr != data);
data_ = new char[size_];
memcpy(data_, data, size_);
}
~Packet() override {
delete[] data_;
}
~Packet() override { delete[] data_; }
const char* data() const { return data_ + consumed_; }
size_t size() const { return size_ - consumed_; }
@ -92,7 +89,7 @@ class Packet : public MessageData {
};
struct MessageAddress : public MessageData {
explicit MessageAddress(const SocketAddress& a) : addr(a) { }
explicit MessageAddress(const SocketAddress& a) : addr(a) {}
SocketAddress addr;
};
@ -236,15 +233,15 @@ int VirtualSocket::Close() {
}
int VirtualSocket::Send(const void* pv, size_t cb) {
if (CS_CONNECTED != state_) {
error_ = ENOTCONN;
return -1;
}
if (SOCK_DGRAM == type_) {
return SendUdp(pv, cb, remote_addr_);
} else {
return SendTcp(pv, cb);
}
if (CS_CONNECTED != state_) {
error_ = ENOTCONN;
return -1;
}
if (SOCK_DGRAM == type_) {
return SendUdp(pv, cb, remote_addr_);
} else {
return SendTcp(pv, cb);
}
}
int VirtualSocket::SendTo(const void* pv,
@ -555,8 +552,7 @@ VirtualSocketServer::~VirtualSocketServer() {
IPAddress VirtualSocketServer::GetNextIP(int family) {
if (family == AF_INET) {
IPAddress next_ip(next_ipv4_);
next_ipv4_.s_addr =
HostToNetwork32(NetworkToHost32(next_ipv4_.s_addr) + 1);
next_ipv4_.s_addr = HostToNetwork32(NetworkToHost32(next_ipv4_.s_addr) + 1);
return next_ip;
} else if (family == AF_INET6) {
IPAddress next_ip(next_ipv6_);
@ -607,8 +603,8 @@ VirtualSocket* VirtualSocketServer::CreateSocketInternal(int family, int type) {
void VirtualSocketServer::SetMessageQueue(MessageQueue* msg_queue) {
msg_queue_ = msg_queue;
if (msg_queue_) {
msg_queue_->SignalQueueDestroyed.connect(this,
&VirtualSocketServer::OnMessageQueueDestroyed);
msg_queue_->SignalQueueDestroyed.connect(
this, &VirtualSocketServer::OnMessageQueueDestroyed);
}
}
@ -721,8 +717,7 @@ int VirtualSocketServer::Bind(VirtualSocket* socket, SocketAddress* addr) {
}
VirtualSocket* VirtualSocketServer::LookupBinding(const SocketAddress& addr) {
SocketAddress normalized(addr.ipaddr().Normalized(),
addr.port());
SocketAddress normalized(addr.ipaddr().Normalized(), addr.port());
AddressMap::iterator it = bindings_->find(normalized);
if (it != bindings_->end()) {
return it->second;
@ -744,8 +739,7 @@ VirtualSocket* VirtualSocketServer::LookupBinding(const SocketAddress& addr) {
int VirtualSocketServer::Unbind(const SocketAddress& addr,
VirtualSocket* socket) {
SocketAddress normalized(addr.ipaddr().Normalized(),
addr.port());
SocketAddress normalized(addr.ipaddr().Normalized(), addr.port());
RTC_DCHECK((*bindings_)[normalized] == socket);
bindings_->erase(bindings_->find(normalized));
return 0;
@ -756,22 +750,18 @@ void VirtualSocketServer::AddConnection(const SocketAddress& local,
VirtualSocket* remote_socket) {
// Add this socket pair to our routing table. This will allow
// multiple clients to connect to the same server address.
SocketAddress local_normalized(local.ipaddr().Normalized(),
local.port());
SocketAddress remote_normalized(remote.ipaddr().Normalized(),
remote.port());
SocketAddress local_normalized(local.ipaddr().Normalized(), local.port());
SocketAddress remote_normalized(remote.ipaddr().Normalized(), remote.port());
SocketAddressPair address_pair(local_normalized, remote_normalized);
connections_->insert(std::pair<SocketAddressPair,
VirtualSocket*>(address_pair, remote_socket));
connections_->insert(std::pair<SocketAddressPair, VirtualSocket*>(
address_pair, remote_socket));
}
VirtualSocket* VirtualSocketServer::LookupConnection(
const SocketAddress& local,
const SocketAddress& remote) {
SocketAddress local_normalized(local.ipaddr().Normalized(),
local.port());
SocketAddress remote_normalized(remote.ipaddr().Normalized(),
remote.port());
SocketAddress local_normalized(local.ipaddr().Normalized(), local.port());
SocketAddress remote_normalized(remote.ipaddr().Normalized(), remote.port());
SocketAddressPair address_pair(local_normalized, remote_normalized);
ConnectionMap::iterator it = connections_->find(address_pair);
return (connections_->end() != it) ? it->second : nullptr;
@ -779,10 +769,8 @@ VirtualSocket* VirtualSocketServer::LookupConnection(
void VirtualSocketServer::RemoveConnection(const SocketAddress& local,
const SocketAddress& remote) {
SocketAddress local_normalized(local.ipaddr().Normalized(),
local.port());
SocketAddress remote_normalized(remote.ipaddr().Normalized(),
remote.port());
SocketAddress local_normalized(local.ipaddr().Normalized(), local.port());
SocketAddress remote_normalized(remote.ipaddr().Normalized(), remote.port());
SocketAddressPair address_pair(local_normalized, remote_normalized);
connections_->erase(address_pair);
}
@ -826,7 +814,8 @@ bool VirtualSocketServer::Disconnect(VirtualSocket* socket) {
}
int VirtualSocketServer::SendUdp(VirtualSocket* socket,
const char* data, size_t data_size,
const char* data,
size_t data_size,
const SocketAddress& remote_addr) {
++sent_packets_;
if (sending_blocked_) {
@ -907,8 +896,8 @@ void VirtualSocketServer::SendTcp(VirtualSocket* socket) {
// is read from the recv_buffer.
// Lookup the local/remote pair in the connections table.
VirtualSocket* recipient = LookupConnection(socket->local_addr_,
socket->remote_addr_);
VirtualSocket* recipient =
LookupConnection(socket->local_addr_, socket->remote_addr_);
if (!recipient) {
RTC_LOG(LS_VERBOSE) << "Sending data to no one.";
return;
@ -1029,8 +1018,8 @@ void PrintFunction(std::vector<std::pair<double, double> >* f) {
#endif // <unused>
void VirtualSocketServer::UpdateDelayDistribution() {
Function* dist = CreateDistribution(delay_mean_, delay_stddev_,
delay_samples_);
Function* dist =
CreateDistribution(delay_mean_, delay_stddev_, delay_samples_);
// We take a lock just to make sure we don't leak memory.
{
CritScope cs(&delay_crit_);
@ -1092,7 +1081,7 @@ uint32_t VirtualSocketServer::GetTransitDelay(Socket* socket) {
struct FunctionDomainCmp {
bool operator()(const VirtualSocketServer::Point& p1,
const VirtualSocketServer::Point& p2) {
const VirtualSocketServer::Point& p2) {
return p1.first < p2.first;
}
bool operator()(double v1, const VirtualSocketServer::Point& p2) {
@ -1112,7 +1101,7 @@ VirtualSocketServer::Function* VirtualSocketServer::Accumulate(Function* f) {
(*f)[i].second = v;
v = v + dx * avgy;
}
(*f)[f->size()-1].second = v;
(*f)[f->size() - 1].second = v;
return f;
}