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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <memory> | 10 #include <memory> |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 DCHECK(event_handler); | 190 DCHECK(event_handler); |
191 event_handler_ = event_handler; | 191 event_handler_ = event_handler; |
192 } | 192 } |
193 | 193 |
194 ErrorCode JingleSession::error() { | 194 ErrorCode JingleSession::error() { |
195 DCHECK(thread_checker_.CalledOnValidThread()); | 195 DCHECK(thread_checker_.CalledOnValidThread()); |
196 return error_; | 196 return error_; |
197 } | 197 } |
198 | 198 |
199 void JingleSession::StartConnection( | 199 void JingleSession::StartConnection( |
200 const std::string& peer_jid, | 200 const SignalingAddress& peer_address, |
201 std::unique_ptr<Authenticator> authenticator) { | 201 std::unique_ptr<Authenticator> authenticator) { |
202 DCHECK(thread_checker_.CalledOnValidThread()); | 202 DCHECK(thread_checker_.CalledOnValidThread()); |
203 DCHECK(authenticator.get()); | 203 DCHECK(authenticator.get()); |
204 DCHECK_EQ(authenticator->state(), Authenticator::MESSAGE_READY); | 204 DCHECK_EQ(authenticator->state(), Authenticator::MESSAGE_READY); |
205 | 205 |
206 peer_address_ = SignalingAddress(peer_jid); | 206 peer_address_ = peer_address; |
207 authenticator_ = std::move(authenticator); | 207 authenticator_ = std::move(authenticator); |
208 | 208 |
209 // Generate random session ID. There are usually not more than 1 | 209 // Generate random session ID. There are usually not more than 1 |
210 // concurrent session per host, so a random 64-bit integer provides | 210 // concurrent session per host, so a random 64-bit integer provides |
211 // enough entropy. In the worst case connection will fail when two | 211 // enough entropy. In the worst case connection will fail when two |
212 // clients generate the same session ID concurrently. | 212 // clients generate the same session ID concurrently. |
213 session_id_ = base::Uint64ToString( | 213 session_id_ = base::Uint64ToString( |
214 base::RandGenerator(std::numeric_limits<uint64_t>::max())); | 214 base::RandGenerator(std::numeric_limits<uint64_t>::max())); |
215 | 215 |
216 // Delay sending session-initiate message to ensure SessionPlugin can be | 216 // Delay sending session-initiate message to ensure SessionPlugin can be |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 } | 785 } |
786 } | 786 } |
787 } | 787 } |
788 | 788 |
789 void JingleSession::SendSessionInitiateMessage() { | 789 void JingleSession::SendSessionInitiateMessage() { |
790 if (state_ != CONNECTING) { | 790 if (state_ != CONNECTING) { |
791 return; | 791 return; |
792 } | 792 } |
793 std::unique_ptr<JingleMessage> message(new JingleMessage( | 793 std::unique_ptr<JingleMessage> message(new JingleMessage( |
794 peer_address_, JingleMessage::SESSION_INITIATE, session_id_)); | 794 peer_address_, JingleMessage::SESSION_INITIATE, session_id_)); |
795 message->initiator = session_manager_->signal_strategy_->GetLocalJid(); | 795 message->initiator = |
| 796 session_manager_->signal_strategy_->GetLocalAddress().jid(); |
796 message->description.reset(new ContentDescription( | 797 message->description.reset(new ContentDescription( |
797 session_manager_->protocol_config_->Clone(), | 798 session_manager_->protocol_config_->Clone(), |
798 authenticator_->GetNextMessage())); | 799 authenticator_->GetNextMessage())); |
799 SendMessage(std::move(message)); | 800 SendMessage(std::move(message)); |
800 } | 801 } |
801 | 802 |
802 std::string JingleSession::GetNextOutgoingId() { | 803 std::string JingleSession::GetNextOutgoingId() { |
803 return outgoing_id_prefix_ + "_" + base::IntToString(++next_outgoing_id_); | 804 return outgoing_id_prefix_ + "_" + base::IntToString(++next_outgoing_id_); |
804 } | 805 } |
805 | 806 |
806 } // namespace protocol | 807 } // namespace protocol |
807 } // namespace remoting | 808 } // namespace remoting |
OLD | NEW |