| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
| 8 #include "base/task.h" | 8 #include "base/task.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 FROM_HERE, | 63 FROM_HERE, |
| 64 NewRunnableMethod(this, &ChromotingHost::Start, shutdown_task)); | 64 NewRunnableMethod(this, &ChromotingHost::Start, shutdown_task)); |
| 65 return; | 65 return; |
| 66 } | 66 } |
| 67 | 67 |
| 68 DCHECK(!jingle_client_); | 68 DCHECK(!jingle_client_); |
| 69 DCHECK(shutdown_task); | 69 DCHECK(shutdown_task); |
| 70 | 70 |
| 71 // Make sure this object is not started. | 71 // Make sure this object is not started. |
| 72 { | 72 { |
| 73 AutoLock auto_lock(lock_); | 73 base::AutoLock auto_lock(lock_); |
| 74 if (state_ != kInitial) | 74 if (state_ != kInitial) |
| 75 return; | 75 return; |
| 76 state_ = kStarted; | 76 state_ = kStarted; |
| 77 } | 77 } |
| 78 | 78 |
| 79 // Save the shutdown task. | 79 // Save the shutdown task. |
| 80 shutdown_task_.reset(shutdown_task); | 80 shutdown_task_.reset(shutdown_task); |
| 81 | 81 |
| 82 std::string xmpp_login; | 82 std::string xmpp_login; |
| 83 std::string xmpp_auth_token; | 83 std::string xmpp_auth_token; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 106 void ChromotingHost::Shutdown() { | 106 void ChromotingHost::Shutdown() { |
| 107 if (MessageLoop::current() != context_->main_message_loop()) { | 107 if (MessageLoop::current() != context_->main_message_loop()) { |
| 108 context_->main_message_loop()->PostTask( | 108 context_->main_message_loop()->PostTask( |
| 109 FROM_HERE, | 109 FROM_HERE, |
| 110 NewRunnableMethod(this, &ChromotingHost::Shutdown)); | 110 NewRunnableMethod(this, &ChromotingHost::Shutdown)); |
| 111 return; | 111 return; |
| 112 } | 112 } |
| 113 | 113 |
| 114 // No-op if this object is not started yet. | 114 // No-op if this object is not started yet. |
| 115 { | 115 { |
| 116 AutoLock auto_lock(lock_); | 116 base::AutoLock auto_lock(lock_); |
| 117 if (state_ != kStarted) { | 117 if (state_ != kStarted) { |
| 118 state_ = kStopped; | 118 state_ = kStopped; |
| 119 return; | 119 return; |
| 120 } | 120 } |
| 121 state_ = kStopped; | 121 state_ = kStopped; |
| 122 } | 122 } |
| 123 | 123 |
| 124 // Tell the session to pause and then disconnect all clients. | 124 // Tell the session to pause and then disconnect all clients. |
| 125 if (recorder_.get()) { | 125 if (recorder_.get()) { |
| 126 recorder_->Pause(); | 126 recorder_->Pause(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 257 |
| 258 // TODO(sergeyu): We should try reconnecting here instead of terminating | 258 // TODO(sergeyu): We should try reconnecting here instead of terminating |
| 259 // the host. | 259 // the host. |
| 260 Shutdown(); | 260 Shutdown(); |
| 261 } | 261 } |
| 262 } | 262 } |
| 263 | 263 |
| 264 void ChromotingHost::OnNewClientSession( | 264 void ChromotingHost::OnNewClientSession( |
| 265 protocol::Session* session, | 265 protocol::Session* session, |
| 266 protocol::SessionManager::IncomingSessionResponse* response) { | 266 protocol::SessionManager::IncomingSessionResponse* response) { |
| 267 AutoLock auto_lock(lock_); | 267 base::AutoLock auto_lock(lock_); |
| 268 // TODO(hclam): Allow multiple clients to connect to the host. | 268 // TODO(hclam): Allow multiple clients to connect to the host. |
| 269 if (connection_.get() || state_ != kStarted) { | 269 if (connection_.get() || state_ != kStarted) { |
| 270 *response = protocol::SessionManager::DECLINE; | 270 *response = protocol::SessionManager::DECLINE; |
| 271 return; | 271 return; |
| 272 } | 272 } |
| 273 | 273 |
| 274 // Check that the client has access to the host. | 274 // Check that the client has access to the host. |
| 275 if (!access_verifier_.VerifyPermissions(session->jid(), | 275 if (!access_verifier_.VerifyPermissions(session->jid(), |
| 276 session->initiator_token())) { | 276 session->initiator_token())) { |
| 277 *response = protocol::SessionManager::DECLINE; | 277 *response = protocol::SessionManager::DECLINE; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 return NULL; | 337 return NULL; |
| 338 } | 338 } |
| 339 | 339 |
| 340 std::string ChromotingHost::GenerateHostAuthToken( | 340 std::string ChromotingHost::GenerateHostAuthToken( |
| 341 const std::string& encoded_client_token) { | 341 const std::string& encoded_client_token) { |
| 342 // TODO(ajwong): Return the signature of this instead. | 342 // TODO(ajwong): Return the signature of this instead. |
| 343 return encoded_client_token; | 343 return encoded_client_token; |
| 344 } | 344 } |
| 345 | 345 |
| 346 } // namespace remoting | 346 } // namespace remoting |
| OLD | NEW |