| 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/protocol/jingle_session.h" | 5 #include "remoting/protocol/jingle_session.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 } else { | 336 } else { |
| 337 LOG(ERROR) << "Failed to send a " | 337 LOG(ERROR) << "Failed to send a " |
| 338 << JingleMessage::GetActionName(message.action) << " message"; | 338 << JingleMessage::GetActionName(message.action) << " message"; |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 | 341 |
| 342 void JingleSession::OnMessageResponse( | 342 void JingleSession::OnMessageResponse( |
| 343 JingleMessage::ActionType request_type, | 343 JingleMessage::ActionType request_type, |
| 344 IqRequest* request, | 344 IqRequest* request, |
| 345 const buzz::XmlElement* response) { | 345 const buzz::XmlElement* response) { |
| 346 std::string type_str = JingleMessage::GetActionName(request_type); | |
| 347 | |
| 348 // Delete the request from the list of pending requests. | 346 // Delete the request from the list of pending requests. |
| 349 pending_requests_.erase(request); | 347 pending_requests_.erase(request); |
| 350 delete request; | 348 delete request; |
| 351 | 349 |
| 350 // Ignore all responses after session was closed. |
| 351 if (state_ == CLOSED || state_ == FAILED) |
| 352 return; |
| 353 |
| 354 std::string type_str = JingleMessage::GetActionName(request_type); |
| 355 |
| 352 // |response| will be NULL if the request timed out. | 356 // |response| will be NULL if the request timed out. |
| 353 if (!response) { | 357 if (!response) { |
| 354 LOG(ERROR) << type_str << " request timed out."; | 358 LOG(ERROR) << type_str << " request timed out."; |
| 355 CloseInternal(SIGNALING_TIMEOUT); | 359 CloseInternal(SIGNALING_TIMEOUT); |
| 356 return; | 360 return; |
| 357 } else { | 361 } else { |
| 358 const std::string& type = | 362 const std::string& type = |
| 359 response->Attr(buzz::QName(std::string(), "type")); | 363 response->Attr(buzz::QName(std::string(), "type")); |
| 360 if (type != "result") { | 364 if (type != "result") { |
| 361 LOG(ERROR) << "Received error in response to " << type_str | 365 LOG(ERROR) << "Received error in response to " << type_str |
| 362 << " message: \"" << response->Str() | 366 << " message: \"" << response->Str() |
| 363 << "\". Terminating the session."; | 367 << "\". Terminating the session."; |
| 364 | 368 |
| 365 switch (request_type) { | 369 // TODO(sergeyu): There may be different reasons for error |
| 366 case JingleMessage::SESSION_INFO: | 370 // here. Parse the response stanza to find failure reason. |
| 367 // session-info is used for the new authentication protocol, | 371 CloseInternal(PEER_IS_OFFLINE); |
| 368 // and wasn't previously supported. | |
| 369 CloseInternal(INCOMPATIBLE_PROTOCOL); | |
| 370 break; | |
| 371 | |
| 372 default: | |
| 373 // TODO(sergeyu): There may be different reasons for error | |
| 374 // here. Parse the response stanza to find failure reason. | |
| 375 CloseInternal(PEER_IS_OFFLINE); | |
| 376 } | |
| 377 } | 372 } |
| 378 } | 373 } |
| 379 } | 374 } |
| 380 | 375 |
| 381 void JingleSession::SendTransportInfo() { | 376 void JingleSession::SendTransportInfo() { |
| 382 JingleMessage message(peer_jid_, JingleMessage::TRANSPORT_INFO, session_id_); | 377 JingleMessage message(peer_jid_, JingleMessage::TRANSPORT_INFO, session_id_); |
| 383 message.candidates.swap(pending_candidates_); | 378 message.candidates.swap(pending_candidates_); |
| 384 | 379 |
| 385 scoped_ptr<IqRequest> request = session_manager_->iq_sender()->SendIq( | 380 scoped_ptr<IqRequest> request = session_manager_->iq_sender()->SendIq( |
| 386 message.ToXml(), | 381 message.ToXml(), |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 } | 675 } |
| 681 } | 676 } |
| 682 | 677 |
| 683 bool JingleSession::is_session_active() { | 678 bool JingleSession::is_session_active() { |
| 684 return state_ == CONNECTING || state_ == ACCEPTING || state_ == CONNECTED || | 679 return state_ == CONNECTING || state_ == ACCEPTING || state_ == CONNECTED || |
| 685 state_ == AUTHENTICATING || state_ == AUTHENTICATED; | 680 state_ == AUTHENTICATING || state_ == AUTHENTICATED; |
| 686 } | 681 } |
| 687 | 682 |
| 688 } // namespace protocol | 683 } // namespace protocol |
| 689 } // namespace remoting | 684 } // namespace remoting |
| OLD | NEW |