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

@ -129,13 +129,12 @@ BasicPortAllocator::BasicPortAllocator(
RTC_DCHECK(relay_port_factory_ != nullptr);
RTC_DCHECK(network_manager_ != nullptr);
RTC_DCHECK(socket_factory_ != nullptr);
SetConfiguration(ServerAddresses(), std::vector<RelayServerConfig>(),
0, false, customizer);
SetConfiguration(ServerAddresses(), std::vector<RelayServerConfig>(), 0,
false, customizer);
Construct();
}
BasicPortAllocator::BasicPortAllocator(
rtc::NetworkManager* network_manager)
BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager)
: network_manager_(network_manager), socket_factory_(nullptr) {
InitRelayPortFactory(nullptr);
RTC_DCHECK(relay_port_factory_ != nullptr);
@ -143,10 +142,9 @@ BasicPortAllocator::BasicPortAllocator(
Construct();
}
BasicPortAllocator::BasicPortAllocator(
rtc::NetworkManager* network_manager,
rtc::PacketSocketFactory* socket_factory,
const ServerAddresses& stun_servers)
BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager,
rtc::PacketSocketFactory* socket_factory,
const ServerAddresses& stun_servers)
: network_manager_(network_manager), socket_factory_(socket_factory) {
InitRelayPortFactory(nullptr);
RTC_DCHECK(relay_port_factory_ != nullptr);
@ -224,8 +222,10 @@ void BasicPortAllocator::SetNetworkIgnoreMask(int network_ignore_mask) {
}
PortAllocatorSession* BasicPortAllocator::CreateSessionInternal(
const std::string& content_name, int component,
const std::string& ice_ufrag, const std::string& ice_pwd) {
const std::string& content_name,
int component,
const std::string& ice_ufrag,
const std::string& ice_pwd) {
CheckRunOnValidThreadAndInitialized();
PortAllocatorSession* session = new BasicPortAllocatorSession(
this, content_name, component, ice_ufrag, ice_pwd);
@ -545,30 +545,30 @@ bool BasicPortAllocatorSession::CandidatesAllocationDone() const {
[](const PortData& port) { return port.inprogress(); });
}
void BasicPortAllocatorSession::OnMessage(rtc::Message *message) {
void BasicPortAllocatorSession::OnMessage(rtc::Message* message) {
switch (message->message_id) {
case MSG_CONFIG_START:
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
GetPortConfigurations();
break;
case MSG_CONFIG_READY:
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
OnConfigReady(static_cast<PortConfiguration*>(message->pdata));
break;
case MSG_ALLOCATE:
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
OnAllocate();
break;
case MSG_SEQUENCEOBJECTS_CREATED:
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
OnAllocationSequenceObjectsCreated();
break;
case MSG_CONFIG_STOP:
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
OnConfigStop();
break;
default:
RTC_NOTREACHED();
case MSG_CONFIG_START:
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
GetPortConfigurations();
break;
case MSG_CONFIG_READY:
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
OnConfigReady(static_cast<PortConfiguration*>(message->pdata));
break;
case MSG_ALLOCATE:
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
OnAllocate();
break;
case MSG_SEQUENCEOBJECTS_CREATED:
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
OnAllocationSequenceObjectsCreated();
break;
case MSG_CONFIG_STOP:
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
OnConfigStop();
break;
default:
RTC_NOTREACHED();
}
}
@ -580,9 +580,8 @@ void BasicPortAllocatorSession::UpdateIceParametersInternal() {
}
void BasicPortAllocatorSession::GetPortConfigurations() {
PortConfiguration* config = new PortConfiguration(allocator_->stun_servers(),
username(),
password());
PortConfiguration* config =
new PortConfiguration(allocator_->stun_servers(), username(), password());
for (const RelayServerConfig& turn_server : allocator_->turn_servers()) {
config->AddRelay(turn_server);
@ -610,8 +609,8 @@ void BasicPortAllocatorSession::OnConfigStop() {
// mark those as error. Since session doesn't need any new candidates
// at this stage of the allocation, it's safe to discard any new candidates.
bool send_signal = false;
for (std::vector<PortData>::iterator it = ports_.begin();
it != ports_.end(); ++it) {
for (std::vector<PortData>::iterator it = ports_.begin(); it != ports_.end();
++it) {
if (it->inprogress()) {
// Updating port state to error, which didn't finish allocating candidates
// yet.
@ -836,14 +835,14 @@ void BasicPortAllocatorSession::DisableEquivalentPhases(
PortConfiguration* config,
uint32_t* flags) {
for (uint32_t i = 0; i < sequences_.size() &&
(*flags & DISABLE_ALL_PHASES) != DISABLE_ALL_PHASES;
(*flags & DISABLE_ALL_PHASES) != DISABLE_ALL_PHASES;
++i) {
sequences_[i]->DisableEquivalentPhases(network, config, flags);
}
}
void BasicPortAllocatorSession::AddAllocatedPort(Port* port,
AllocationSequence * seq,
AllocationSequence* seq,
bool prepare_address) {
if (!port)
return;
@ -863,13 +862,11 @@ void BasicPortAllocatorSession::AddAllocatedPort(Port* port,
port->SignalCandidateReady.connect(
this, &BasicPortAllocatorSession::OnCandidateReady);
port->SignalPortComplete.connect(this,
&BasicPortAllocatorSession::OnPortComplete);
&BasicPortAllocatorSession::OnPortComplete);
port->SignalDestroyed.connect(this,
&BasicPortAllocatorSession::OnPortDestroyed);
port->SignalPortError.connect(
this, &BasicPortAllocatorSession::OnPortError);
RTC_LOG(LS_INFO) << port->ToString()
<< ": Added port to allocator";
&BasicPortAllocatorSession::OnPortDestroyed);
port->SignalPortError.connect(this, &BasicPortAllocatorSession::OnPortError);
RTC_LOG(LS_INFO) << port->ToString() << ": Added port to allocator";
if (prepare_address)
port->PrepareAddress();
@ -881,8 +878,8 @@ void BasicPortAllocatorSession::OnAllocationSequenceObjectsCreated() {
MaybeSignalCandidatesAllocationDone();
}
void BasicPortAllocatorSession::OnCandidateReady(
Port* port, const Candidate& c) {
void BasicPortAllocatorSession::OnCandidateReady(Port* port,
const Candidate& c) {
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
PortData* data = FindPort(port);
RTC_DCHECK(data != NULL);
@ -1091,15 +1088,13 @@ void BasicPortAllocatorSession::MaybeSignalCandidatesAllocationDone() {
}
}
void BasicPortAllocatorSession::OnPortDestroyed(
PortInterface* port) {
void BasicPortAllocatorSession::OnPortDestroyed(PortInterface* port) {
RTC_DCHECK(rtc::Thread::Current() == network_thread_);
for (std::vector<PortData>::iterator iter = ports_.begin();
iter != ports_.end(); ++iter) {
if (port == iter->port()) {
ports_.erase(iter);
RTC_LOG(LS_INFO) << port->ToString()
<< ": Removed port from allocator ("
RTC_LOG(LS_INFO) << port->ToString() << ": Removed port from allocator ("
<< static_cast<int>(ports_.size()) << " remaining)";
return;
}
@ -1109,8 +1104,8 @@ void BasicPortAllocatorSession::OnPortDestroyed(
BasicPortAllocatorSession::PortData* BasicPortAllocatorSession::FindPort(
Port* port) {
for (std::vector<PortData>::iterator it = ports_.begin();
it != ports_.end(); ++it) {
for (std::vector<PortData>::iterator it = ports_.begin(); it != ports_.end();
++it) {
if (it->port() == port) {
return &*it;
}
@ -1170,8 +1165,7 @@ AllocationSequence::AllocationSequence(BasicPortAllocatorSession* session,
flags_(flags),
udp_socket_(),
udp_port_(NULL),
phase_(0) {
}
phase_(0) {}
void AllocationSequence::Init() {
if (IsFlagSet(PORTALLOCATOR_ENABLE_SHARED_SOCKET)) {
@ -1179,8 +1173,8 @@ void AllocationSequence::Init() {
rtc::SocketAddress(network_->GetBestIP(), 0),
session_->allocator()->min_port(), session_->allocator()->max_port()));
if (udp_socket_) {
udp_socket_->SignalReadPacket.connect(
this, &AllocationSequence::OnReadPacket);
udp_socket_->SignalReadPacket.connect(this,
&AllocationSequence::OnReadPacket);
}
// Continuing if |udp_socket_| is NULL, as local TCP and RelayPort using TCP
// are next available options to setup a communication channel.
@ -1204,7 +1198,8 @@ AllocationSequence::~AllocationSequence() {
}
void AllocationSequence::DisableEquivalentPhases(rtc::Network* network,
PortConfiguration* config, uint32_t* flags) {
PortConfiguration* config,
uint32_t* flags) {
if (network_failed_) {
// If the network of this allocation sequence has ever become failed,
// it won't be equivalent to the new network.
@ -1457,8 +1452,7 @@ void AllocationSequence::CreateGturnPort(const RelayServerConfig& config) {
// Add the addresses of this protocol.
PortList::const_iterator relay_port;
for (relay_port = config.ports.begin();
relay_port != config.ports.end();
for (relay_port = config.ports.begin(); relay_port != config.ports.end();
++relay_port) {
port->AddServerAddress(*relay_port);
port->AddExternalAddress(*relay_port);
@ -1470,8 +1464,8 @@ void AllocationSequence::CreateGturnPort(const RelayServerConfig& config) {
void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) {
PortList::const_iterator relay_port;
for (relay_port = config.ports.begin();
relay_port != config.ports.end(); ++relay_port) {
for (relay_port = config.ports.begin(); relay_port != config.ports.end();
++relay_port) {
// Skip UDP connections to relay servers if it's disallowed.
if (IsFlagSet(PORTALLOCATOR_DISABLE_UDP_RELAY) &&
relay_port->proto == PROTO_UDP) {
@ -1485,7 +1479,8 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) {
if (server_ip_family != AF_UNSPEC && server_ip_family != local_ip_family) {
RTC_LOG(LS_INFO)
<< "Server and local address families are not compatible. "
"Server address: " << relay_port->address.ipaddr().ToString()
"Server address: "
<< relay_port->address.ipaddr().ToString()
<< " Local address: " << network_->GetBestIP().ToString();
continue;
}
@ -1512,9 +1507,8 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) {
args, udp_socket_.get());
if (!port) {
RTC_LOG(LS_WARNING)
<< "Failed to create relay port with "
<< args.server_address->address.ToString();
RTC_LOG(LS_WARNING) << "Failed to create relay port with "
<< args.server_address->address.ToString();
continue;
}
@ -1524,14 +1518,12 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) {
port->SignalDestroyed.connect(this, &AllocationSequence::OnPortDestroyed);
} else {
port = session_->allocator()->relay_port_factory()->Create(
args,
session_->allocator()->min_port(),
args, session_->allocator()->min_port(),
session_->allocator()->max_port());
if (!port) {
RTC_LOG(LS_WARNING)
<< "Failed to create relay port with "
<< args.server_address->address.ToString();
RTC_LOG(LS_WARNING) << "Failed to create relay port with "
<< args.server_address->address.ToString();
continue;
}
}
@ -1540,10 +1532,11 @@ void AllocationSequence::CreateTurnPort(const RelayServerConfig& config) {
}
}
void AllocationSequence::OnReadPacket(
rtc::AsyncPacketSocket* socket, const char* data, size_t size,
const rtc::SocketAddress& remote_addr,
const rtc::PacketTime& packet_time) {
void AllocationSequence::OnReadPacket(rtc::AsyncPacketSocket* socket,
const char* data,
size_t size,
const rtc::SocketAddress& remote_addr,
const rtc::PacketTime& packet_time) {
RTC_DCHECK(socket == udp_socket_.get());
bool turn_port_found = false;
@ -1594,10 +1587,9 @@ void AllocationSequence::OnPortDestroyed(PortInterface* port) {
}
// PortConfiguration
PortConfiguration::PortConfiguration(
const rtc::SocketAddress& stun_address,
const std::string& username,
const std::string& password)
PortConfiguration::PortConfiguration(const rtc::SocketAddress& stun_address,
const std::string& username,
const std::string& password)
: stun_address(stun_address), username(username), password(password) {
if (!stun_address.IsNil())
stun_servers.insert(stun_address);
@ -1606,9 +1598,7 @@ PortConfiguration::PortConfiguration(
PortConfiguration::PortConfiguration(const ServerAddresses& stun_servers,
const std::string& username,
const std::string& password)
: stun_servers(stun_servers),
username(username),
password(password) {
: stun_servers(stun_servers), username(username), password(password) {
if (!stun_servers.empty())
stun_address = *(stun_servers.begin());
}
@ -1634,12 +1624,11 @@ void PortConfiguration::AddRelay(const RelayServerConfig& config) {
relays.push_back(config);
}
bool PortConfiguration::SupportsProtocol(
const RelayServerConfig& relay, ProtocolType type) const {
bool PortConfiguration::SupportsProtocol(const RelayServerConfig& relay,
ProtocolType type) const {
PortList::const_iterator relay_port;
for (relay_port = relay.ports.begin();
relay_port != relay.ports.end();
++relay_port) {
for (relay_port = relay.ports.begin(); relay_port != relay.ports.end();
++relay_port) {
if (relay_port->proto == type)
return true;
}
@ -1649,15 +1638,15 @@ bool PortConfiguration::SupportsProtocol(
bool PortConfiguration::SupportsProtocol(RelayType turn_type,
ProtocolType type) const {
for (size_t i = 0; i < relays.size(); ++i) {
if (relays[i].type == turn_type &&
SupportsProtocol(relays[i], type))
if (relays[i].type == turn_type && SupportsProtocol(relays[i], type))
return true;
}
return false;
}
ServerAddresses PortConfiguration::GetRelayServerAddresses(
RelayType turn_type, ProtocolType type) const {
RelayType turn_type,
ProtocolType type) const {
ServerAddresses servers;
for (size_t i = 0; i < relays.size(); ++i) {
if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) {