Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1105)

Unified Diff: remoting/host/chromoting_host.cc

Issue 2420183002: Don't use barcodes in ProtocolPerfTests (Closed)
Patch Set: . Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/host/chromoting_host.cc
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index d2c0232e7144616804cedf2bbbf000774462787d..8bc93449ad74bce26b534acbc70679a2b7ddb4d7 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -178,10 +178,11 @@ void ChromotingHost::OnSessionAuthenticated(ClientSession* client) {
// Disconnect all other clients. |it| should be advanced before Disconnect()
// is called to avoid it becoming invalid when the client is removed from
// the list.
- ClientList::iterator it = clients_.begin();
+ ClientSessions::iterator it = clients_.begin();
base::WeakPtr<ChromotingHost> self = weak_factory_.GetWeakPtr();
while (it != clients_.end()) {
- ClientSession* other_client = *it++;
+ ClientSession* other_client = it->get();
+ ++it;
if (other_client != client) {
other_client->DisconnectSession(protocol::OK);
@@ -220,13 +221,16 @@ void ChromotingHost::OnSessionAuthenticationFailed(ClientSession* client) {
void ChromotingHost::OnSessionClosed(ClientSession* client) {
DCHECK(CalledOnValidThread());
- ClientList::iterator it = std::find(clients_.begin(), clients_.end(), client);
+ ClientSessions::iterator 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();
std::string jid = client->client_jid();
clients_.erase(it);
- delete client;
if (was_authenticated) {
FOR_EACH_OBSERVER(HostStatusObserver, status_observers_,
@@ -276,11 +280,9 @@ void ChromotingHost::OnIncomingSession(
}
// Create a ClientSession object.
- ClientSession* client = new ClientSession(
+ clients_.push_back(base::MakeUnique<ClientSession>(
this, std::move(connection), desktop_environment_factory_,
- max_session_duration_, pairing_registry_, extensions_.get());
-
- clients_.push_back(client);
+ max_session_duration_, pairing_registry_, extensions_.get()));
}
void ChromotingHost::DisconnectAllClients() {

Powered by Google App Engine
This is Rietveld 408576698