| 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/protocol/jingle_session.h" | 5 #include "remoting/protocol/jingle_session.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
| 9 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
| 10 #include "remoting/jingle_glue/channel_socket_adapter.h" | 10 #include "remoting/jingle_glue/channel_socket_adapter.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 const std::string& JingleSession::jid() { | 107 const std::string& JingleSession::jid() { |
| 108 // No synchronization is needed because jid_ is not changed | 108 // No synchronization is needed because jid_ is not changed |
| 109 // after new connection is passed to JingleChromotocolServer callback. | 109 // after new connection is passed to JingleChromotocolServer callback. |
| 110 return jid_; | 110 return jid_; |
| 111 } | 111 } |
| 112 | 112 |
| 113 MessageLoop* JingleSession::message_loop() { | 113 MessageLoop* JingleSession::message_loop() { |
| 114 return jingle_session_manager_->message_loop(); | 114 return jingle_session_manager_->message_loop(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 const CandidateChromotocolConfig* | 117 const CandidateSessionConfig* |
| 118 JingleSession::candidate_config() { | 118 JingleSession::candidate_config() { |
| 119 DCHECK(candidate_config_.get()); | 119 DCHECK(candidate_config_.get()); |
| 120 return candidate_config_.get(); | 120 return candidate_config_.get(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void JingleSession::set_candidate_config( | 123 void JingleSession::set_candidate_config( |
| 124 const CandidateChromotocolConfig* candidate_config) { | 124 const CandidateSessionConfig* candidate_config) { |
| 125 DCHECK(!candidate_config_.get()); | 125 DCHECK(!candidate_config_.get()); |
| 126 DCHECK(candidate_config); | 126 DCHECK(candidate_config); |
| 127 candidate_config_.reset(candidate_config); | 127 candidate_config_.reset(candidate_config); |
| 128 } | 128 } |
| 129 | 129 |
| 130 const ChromotocolConfig* JingleSession::config() { | 130 const SessionConfig* JingleSession::config() { |
| 131 DCHECK(config_.get()); | 131 DCHECK(config_.get()); |
| 132 return config_.get(); | 132 return config_.get(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void JingleSession::set_config(const ChromotocolConfig* config) { | 135 void JingleSession::set_config(const SessionConfig* config) { |
| 136 DCHECK(!config_.get()); | 136 DCHECK(!config_.get()); |
| 137 DCHECK(config); | 137 DCHECK(config); |
| 138 config_.reset(config); | 138 config_.reset(config); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void JingleSession::Close(Task* closed_task) { | 141 void JingleSession::Close(Task* closed_task) { |
| 142 if (MessageLoop::current() != jingle_session_manager_->message_loop()) { | 142 if (MessageLoop::current() != jingle_session_manager_->message_loop()) { |
| 143 jingle_session_manager_->message_loop()->PostTask( | 143 jingle_session_manager_->message_loop()->PostTask( |
| 144 FROM_HERE, NewRunnableMethod(this, &JingleSession::Close, | 144 FROM_HERE, NewRunnableMethod(this, &JingleSession::Close, |
| 145 closed_task)); | 145 closed_task)); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 void JingleSession::OnAccept() { | 274 void JingleSession::OnAccept() { |
| 275 // Set the config if we are the one who initiated the session. | 275 // Set the config if we are the one who initiated the session. |
| 276 if (cricket_session_->initiator()) { | 276 if (cricket_session_->initiator()) { |
| 277 const cricket::ContentInfo* content = | 277 const cricket::ContentInfo* content = |
| 278 cricket_session_->remote_description()->FirstContentByType( | 278 cricket_session_->remote_description()->FirstContentByType( |
| 279 kChromotingXmlNamespace); | 279 kChromotingXmlNamespace); |
| 280 CHECK(content); | 280 CHECK(content); |
| 281 | 281 |
| 282 const protocol::ContentDescription* content_description = | 282 const protocol::ContentDescription* content_description = |
| 283 static_cast<const protocol::ContentDescription*>(content->description); | 283 static_cast<const protocol::ContentDescription*>(content->description); |
| 284 ChromotocolConfig* config = content_description->config()->GetFinalConfig(); | 284 SessionConfig* config = content_description->config()->GetFinalConfig(); |
| 285 | 285 |
| 286 // Terminate the session if the config we received is invalid. | 286 // Terminate the session if the config we received is invalid. |
| 287 if (!config || !candidate_config()->IsSupported(config)) { | 287 if (!config || !candidate_config()->IsSupported(config)) { |
| 288 // TODO(sergeyu): Inform the user that the host is misbehaving? | 288 // TODO(sergeyu): Inform the user that the host is misbehaving? |
| 289 LOG(ERROR) << "Terminating outgoing session after an " | 289 LOG(ERROR) << "Terminating outgoing session after an " |
| 290 "invalid session description has been received."; | 290 "invalid session description has been received."; |
| 291 cricket_session_->Terminate(); | 291 cricket_session_->Terminate(); |
| 292 return; | 292 return; |
| 293 } | 293 } |
| 294 | 294 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 if (new_state != state_) { | 334 if (new_state != state_) { |
| 335 state_ = new_state; | 335 state_ = new_state; |
| 336 if (!closed_ && state_change_callback_.get()) | 336 if (!closed_ && state_change_callback_.get()) |
| 337 state_change_callback_->Run(new_state); | 337 state_change_callback_->Run(new_state); |
| 338 } | 338 } |
| 339 } | 339 } |
| 340 | 340 |
| 341 } // namespace protocol | 341 } // namespace protocol |
| 342 | 342 |
| 343 } // namespace remoting | 343 } // namespace remoting |
| OLD | NEW |