| 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 "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 21 matching lines...) Expand all Loading... |
| 32 namespace remoting { | 32 namespace remoting { |
| 33 | 33 |
| 34 ChromotingHost::ChromotingHost( | 34 ChromotingHost::ChromotingHost( |
| 35 ChromotingHostContext* context, | 35 ChromotingHostContext* context, |
| 36 SignalStrategy* signal_strategy, | 36 SignalStrategy* signal_strategy, |
| 37 DesktopEnvironment* environment, | 37 DesktopEnvironment* environment, |
| 38 const protocol::NetworkSettings& network_settings) | 38 const protocol::NetworkSettings& network_settings) |
| 39 : context_(context), | 39 : context_(context), |
| 40 desktop_environment_(environment), | 40 desktop_environment_(environment), |
| 41 network_settings_(network_settings), | 41 network_settings_(network_settings), |
| 42 have_shared_secret_(false), | |
| 43 signal_strategy_(signal_strategy), | 42 signal_strategy_(signal_strategy), |
| 44 stopping_recorders_(0), | 43 stopping_recorders_(0), |
| 45 state_(kInitial), | 44 state_(kInitial), |
| 46 protocol_config_(protocol::CandidateSessionConfig::CreateDefault()), | 45 protocol_config_(protocol::CandidateSessionConfig::CreateDefault()), |
| 47 authenticating_client_(false), | 46 authenticating_client_(false), |
| 48 reject_authenticating_client_(false) { | 47 reject_authenticating_client_(false) { |
| 49 DCHECK(context_); | 48 DCHECK(context_); |
| 50 DCHECK(signal_strategy); | 49 DCHECK(signal_strategy); |
| 51 DCHECK(desktop_environment_); | 50 DCHECK(desktop_environment_); |
| 52 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); | 51 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 shutdown_tasks_.push_back(shutdown_task); | 93 shutdown_tasks_.push_back(shutdown_task); |
| 95 if (state_ == kStopping) | 94 if (state_ == kStopping) |
| 96 return; | 95 return; |
| 97 state_ = kStopping; | 96 state_ = kStopping; |
| 98 | 97 |
| 99 // Disconnect all of the clients, implicitly stopping the ScreenRecorder. | 98 // Disconnect all of the clients, implicitly stopping the ScreenRecorder. |
| 100 while (!clients_.empty()) { | 99 while (!clients_.empty()) { |
| 101 clients_.front()->Disconnect(); | 100 clients_.front()->Disconnect(); |
| 102 } | 101 } |
| 103 | 102 |
| 104 // Stop session manager. | 103 // Destroy session manager. |
| 105 if (session_manager_.get()) { | 104 session_manager_.reset(); |
| 106 session_manager_->Close(); | |
| 107 // It may not be safe to delete |session_manager_| here becase | |
| 108 // this method may be invoked in response to a libjingle event and | |
| 109 // libjingle's sigslot doesn't handle it properly, so postpone the | |
| 110 // deletion. | |
| 111 context_->network_message_loop()->DeleteSoon( | |
| 112 FROM_HERE, session_manager_.release()); | |
| 113 have_shared_secret_ = false; | |
| 114 } | |
| 115 | 105 |
| 106 // Stop screen recorder |
| 116 if (recorder_.get()) { | 107 if (recorder_.get()) { |
| 117 StopScreenRecorder(); | 108 StopScreenRecorder(); |
| 118 } else if (!stopping_recorders_) { | 109 } else if (!stopping_recorders_) { |
| 119 ShutdownFinish(); | 110 ShutdownFinish(); |
| 120 } | 111 } |
| 121 } | 112 } |
| 122 | 113 |
| 123 void ChromotingHost::AddStatusObserver(HostStatusObserver* observer) { | 114 void ChromotingHost::AddStatusObserver(HostStatusObserver* observer) { |
| 124 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); | 115 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); |
| 125 status_observers_.AddObserver(observer); | 116 status_observers_.AddObserver(observer); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 OnShutdown()); | 365 OnShutdown()); |
| 375 | 366 |
| 376 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); | 367 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); |
| 377 it != shutdown_tasks_.end(); ++it) { | 368 it != shutdown_tasks_.end(); ++it) { |
| 378 it->Run(); | 369 it->Run(); |
| 379 } | 370 } |
| 380 shutdown_tasks_.clear(); | 371 shutdown_tasks_.clear(); |
| 381 } | 372 } |
| 382 | 373 |
| 383 } // namespace remoting | 374 } // namespace remoting |
| OLD | NEW |