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/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 auth_message.Pass())); | 174 auth_message.Pass())); |
175 SendMessage(message); | 175 SendMessage(message); |
176 | 176 |
177 // Update state. | 177 // Update state. |
178 SetState(CONNECTED); | 178 SetState(CONNECTED); |
179 | 179 |
180 if (authenticator_->state() == Authenticator::ACCEPTED) { | 180 if (authenticator_->state() == Authenticator::ACCEPTED) { |
181 SetState(AUTHENTICATED); | 181 SetState(AUTHENTICATED); |
182 } else { | 182 } else { |
183 DCHECK_EQ(authenticator_->state(), Authenticator::WAITING_MESSAGE); | 183 DCHECK_EQ(authenticator_->state(), Authenticator::WAITING_MESSAGE); |
184 if (authenticator_->has_auth_started()) { | |
185 event_handler_->OnSessionAuthenticationBegin(); | |
186 } | |
184 } | 187 } |
185 | 188 |
186 return; | 189 return; |
187 } | 190 } |
188 | 191 |
189 const std::string& JingleSession::jid() { | 192 const std::string& JingleSession::jid() { |
190 DCHECK(CalledOnValidThread()); | 193 DCHECK(CalledOnValidThread()); |
191 return peer_jid_; | 194 return peer_jid_; |
192 } | 195 } |
193 | 196 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
488 if (state_ != CONNECTED || | 491 if (state_ != CONNECTED || |
489 authenticator_->state() != Authenticator::WAITING_MESSAGE) { | 492 authenticator_->state() != Authenticator::WAITING_MESSAGE) { |
490 LOG(WARNING) << "Received unexpected authenticator message " | 493 LOG(WARNING) << "Received unexpected authenticator message " |
491 << message.info->Str(); | 494 << message.info->Str(); |
492 reply_callback.Run(JingleMessageReply::UNEXPECTED_REQUEST); | 495 reply_callback.Run(JingleMessageReply::UNEXPECTED_REQUEST); |
493 CloseInternal(INCOMPATIBLE_PROTOCOL); | 496 CloseInternal(INCOMPATIBLE_PROTOCOL); |
494 return; | 497 return; |
495 } | 498 } |
496 | 499 |
497 reply_callback.Run(JingleMessageReply::NONE); | 500 reply_callback.Run(JingleMessageReply::NONE); |
498 | |
Sergey Ulanov
2014/03/24 18:42:36
nit: keep this empty line
kelvinp
2014/03/24 23:11:39
Done.
| |
499 authenticator_->ProcessMessage(message.info.get(), base::Bind( | 501 authenticator_->ProcessMessage(message.info.get(), base::Bind( |
500 &JingleSession::ProcessAuthenticationStep, base::Unretained(this))); | 502 &JingleSession::ProcessAuthenticationStep, base::Unretained(this))); |
501 } | 503 } |
502 | 504 |
503 void JingleSession::ProcessTransportInfo(const JingleMessage& message) { | 505 void JingleSession::ProcessTransportInfo(const JingleMessage& message) { |
504 for (std::list<JingleMessage::NamedCandidate>::const_iterator it = | 506 for (std::list<JingleMessage::NamedCandidate>::const_iterator it = |
505 message.candidates.begin(); | 507 message.candidates.begin(); |
506 it != message.candidates.end(); ++it) { | 508 it != message.candidates.end(); ++it) { |
507 ChannelsMap::iterator channel = channels_.find(it->name); | 509 ChannelsMap::iterator channel = channels_.find(it->name); |
508 if (channel != channels_.end()) { | 510 if (channel != channels_.end()) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 DCHECK(CalledOnValidThread()); | 579 DCHECK(CalledOnValidThread()); |
578 DCHECK_NE(authenticator_->state(), Authenticator::PROCESSING_MESSAGE); | 580 DCHECK_NE(authenticator_->state(), Authenticator::PROCESSING_MESSAGE); |
579 | 581 |
580 if (state_ != CONNECTED) { | 582 if (state_ != CONNECTED) { |
581 DCHECK(state_ == FAILED || state_ == CLOSED); | 583 DCHECK(state_ == FAILED || state_ == CLOSED); |
582 // The remote host closed the connection while the authentication was being | 584 // The remote host closed the connection while the authentication was being |
583 // processed asynchronously, nothing to do. | 585 // processed asynchronously, nothing to do. |
584 return; | 586 return; |
585 } | 587 } |
586 | 588 |
589 if (authenticator_->has_auth_started()) { | |
590 event_handler_->OnSessionAuthenticationBegin(); | |
591 } | |
592 | |
587 if (authenticator_->state() == Authenticator::MESSAGE_READY) { | 593 if (authenticator_->state() == Authenticator::MESSAGE_READY) { |
588 JingleMessage message(peer_jid_, JingleMessage::SESSION_INFO, session_id_); | 594 JingleMessage message(peer_jid_, JingleMessage::SESSION_INFO, session_id_); |
589 message.info = authenticator_->GetNextMessage(); | 595 message.info = authenticator_->GetNextMessage(); |
590 DCHECK(message.info.get()); | 596 DCHECK(message.info.get()); |
591 SendMessage(message); | 597 SendMessage(message); |
592 } | 598 } |
593 DCHECK_NE(authenticator_->state(), Authenticator::MESSAGE_READY); | 599 DCHECK_NE(authenticator_->state(), Authenticator::MESSAGE_READY); |
594 | 600 |
595 if (authenticator_->state() == Authenticator::ACCEPTED) { | 601 if (authenticator_->state() == Authenticator::ACCEPTED) { |
596 SetState(AUTHENTICATED); | 602 SetState(AUTHENTICATED); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
641 } | 647 } |
642 } | 648 } |
643 } | 649 } |
644 | 650 |
645 void JingleSession::SetState(State new_state) { | 651 void JingleSession::SetState(State new_state) { |
646 DCHECK(CalledOnValidThread()); | 652 DCHECK(CalledOnValidThread()); |
647 | 653 |
648 if (new_state != state_) { | 654 if (new_state != state_) { |
649 DCHECK_NE(state_, CLOSED); | 655 DCHECK_NE(state_, CLOSED); |
650 DCHECK_NE(state_, FAILED); | 656 DCHECK_NE(state_, FAILED); |
651 | |
Sergey Ulanov
2014/03/24 18:42:36
nit: keep this line
kelvinp
2014/03/24 23:11:39
Done.
| |
652 state_ = new_state; | 657 state_ = new_state; |
653 if (event_handler_) | 658 if (event_handler_) |
654 event_handler_->OnSessionStateChange(new_state); | 659 event_handler_->OnSessionStateChange(new_state); |
655 } | 660 } |
656 } | 661 } |
657 | 662 |
658 } // namespace protocol | 663 } // namespace protocol |
659 } // namespace remoting | 664 } // namespace remoting |
OLD | NEW |