| 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 } | 239 } |
| 240 | 240 |
| 241 void JingleSession::Close() { | 241 void JingleSession::Close() { |
| 242 DCHECK(CalledOnValidThread()); | 242 DCHECK(CalledOnValidThread()); |
| 243 | 243 |
| 244 CloseInternal(OK); | 244 CloseInternal(OK); |
| 245 } | 245 } |
| 246 | 246 |
| 247 void JingleSession::OnTransportCandidate(Transport* transport, | 247 void JingleSession::OnTransportCandidate(Transport* transport, |
| 248 const cricket::Candidate& candidate) { | 248 const cricket::Candidate& candidate) { |
| 249 pending_candidates_.push_back(candidate); | 249 pending_candidates_.push_back(JingleMessage::NamedCandidate( |
| 250 transport->name(), candidate)); |
| 250 | 251 |
| 251 if (!transport_infos_timer_.IsRunning()) { | 252 if (!transport_infos_timer_.IsRunning()) { |
| 252 // Delay sending the new candidates in case we get more candidates | 253 // Delay sending the new candidates in case we get more candidates |
| 253 // that we can send in one message. | 254 // that we can send in one message. |
| 254 transport_infos_timer_.Start( | 255 transport_infos_timer_.Start( |
| 255 FROM_HERE, base::TimeDelta::FromMilliseconds(kTransportInfoSendDelayMs), | 256 FROM_HERE, base::TimeDelta::FromMilliseconds(kTransportInfoSendDelayMs), |
| 256 this, &JingleSession::SendTransportInfo); | 257 this, &JingleSession::SendTransportInfo); |
| 257 } | 258 } |
| 258 } | 259 } |
| 259 | 260 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 return; | 432 return; |
| 432 } | 433 } |
| 433 | 434 |
| 434 reply_callback.Run(JingleMessageReply::NONE); | 435 reply_callback.Run(JingleMessageReply::NONE); |
| 435 | 436 |
| 436 authenticator_->ProcessMessage(message.info.get()); | 437 authenticator_->ProcessMessage(message.info.get()); |
| 437 ProcessAuthenticationStep(); | 438 ProcessAuthenticationStep(); |
| 438 } | 439 } |
| 439 | 440 |
| 440 void JingleSession::ProcessTransportInfo(const JingleMessage& message) { | 441 void JingleSession::ProcessTransportInfo(const JingleMessage& message) { |
| 441 for (std::list<cricket::Candidate>::const_iterator it = | 442 for (std::list<JingleMessage::NamedCandidate>::const_iterator it = |
| 442 message.candidates.begin(); | 443 message.candidates.begin(); |
| 443 it != message.candidates.end(); ++it) { | 444 it != message.candidates.end(); ++it) { |
| 444 ChannelsMap::iterator channel = channels_.find(it->name()); | 445 ChannelsMap::iterator channel = channels_.find(it->name); |
| 445 if (channel == channels_.end()) { | 446 if (channel == channels_.end()) { |
| 446 LOG(WARNING) << "Received candidate for unknown channel " << it->name(); | 447 LOG(WARNING) << "Received candidate for unknown channel " << it->name; |
| 447 continue; | 448 continue; |
| 448 } | 449 } |
| 449 channel->second->AddRemoteCandidate(*it); | 450 channel->second->AddRemoteCandidate(it->candidate); |
| 450 } | 451 } |
| 451 } | 452 } |
| 452 | 453 |
| 453 void JingleSession::OnTerminate(const JingleMessage& message, | 454 void JingleSession::OnTerminate(const JingleMessage& message, |
| 454 const ReplyCallback& reply_callback) { | 455 const ReplyCallback& reply_callback) { |
| 455 if (state_ != CONNECTING && state_ != CONNECTED && state_ != AUTHENTICATED) { | 456 if (state_ != CONNECTING && state_ != CONNECTED && state_ != AUTHENTICATED) { |
| 456 LOG(WARNING) << "Received unexpected session-terminate message."; | 457 LOG(WARNING) << "Received unexpected session-terminate message."; |
| 457 reply_callback.Run(JingleMessageReply::UNEXPECTED_REQUEST); | 458 reply_callback.Run(JingleMessageReply::UNEXPECTED_REQUEST); |
| 458 return; | 459 return; |
| 459 } | 460 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 DCHECK_NE(state_, FAILED); | 582 DCHECK_NE(state_, FAILED); |
| 582 | 583 |
| 583 state_ = new_state; | 584 state_ = new_state; |
| 584 if (!state_change_callback_.is_null()) | 585 if (!state_change_callback_.is_null()) |
| 585 state_change_callback_.Run(new_state); | 586 state_change_callback_.Run(new_state); |
| 586 } | 587 } |
| 587 } | 588 } |
| 588 | 589 |
| 589 } // namespace protocol | 590 } // namespace protocol |
| 590 } // namespace remoting | 591 } // namespace remoting |
| OLD | NEW |