| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/host/chromoting_host.h" | 5 #include "remoting/host/chromoting_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 session_manager_->set_authenticator_factory(authenticator_factory.Pass()); | 174 session_manager_->set_authenticator_factory(authenticator_factory.Pass()); |
| 175 } | 175 } |
| 176 | 176 |
| 177 void ChromotingHost::SetMaximumSessionDuration( | 177 void ChromotingHost::SetMaximumSessionDuration( |
| 178 const base::TimeDelta& max_session_duration) { | 178 const base::TimeDelta& max_session_duration) { |
| 179 max_session_duration_ = max_session_duration; | 179 max_session_duration_ = max_session_duration; |
| 180 } | 180 } |
| 181 | 181 |
| 182 //////////////////////////////////////////////////////////////////////////// | 182 //////////////////////////////////////////////////////////////////////////// |
| 183 // protocol::ClientSession::EventHandler implementation. | 183 // protocol::ClientSession::EventHandler implementation. |
| 184 void ChromotingHost::OnSessionAuthenticated(ClientSession* client) { | 184 bool ChromotingHost::OnSessionAuthenticated(ClientSession* client) { |
| 185 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 185 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 186 | 186 |
| 187 login_backoff_.Reset(); | 187 login_backoff_.Reset(); |
| 188 | 188 |
| 189 // Disconnect all other clients. |it| should be advanced before Disconnect() | 189 // Disconnect all other clients. |it| should be advanced before Disconnect() |
| 190 // is called to avoid it becoming invalid when the client is removed from | 190 // is called to avoid it becoming invalid when the client is removed from |
| 191 // the list. | 191 // the list. |
| 192 ClientList::iterator it = clients_.begin(); | 192 ClientList::iterator it = clients_.begin(); |
| 193 while (it != clients_.end()) { | 193 while (it != clients_.end()) { |
| 194 ClientSession* other_client = *it++; | 194 ClientSession* other_client = *it++; |
| 195 if (other_client != client) | 195 if (other_client != client) |
| 196 other_client->DisconnectSession(); | 196 other_client->DisconnectSession(); |
| 197 } | 197 } |
| 198 | 198 |
| 199 // Disconnects above must have destroyed all other clients. | 199 // Disconnects above must have destroyed all other clients. |
| 200 DCHECK_EQ(clients_.size(), 1U); | 200 DCHECK_EQ(clients_.size(), 1U); |
| 201 | 201 |
| 202 // Notify observers that there is at least one authenticated client. | 202 // Notify observers that there is at least one authenticated client. |
| 203 const std::string& jid = client->client_jid(); | 203 const std::string& jid = client->client_jid(); |
| 204 | 204 |
| 205 reject_authenticating_client_ = false; | 205 reject_authenticating_client_ = false; |
| 206 | 206 |
| 207 authenticating_client_ = true; | 207 authenticating_client_ = true; |
| 208 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 208 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, |
| 209 OnClientAuthenticated(jid)); | 209 OnClientAuthenticated(jid)); |
| 210 authenticating_client_ = false; | 210 authenticating_client_ = false; |
| 211 | 211 |
| 212 if (reject_authenticating_client_) { | 212 return !reject_authenticating_client_; |
| 213 client->DisconnectSession(); | |
| 214 } | |
| 215 } | 213 } |
| 216 | 214 |
| 217 void ChromotingHost::OnSessionChannelsConnected(ClientSession* client) { | 215 void ChromotingHost::OnSessionChannelsConnected(ClientSession* client) { |
| 218 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 216 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
| 219 | 217 |
| 220 // Notify observers. | 218 // Notify observers. |
| 221 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 219 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, |
| 222 OnClientConnected(client->client_jid())); | 220 OnClientConnected(client->client_jid())); |
| 223 } | 221 } |
| 224 | 222 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); | 366 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); |
| 369 it != shutdown_tasks_.end(); ++it) { | 367 it != shutdown_tasks_.end(); ++it) { |
| 370 it->Run(); | 368 it->Run(); |
| 371 } | 369 } |
| 372 shutdown_tasks_.clear(); | 370 shutdown_tasks_.clear(); |
| 373 | 371 |
| 374 weak_factory_.InvalidateWeakPtrs(); | 372 weak_factory_.InvalidateWeakPtrs(); |
| 375 } | 373 } |
| 376 | 374 |
| 377 } // namespace remoting | 375 } // namespace remoting |
| OLD | NEW |