| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 70 } |
| 71 | 71 |
| 72 LOG(INFO) << "Starting host"; | 72 LOG(INFO) << "Starting host"; |
| 73 DCHECK(!signal_strategy_.get()); | 73 DCHECK(!signal_strategy_.get()); |
| 74 | 74 |
| 75 // Make sure this object is not started. | 75 // Make sure this object is not started. |
| 76 if (state_ != kInitial) | 76 if (state_ != kInitial) |
| 77 return; | 77 return; |
| 78 state_ = kStarted; | 78 state_ = kStarted; |
| 79 | 79 |
| 80 // Create the session manager. |
| 81 session_manager_.reset( |
| 82 new protocol::JingleSessionManager(context_->network_message_loop())); |
| 83 |
| 80 // Assign key and certificate to server. | 84 // Assign key and certificate to server. |
| 81 if (!key_pair_.Load(config_)) { | 85 if (!key_pair_.Load(config_)) { |
| 82 LOG(ERROR) << "Failed to load key pair for the host."; | 86 LOG(ERROR) << "Failed to load key pair for the host."; |
| 83 return; | 87 return; |
| 84 } | 88 } |
| 85 | 89 |
| 86 // Use an XMPP connection to the Talk network for session signalling. | 90 // Use an XMPP connection to the Talk network for session signalling. |
| 87 std::string xmpp_login; | 91 std::string xmpp_login; |
| 88 std::string xmpp_auth_token; | 92 std::string xmpp_auth_token; |
| 89 std::string xmpp_auth_service; | 93 std::string xmpp_auth_service; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 267 |
| 264 //////////////////////////////////////////////////////////////////////////// | 268 //////////////////////////////////////////////////////////////////////////// |
| 265 // SignalStrategy::StatusObserver implementations | 269 // SignalStrategy::StatusObserver implementations |
| 266 void ChromotingHost::OnStateChange( | 270 void ChromotingHost::OnStateChange( |
| 267 SignalStrategy::StatusObserver::State state) { | 271 SignalStrategy::StatusObserver::State state) { |
| 268 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); | 272 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); |
| 269 | 273 |
| 270 if (state == SignalStrategy::StatusObserver::CONNECTED) { | 274 if (state == SignalStrategy::StatusObserver::CONNECTED) { |
| 271 LOG(INFO) << "Host connected as " << local_jid_; | 275 LOG(INFO) << "Host connected as " << local_jid_; |
| 272 | 276 |
| 273 // Create and start session manager. | 277 // Start the session manager. |
| 274 protocol::JingleSessionManager* server = | 278 session_manager_->Init(local_jid_, signal_strategy_.get(), |
| 275 new protocol::JingleSessionManager(context_->network_message_loop()); | |
| 276 | |
| 277 server->Init(local_jid_, signal_strategy_.get(), | |
| 278 this, allow_nat_traversal_); | 279 this, allow_nat_traversal_); |
| 279 | 280 |
| 280 session_manager_.reset(server); | |
| 281 | |
| 282 for (StatusObserverList::iterator it = status_observers_.begin(); | 281 for (StatusObserverList::iterator it = status_observers_.begin(); |
| 283 it != status_observers_.end(); ++it) { | 282 it != status_observers_.end(); ++it) { |
| 284 (*it)->OnSignallingConnected(signal_strategy_.get(), local_jid_); | 283 (*it)->OnSignallingConnected(signal_strategy_.get(), local_jid_); |
| 285 } | 284 } |
| 286 } else if (state == SignalStrategy::StatusObserver::CLOSED) { | 285 } else if (state == SignalStrategy::StatusObserver::CLOSED) { |
| 287 LOG(INFO) << "Host disconnected from talk network."; | 286 LOG(INFO) << "Host disconnected from talk network."; |
| 288 for (StatusObserverList::iterator it = status_observers_.begin(); | 287 for (StatusObserverList::iterator it = status_observers_.begin(); |
| 289 it != status_observers_.end(); ++it) { | 288 it != status_observers_.end(); ++it) { |
| 290 (*it)->OnSignallingDisconnected(); | 289 (*it)->OnSignallingDisconnected(); |
| 291 } | 290 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 } | 469 } |
| 471 | 470 |
| 472 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); | 471 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); |
| 473 it != shutdown_tasks_.end(); ++it) { | 472 it != shutdown_tasks_.end(); ++it) { |
| 474 it->Run(); | 473 it->Run(); |
| 475 } | 474 } |
| 476 shutdown_tasks_.clear(); | 475 shutdown_tasks_.clear(); |
| 477 } | 476 } |
| 478 | 477 |
| 479 } // namespace remoting | 478 } // namespace remoting |
| OLD | NEW |