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/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 } | 543 } |
544 if (!candidate_config()->IsSupported(config_)) { | 544 if (!candidate_config()->IsSupported(config_)) { |
545 LOG(ERROR) << "session-accept specifies an invalid configuration"; | 545 LOG(ERROR) << "session-accept specifies an invalid configuration"; |
546 return false; | 546 return false; |
547 } | 547 } |
548 | 548 |
549 return true; | 549 return true; |
550 } | 550 } |
551 | 551 |
552 void JingleSession::ProcessAuthenticationStep() { | 552 void JingleSession::ProcessAuthenticationStep() { |
| 553 DCHECK(CalledOnValidThread()); |
553 DCHECK_EQ(state_, CONNECTED); | 554 DCHECK_EQ(state_, CONNECTED); |
554 | 555 |
555 if (authenticator_->state() == Authenticator::MESSAGE_READY) { | 556 if (authenticator_->state() == Authenticator::MESSAGE_READY) { |
556 JingleMessage message(peer_jid_, JingleMessage::SESSION_INFO, session_id_); | 557 JingleMessage message(peer_jid_, JingleMessage::SESSION_INFO, session_id_); |
557 message.info = authenticator_->GetNextMessage(); | 558 message.info = authenticator_->GetNextMessage(); |
558 DCHECK(message.info.get()); | 559 DCHECK(message.info.get()); |
559 SendMessage(message); | 560 SendMessage(message); |
560 } | 561 } |
561 DCHECK_NE(authenticator_->state(), Authenticator::MESSAGE_READY); | 562 DCHECK_NE(authenticator_->state(), Authenticator::MESSAGE_READY); |
562 | 563 |
563 if (authenticator_->state() == Authenticator::ACCEPTED) { | 564 if (authenticator_->state() == Authenticator::ACCEPTED) { |
564 SetState(AUTHENTICATED); | 565 SetState(AUTHENTICATED); |
565 } else if (authenticator_->state() == Authenticator::REJECTED) { | 566 } else if (authenticator_->state() == Authenticator::REJECTED) { |
566 CloseInternal(AuthRejectionReasonToErrorCode( | 567 CloseInternal(AuthRejectionReasonToErrorCode( |
567 authenticator_->rejection_reason())); | 568 authenticator_->rejection_reason())); |
| 569 } else if (authenticator_->state() == Authenticator::WAITING_EXTERNAL) { |
| 570 authenticator_->PerformExternalAction(base::Bind( |
| 571 &JingleSession::ProcessAuthenticationStep, |
| 572 // Authenticator is owned by JingleSession, and cannot outlive it. |
| 573 base::Unretained(this))); |
568 } | 574 } |
569 } | 575 } |
570 | 576 |
571 void JingleSession::CloseInternal(ErrorCode error) { | 577 void JingleSession::CloseInternal(ErrorCode error) { |
572 DCHECK(CalledOnValidThread()); | 578 DCHECK(CalledOnValidThread()); |
573 | 579 |
574 if (state_ == CONNECTING || state_ == CONNECTED || state_ == AUTHENTICATED) { | 580 if (state_ == CONNECTING || state_ == CONNECTED || state_ == AUTHENTICATED) { |
575 // Send session-terminate message with the appropriate error code. | 581 // Send session-terminate message with the appropriate error code. |
576 JingleMessage::Reason reason; | 582 JingleMessage::Reason reason; |
577 switch (error) { | 583 switch (error) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 DCHECK_NE(state_, FAILED); | 623 DCHECK_NE(state_, FAILED); |
618 | 624 |
619 state_ = new_state; | 625 state_ = new_state; |
620 if (event_handler_) | 626 if (event_handler_) |
621 event_handler_->OnSessionStateChange(new_state); | 627 event_handler_->OnSessionStateChange(new_state); |
622 } | 628 } |
623 } | 629 } |
624 | 630 |
625 } // namespace protocol | 631 } // namespace protocol |
626 } // namespace remoting | 632 } // namespace remoting |
OLD | NEW |