Commit d0539eeb authored by jdoerrie's avatar jdoerrie Committed by Commit Bot

[clang-tidy] Apply modernize-use-auto in /remoting

This change applies clang-tidy's modernize-use-auto [1] in /remoting.
This change does not rewrite new and cast expressions.

Reproduction steps:
- run clang-tidy's modernize-use-auto
- run git cl format
- manually remove unused typedefs due to -Wunused-local-typedef error

[1] https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-auto.html

This CL was uploaded by git cl split.

R=joedow@chromium.org

Bug: 890902
Change-Id: Ib36073c54837ccd92347d202b539cef688d8402a
Reviewed-on: https://chromium-review.googlesource.com/c/1257908Reviewed-by: default avatarJoe Downing <joedow@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595974}
parent 698875bc
......@@ -45,8 +45,7 @@ void KeyEventMapper::InjectKeyEvent(const protocol::KeyEvent& event) {
}
// Re-map mapped keys to the new value before passing them on.
std::map<uint32_t, uint32_t>::iterator mapped =
mapped_keys.find(event.usb_keycode());
auto mapped = mapped_keys.find(event.usb_keycode());
if (mapped != mapped_keys.end()) {
protocol::KeyEvent new_event(event);
new_event.set_usb_keycode(mapped->second);
......
......@@ -71,8 +71,7 @@ void NormalizingInputFilterMac::InjectKeyEvent(
}
void NormalizingInputFilterMac::GenerateKeyupEvents() {
for (KeyPressedMap::iterator i = key_pressed_map_.begin();
i != key_pressed_map_.end(); ++i) {
for (auto i = key_pressed_map_.begin(); i != key_pressed_map_.end(); ++i) {
// The generated key up event will have the same key code and lock states
// as the original key down event.
protocol::KeyEvent event = i->second;
......
......@@ -189,11 +189,10 @@ void ChromotingHost::OnSessionAuthenticationFailed(ClientSession* client) {
void ChromotingHost::OnSessionClosed(ClientSession* client) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ClientSessions::iterator it =
std::find_if(clients_.begin(), clients_.end(),
[client](const std::unique_ptr<ClientSession>& item) {
return item.get() == client;
});
auto it = std::find_if(clients_.begin(), clients_.end(),
[client](const std::unique_ptr<ClientSession>& item) {
return item.get() == client;
});
CHECK(it != clients_.end());
bool was_authenticated = client->is_authenticated();
......
......@@ -176,7 +176,7 @@ void IpcDesktopEnvironmentFactory::OnDesktopSessionAgentAttached(
return;
}
ActiveConnectionsList::iterator i = active_connections_.find(terminal_id);
auto i = active_connections_.find(terminal_id);
if (i != active_connections_.end()) {
i->second->DetachFromDesktop();
i->second->AttachToDesktop(desktop_pipe, session_id);
......@@ -193,7 +193,7 @@ void IpcDesktopEnvironmentFactory::OnTerminalDisconnected(int terminal_id) {
return;
}
ActiveConnectionsList::iterator i = active_connections_.find(terminal_id);
auto i = active_connections_.find(terminal_id);
if (i != active_connections_.end()) {
DesktopSessionProxy* desktop_session_proxy = i->second;
active_connections_.erase(i);
......
......@@ -38,8 +38,7 @@ void RemoteInputFilter::LocalMouseMoved(
// input event that we've just injected), then ignore remote inputs for a
// short time.
if (expect_local_echo_) {
std::list<webrtc::DesktopVector>::iterator found_position =
injected_mouse_positions_.begin();
auto found_position = injected_mouse_positions_.begin();
while (found_position != injected_mouse_positions_.end() &&
!mouse_pos.equals(*found_position)) {
++found_position;
......
......@@ -201,7 +201,7 @@ bool SecurityKeyAuthHandlerPosix::IsValidConnectionId(int connection_id) const {
void SecurityKeyAuthHandlerPosix::SendClientResponse(
int connection_id,
const std::string& response) {
ActiveSockets::const_iterator iter = GetSocketForConnectionId(connection_id);
auto iter = GetSocketForConnectionId(connection_id);
if (iter != active_sockets_.end()) {
HOST_DLOG << "Sending client response to socket: " << connection_id;
iter->second->SendResponse(response);
......@@ -214,7 +214,7 @@ void SecurityKeyAuthHandlerPosix::SendClientResponse(
}
void SecurityKeyAuthHandlerPosix::SendErrorAndCloseConnection(int id) {
ActiveSockets::const_iterator iter = GetSocketForConnectionId(id);
auto iter = GetSocketForConnectionId(id);
if (iter != active_sockets_.end()) {
HOST_DLOG << "Sending error and closing socket: " << id;
SendErrorAndCloseActiveSocket(iter);
......
......@@ -348,8 +348,8 @@ void ChannelMultiplexer::CreateChannel(const std::string& name,
}
void ChannelMultiplexer::CancelChannelCreation(const std::string& name) {
for (std::list<PendingChannel>::iterator it = pending_channels_.begin();
it != pending_channels_.end(); ++it) {
for (auto it = pending_channels_.begin(); it != pending_channels_.end();
++it) {
if (it->name == name) {
pending_channels_.erase(it);
return;
......@@ -442,8 +442,7 @@ void ChannelMultiplexer::OnIncomingPacket(
int receive_id = packet->channel_id();
MuxChannel* channel = nullptr;
std::map<int, MuxChannel*>::iterator it =
channels_by_receive_id_.find(receive_id);
auto it = channels_by_receive_id_.find(receive_id);
if (it != channels_by_receive_id_.end()) {
channel = it->second;
} else {
......
......@@ -90,7 +90,7 @@ void ClientVideoDispatcher::OnIncomingMessage(
client_stub_->SetVideoLayout(layout);
}
PendingFramesList::iterator pending_frame =
auto pending_frame =
pending_frames_.insert(pending_frames_.end(), PendingFrame(frame_id));
video_stub_->ProcessVideoPacket(
......
......@@ -135,8 +135,7 @@ FakeDatagramChannelFactory::FakeDatagramChannelFactory()
}
FakeDatagramChannelFactory::~FakeDatagramChannelFactory() {
for (ChannelsMap::iterator it = channels_.begin(); it != channels_.end();
++it) {
for (auto it = channels_.begin(); it != channels_.end(); ++it) {
EXPECT_FALSE(it->second);
}
}
......
......@@ -60,7 +60,7 @@ bool IceTransport::ProcessTransportInfo(buzz::XmlElement* transport_info_xml) {
for (auto it = transport_info.ice_credentials.begin();
it != transport_info.ice_credentials.end(); ++it) {
ChannelsMap::iterator channel = channels_.find(it->channel);
auto channel = channels_.find(it->channel);
if (channel != channels_.end()) {
channel->second->SetRemoteCredentials(it->ufrag, it->password);
} else {
......@@ -72,7 +72,7 @@ bool IceTransport::ProcessTransportInfo(buzz::XmlElement* transport_info_xml) {
for (auto it = transport_info.candidates.begin();
it != transport_info.candidates.end(); ++it) {
ChannelsMap::iterator channel = channels_.find(it->name);
auto channel = channels_.find(it->name);
rtc::SocketAddress address = ToNativeSocket(it->candidate.address());
it->candidate.set_address(address);
if (channel != channels_.end()) {
......@@ -114,7 +114,7 @@ void IceTransport::CreateChannel(const std::string& name,
}
void IceTransport::CancelChannelCreation(const std::string& name) {
ChannelsMap::iterator it = channels_.find(name);
auto it = channels_.find(name);
if (it != channels_.end()) {
DCHECK(!it->second->is_connected());
delete it->second;
......@@ -123,8 +123,7 @@ void IceTransport::CancelChannelCreation(const std::string& name) {
}
void IceTransport::AddPendingRemoteTransportInfo(IceTransportChannel* channel) {
std::list<IceTransportInfo::IceCredentials>::iterator credentials =
pending_remote_ice_credentials_.begin();
auto credentials = pending_remote_ice_credentials_.begin();
while (credentials != pending_remote_ice_credentials_.end()) {
if (credentials->channel == channel->name()) {
channel->SetRemoteCredentials(credentials->ufrag, credentials->password);
......@@ -134,8 +133,7 @@ void IceTransport::AddPendingRemoteTransportInfo(IceTransportChannel* channel) {
}
}
std::list<IceTransportInfo::NamedCandidate>::iterator candidate =
pending_remote_candidates_.begin();
auto candidate = pending_remote_candidates_.begin();
while (candidate != pending_remote_candidates_.end()) {
if (candidate->name == channel->name()) {
channel->AddRemoteCandidate(candidate->candidate);
......@@ -172,7 +170,7 @@ void IceTransport::OnChannelFailed(IceTransportChannel* channel) {
}
void IceTransport::OnChannelDeleted(IceTransportChannel* channel) {
ChannelsMap::iterator it = channels_.find(channel->name());
auto it = channels_.find(channel->name());
DCHECK_EQ(it->second, channel);
channels_.erase(it);
}
......
......@@ -128,7 +128,7 @@ bool JingleSessionManager::OnSignalStrategyIncomingStanza(
return true;
}
SessionsMap::iterator it = sessions_.find(message->sid);
auto it = sessions_.find(message->sid);
if (it == sessions_.end()) {
SendReply(std::move(stanza_copy), JingleMessageReply::INVALID_SID);
return true;
......
......@@ -49,7 +49,7 @@ void PseudoTcpChannelFactory::CreateChannel(
}
void PseudoTcpChannelFactory::CancelChannelCreation(const std::string& name) {
PendingSocketsMap::iterator it = pending_sockets_.find(name);
auto it = pending_sockets_.find(name);
if (it == pending_sockets_.end()) {
datagram_channel_factory_->CancelChannelCreation(name);
} else {
......@@ -86,7 +86,7 @@ void PseudoTcpChannelFactory::OnPseudoTcpConnected(
const std::string& name,
const ChannelCreatedCallback& callback,
int result) {
PendingSocketsMap::iterator it = pending_sockets_.find(name);
auto it = pending_sockets_.find(name);
DCHECK(it != pending_sockets_.end());
std::unique_ptr<P2PStreamSocket> socket(it->second);
pending_sockets_.erase(it);
......
......@@ -39,7 +39,7 @@ void SecureChannelFactory::CreateChannel(
void SecureChannelFactory::CancelChannelCreation(
const std::string& name) {
AuthenticatorMap::iterator it = channel_authenticators_.find(name);
auto it = channel_authenticators_.find(name);
if (it == channel_authenticators_.end()) {
channel_factory_->CancelChannelCreation(name);
} else {
......@@ -73,7 +73,7 @@ void SecureChannelFactory::OnSecureChannelCreated(
std::unique_ptr<P2PStreamSocket> socket) {
DCHECK((socket && error == net::OK) || (!socket && error != net::OK));
AuthenticatorMap::iterator it = channel_authenticators_.find(name);
auto it = channel_authenticators_.find(name);
DCHECK(it != channel_authenticators_.end());
delete it->second;
channel_authenticators_.erase(it);
......
......@@ -72,9 +72,9 @@ std::unique_ptr<IqRequest> IqSender::SendIq(
}
void IqSender::RemoveRequest(IqRequest* request) {
IqRequestMap::iterator it = requests_.begin();
auto it = requests_.begin();
while (it != requests_.end()) {
IqRequestMap::iterator cur = it;
auto cur = it;
++it;
if (cur->second == request) {
requests_.erase(cur);
......@@ -110,7 +110,7 @@ bool IqSender::OnSignalStrategyIncomingStanza(const buzz::XmlElement* stanza) {
std::string from = stanza->Attr(buzz::QN_FROM);
IqRequestMap::iterator it = requests_.find(id);
auto it = requests_.find(id);
if (it == requests_.end()) {
return false;
}
......
......@@ -68,8 +68,7 @@ bool VerifyStanza(
}
const std::string& key = attr->Name().LocalPart();
const std::string& value = attr->Value();
std::map<std::string, std::string>::const_iterator iter =
key_value_pairs.find(key);
auto iter = key_value_pairs.find(key);
if (iter == key_value_pairs.end()) {
if (keys.find(key) == keys.end()) {
*error = "unexpected attribute " + key;
......
......@@ -62,7 +62,7 @@ void FakeNetworkDispatcher::DeliverPacket(
{
base::AutoLock auto_lock(nodes_lock_);
NodesMap::iterator node_it = nodes_.find(to.ipaddr());
auto node_it = nodes_.find(to.ipaddr());
if (node_it == nodes_.end()) {
LOG(ERROR) << "Tried to deliver packet to unknown target: "
<< to.ToString();
......
......@@ -336,7 +336,7 @@ void FakePacketSocketFactory::DoReceivePacket() {
PendingPacket packet;
if (pending_packets_.size() > 1 && RandDouble() < out_of_order_rate_) {
std::list<PendingPacket>::iterator it = pending_packets_.begin();
auto it = pending_packets_.begin();
++it;
packet = *it;
pending_packets_.erase(it);
......@@ -345,7 +345,7 @@ void FakePacketSocketFactory::DoReceivePacket() {
pending_packets_.pop_front();
}
UdpSocketsMap::iterator iter = udp_sockets_.find(packet.to.port());
auto iter = udp_sockets_.find(packet.to.port());
if (iter == udp_sockets_.end()) {
// Invalid port number.
return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment