Chromium Code Reviews| 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 27 matching lines...) Expand all Loading... | |
| 38 | 38 |
| 39 const char kControlChannelName[] = "control"; | 39 const char kControlChannelName[] = "control"; |
| 40 const char kEventChannelName[] = "event"; | 40 const char kEventChannelName[] = "event"; |
| 41 const char kVideoChannelName[] = "video"; | 41 const char kVideoChannelName[] = "video"; |
| 42 const char kVideoRtpChannelName[] = "videortp"; | 42 const char kVideoRtpChannelName[] = "videortp"; |
| 43 const char kVideoRtcpChannelName[] = "videortcp"; | 43 const char kVideoRtcpChannelName[] = "videortcp"; |
| 44 | 44 |
| 45 const int kMasterKeyLength = 16; | 45 const int kMasterKeyLength = 16; |
| 46 const int kChannelKeyLength = 16; | 46 const int kChannelKeyLength = 16; |
| 47 | 47 |
| 48 // 10 milliseconds of ACK delay is choosen to lower network latency | |
| 49 // and don't overwhelm the network with ACK packets. | |
|
Wez
2011/06/28 19:27:18
nit: It's chosen to balance the extra latency agai
| |
| 50 const int kTcpAckDelayMilliseconds = 10; | |
| 51 | |
| 48 // Helper method to create a SSL client socket. | 52 // Helper method to create a SSL client socket. |
| 49 net::SSLClientSocket* CreateSSLClientSocket( | 53 net::SSLClientSocket* CreateSSLClientSocket( |
| 50 net::StreamSocket* socket, scoped_refptr<net::X509Certificate> cert, | 54 net::StreamSocket* socket, scoped_refptr<net::X509Certificate> cert, |
| 51 net::CertVerifier* cert_verifier) { | 55 net::CertVerifier* cert_verifier) { |
| 52 net::SSLConfig ssl_config; | 56 net::SSLConfig ssl_config; |
| 53 ssl_config.cached_info_enabled = false; | 57 ssl_config.cached_info_enabled = false; |
| 54 ssl_config.false_start_enabled = false; | 58 ssl_config.false_start_enabled = false; |
| 55 ssl_config.ssl3_enabled = true; | 59 ssl_config.ssl3_enabled = true; |
| 56 ssl_config.tls1_enabled = true; | 60 ssl_config.tls1_enabled = true; |
| 57 | 61 |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 | 448 |
| 445 if (!closed_) { | 449 if (!closed_) { |
| 446 // Set state to CONNECTING if the session is being accepted. | 450 // Set state to CONNECTING if the session is being accepted. |
| 447 SetState(CONNECTING); | 451 SetState(CONNECTING); |
| 448 } | 452 } |
| 449 } | 453 } |
| 450 | 454 |
| 451 bool JingleSession::EstablishPseudoTcp( | 455 bool JingleSession::EstablishPseudoTcp( |
| 452 net::Socket* channel, | 456 net::Socket* channel, |
| 453 scoped_ptr<net::StreamSocket>* stream) { | 457 scoped_ptr<net::StreamSocket>* stream) { |
| 454 stream->reset(new jingle_glue::PseudoTcpAdapter(channel)); | 458 jingle_glue::PseudoTcpAdapter* adapter = |
| 459 new jingle_glue::PseudoTcpAdapter(channel); | |
| 460 adapter->SetAckDelay(kTcpAckDelayMilliseconds); | |
| 461 adapter->SetNoDelay(false); | |
| 462 | |
| 463 stream->reset(adapter); | |
| 455 int result = (*stream)->Connect(&connect_callback_); | 464 int result = (*stream)->Connect(&connect_callback_); |
| 456 return (result == net::OK) || (result == net::ERR_IO_PENDING); | 465 return (result == net::OK) || (result == net::ERR_IO_PENDING); |
| 457 } | 466 } |
| 458 | 467 |
| 459 bool JingleSession::EstablishSSLConnection( | 468 bool JingleSession::EstablishSSLConnection( |
| 460 net::StreamSocket* socket, | 469 net::StreamSocket* socket, |
| 461 scoped_ptr<net::StreamSocket>* ssl_socket) { | 470 scoped_ptr<net::StreamSocket>* ssl_socket) { |
| 462 DCHECK(socket); | 471 DCHECK(socket); |
| 463 DCHECK(socket->IsConnected()); | 472 DCHECK(socket->IsConnected()); |
| 464 if (cricket_session_->initiator()) { | 473 if (cricket_session_->initiator()) { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 | 654 |
| 646 state_ = new_state; | 655 state_ = new_state; |
| 647 if (!closed_ && state_change_callback_.get()) | 656 if (!closed_ && state_change_callback_.get()) |
| 648 state_change_callback_->Run(new_state); | 657 state_change_callback_->Run(new_state); |
| 649 } | 658 } |
| 650 } | 659 } |
| 651 | 660 |
| 652 } // namespace protocol | 661 } // namespace protocol |
| 653 | 662 |
| 654 } // namespace remoting | 663 } // namespace remoting |
| OLD | NEW |