| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "crypto/hmac.h" | 9 #include "crypto/hmac.h" |
| 10 #include "crypto/rsa_private_key.h" | 10 #include "crypto/rsa_private_key.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 if (local_private_key) { | 152 if (local_private_key) { |
| 153 std::vector<uint8> key_bytes; | 153 std::vector<uint8> key_bytes; |
| 154 CHECK(local_private_key->ExportPrivateKey(&key_bytes)); | 154 CHECK(local_private_key->ExportPrivateKey(&key_bytes)); |
| 155 local_private_key_.reset( | 155 local_private_key_.reset( |
| 156 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_bytes)); | 156 crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_bytes)); |
| 157 CHECK(local_private_key_.get()); | 157 CHECK(local_private_key_.get()); |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 JingleSession::~JingleSession() { | 161 JingleSession::~JingleSession() { |
| 162 DCHECK(closed_); | 162 // Reset the callback so that it's not called from Close(). |
| 163 state_change_callback_.reset(); |
| 164 Close(); |
| 163 jingle_session_manager_->SessionDestroyed(this); | 165 jingle_session_manager_->SessionDestroyed(this); |
| 164 } | 166 } |
| 165 | 167 |
| 166 void JingleSession::Init(cricket::Session* cricket_session) { | 168 void JingleSession::Init(cricket::Session* cricket_session) { |
| 167 DCHECK(CalledOnValidThread()); | 169 DCHECK(CalledOnValidThread()); |
| 168 | 170 |
| 169 cricket_session_ = cricket_session; | 171 cricket_session_ = cricket_session; |
| 170 jid_ = cricket_session_->remote_name(); | 172 jid_ = cricket_session_->remote_name(); |
| 171 cert_verifier_.reset(new net::CertVerifier()); | 173 cert_verifier_.reset(new net::CertVerifier()); |
| 172 cricket_session_->SignalState.connect( | 174 cricket_session_->SignalState.connect( |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 new jingle_glue::TransportChannelSocketAdapter(raw_event_channel_)); | 442 new jingle_glue::TransportChannelSocketAdapter(raw_event_channel_)); |
| 441 | 443 |
| 442 // Create video channel. | 444 // Create video channel. |
| 443 // TODO(wez): When we have RTP video support, we'll need to negotiate the | 445 // TODO(wez): When we have RTP video support, we'll need to negotiate the |
| 444 // type of video channel to allocate, for legacy compatibility. | 446 // type of video channel to allocate, for legacy compatibility. |
| 445 raw_video_channel_ = | 447 raw_video_channel_ = |
| 446 cricket_session_->CreateChannel(content_name, kVideoChannelName); | 448 cricket_session_->CreateChannel(content_name, kVideoChannelName); |
| 447 video_channel_.reset( | 449 video_channel_.reset( |
| 448 new jingle_glue::TransportChannelSocketAdapter(raw_video_channel_)); | 450 new jingle_glue::TransportChannelSocketAdapter(raw_video_channel_)); |
| 449 | 451 |
| 450 if (!cricket_session_->initiator()) | 452 if (!cricket_session_->initiator()) { |
| 451 jingle_session_manager_->AcceptConnection(this, cricket_session_); | 453 if (!jingle_session_manager_->AcceptConnection(this, cricket_session_)) { |
| 454 Close(); |
| 455 // Release session so that |
| 456 // JingleSessionManager::SessionDestroyed() doesn't try to call |
| 457 // cricket::SessionManager::DestroySession() for it. |
| 458 ReleaseSession(); |
| 459 delete this; |
| 460 return; |
| 461 } |
| 462 } |
| 452 | 463 |
| 453 if (!closed_) { | 464 // Set state to CONNECTING if the session is being accepted. |
| 454 // Set state to CONNECTING if the session is being accepted. | 465 SetState(CONNECTING); |
| 455 SetState(CONNECTING); | |
| 456 } | |
| 457 } | 466 } |
| 458 | 467 |
| 459 bool JingleSession::EstablishPseudoTcp( | 468 bool JingleSession::EstablishPseudoTcp( |
| 460 net::Socket* channel, | 469 net::Socket* channel, |
| 461 scoped_ptr<net::StreamSocket>* stream) { | 470 scoped_ptr<net::StreamSocket>* stream) { |
| 462 jingle_glue::PseudoTcpAdapter* adapter = | 471 jingle_glue::PseudoTcpAdapter* adapter = |
| 463 new jingle_glue::PseudoTcpAdapter(channel); | 472 new jingle_glue::PseudoTcpAdapter(channel); |
| 464 adapter->SetAckDelay(kTcpAckDelayMilliseconds); | 473 adapter->SetAckDelay(kTcpAckDelayMilliseconds); |
| 465 adapter->SetNoDelay(true); | 474 adapter->SetNoDelay(true); |
| 466 | 475 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 | 676 |
| 668 state_ = new_state; | 677 state_ = new_state; |
| 669 if (!closed_ && state_change_callback_.get()) | 678 if (!closed_ && state_change_callback_.get()) |
| 670 state_change_callback_->Run(new_state); | 679 state_change_callback_->Run(new_state); |
| 671 } | 680 } |
| 672 } | 681 } |
| 673 | 682 |
| 674 } // namespace protocol | 683 } // namespace protocol |
| 675 | 684 |
| 676 } // namespace remoting | 685 } // namespace remoting |
| OLD | NEW |