| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 196 |
| 197 // Notify observers that there is at least one authenticated client. | 197 // Notify observers that there is at least one authenticated client. |
| 198 const std::string& jid = client->connection()->session()->jid(); | 198 const std::string& jid = client->connection()->session()->jid(); |
| 199 for (StatusObserverList::iterator it = status_observers_.begin(); | 199 for (StatusObserverList::iterator it = status_observers_.begin(); |
| 200 it != status_observers_.end(); ++it) { | 200 it != status_observers_.end(); ++it) { |
| 201 (*it)->OnClientAuthenticated(jid); | 201 (*it)->OnClientAuthenticated(jid); |
| 202 } | 202 } |
| 203 // TODO(jamiewalch): Tidy up actions to be taken on connect/disconnect, | 203 // TODO(jamiewalch): Tidy up actions to be taken on connect/disconnect, |
| 204 // including closing the connection on failure of a critical operation. | 204 // including closing the connection on failure of a critical operation. |
| 205 EnableCurtainMode(true); | 205 EnableCurtainMode(true); |
| 206 | |
| 207 std::string username = jid.substr(0, jid.find('/')); | |
| 208 desktop_environment_->OnConnect(username); | |
| 209 } | 206 } |
| 210 | 207 |
| 211 void ChromotingHost::OnSessionClosed(ClientSession* client) { | 208 void ChromotingHost::OnSessionClosed(ClientSession* client) { |
| 212 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); | 209 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); |
| 213 | 210 |
| 214 scoped_ptr<ClientSession> client_destroyer(client); | 211 scoped_ptr<ClientSession> client_destroyer(client); |
| 215 | 212 |
| 216 ClientList::iterator it = std::find(clients_.begin(), clients_.end(), client); | 213 ClientList::iterator it = std::find(clients_.begin(), clients_.end(), client); |
| 217 CHECK(it != clients_.end()); | 214 CHECK(it != clients_.end()); |
| 218 clients_.erase(it); | 215 clients_.erase(it); |
| 219 | 216 |
| 220 if (recorder_.get()) { | 217 if (recorder_.get()) { |
| 221 recorder_->RemoveConnection(client->connection()); | 218 recorder_->RemoveConnection(client->connection()); |
| 222 } | 219 } |
| 223 | 220 |
| 224 for (StatusObserverList::iterator it = status_observers_.begin(); | 221 for (StatusObserverList::iterator it = status_observers_.begin(); |
| 225 it != status_observers_.end(); ++it) { | 222 it != status_observers_.end(); ++it) { |
| 226 (*it)->OnClientDisconnected(client->client_jid()); | 223 (*it)->OnClientDisconnected(client->client_jid()); |
| 227 } | 224 } |
| 228 | 225 |
| 229 if (AuthenticatedClientsCount() == 0) { | 226 if (AuthenticatedClientsCount() == 0) { |
| 230 if (recorder_.get()) { | 227 if (recorder_.get()) { |
| 231 // Stop the recorder if there are no more clients. | 228 // Stop the recorder if there are no more clients. |
| 232 StopScreenRecorder(); | 229 StopScreenRecorder(); |
| 233 } | 230 } |
| 234 | 231 |
| 235 // Disable the "curtain" if there are no more active clients. | 232 // Disable the "curtain" if there are no more active clients. |
| 236 EnableCurtainMode(false); | 233 EnableCurtainMode(false); |
| 237 desktop_environment_->OnLastDisconnect(); | |
| 238 } | 234 } |
| 239 } | 235 } |
| 240 | 236 |
| 241 void ChromotingHost::OnSessionSequenceNumber(ClientSession* session, | 237 void ChromotingHost::OnSessionSequenceNumber(ClientSession* session, |
| 242 int64 sequence_number) { | 238 int64 sequence_number) { |
| 243 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); | 239 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); |
| 244 if (recorder_.get()) | 240 if (recorder_.get()) |
| 245 recorder_->UpdateSequenceNumber(sequence_number); | 241 recorder_->UpdateSequenceNumber(sequence_number); |
| 246 } | 242 } |
| 247 | 243 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 if (!context_->network_message_loop()->BelongsToCurrentThread()) { | 382 if (!context_->network_message_loop()->BelongsToCurrentThread()) { |
| 387 context_->network_message_loop()->PostTask( | 383 context_->network_message_loop()->PostTask( |
| 388 FROM_HERE, base::Bind(&ChromotingHost::PauseSession, this, pause)); | 384 FROM_HERE, base::Bind(&ChromotingHost::PauseSession, this, pause)); |
| 389 return; | 385 return; |
| 390 } | 386 } |
| 391 | 387 |
| 392 ClientList::iterator client; | 388 ClientList::iterator client; |
| 393 for (client = clients_.begin(); client != clients_.end(); ++client) { | 389 for (client = clients_.begin(); client != clients_.end(); ++client) { |
| 394 (*client)->set_awaiting_continue_approval(pause); | 390 (*client)->set_awaiting_continue_approval(pause); |
| 395 } | 391 } |
| 396 desktop_environment_->OnPause(pause); | |
| 397 } | 392 } |
| 398 | 393 |
| 399 void ChromotingHost::SetUiStrings(const UiStrings& ui_strings) { | 394 void ChromotingHost::SetUiStrings(const UiStrings& ui_strings) { |
| 400 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current()); | 395 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current()); |
| 401 DCHECK_EQ(state_, kInitial); | 396 DCHECK_EQ(state_, kInitial); |
| 402 | 397 |
| 403 ui_strings_ = ui_strings; | 398 ui_strings_ = ui_strings; |
| 404 } | 399 } |
| 405 | 400 |
| 406 // TODO(sergeyu): Move this to SessionManager? | 401 // TODO(sergeyu): Move this to SessionManager? |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 } | 481 } |
| 487 | 482 |
| 488 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); | 483 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); |
| 489 it != shutdown_tasks_.end(); ++it) { | 484 it != shutdown_tasks_.end(); ++it) { |
| 490 it->Run(); | 485 it->Run(); |
| 491 } | 486 } |
| 492 shutdown_tasks_.clear(); | 487 shutdown_tasks_.clear(); |
| 493 } | 488 } |
| 494 | 489 |
| 495 } // namespace remoting | 490 } // namespace remoting |
| OLD | NEW |