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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "crypto/hmac.h" | 12 #include "crypto/hmac.h" |
| 13 #include "crypto/rsa_private_key.h" | 13 #include "crypto/rsa_private_key.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 #include "net/socket/stream_socket.h" | 15 #include "net/socket/stream_socket.h" |
| 16 #include "remoting/base/constants.h" | 16 #include "remoting/base/constants.h" |
| 17 #include "remoting/protocol/simple_client_channel_authenticator.h" | |
| 18 #include "remoting/protocol/simple_host_channel_authenticator.h" | |
| 17 #include "remoting/protocol/jingle_datagram_connector.h" | 19 #include "remoting/protocol/jingle_datagram_connector.h" |
| 18 #include "remoting/protocol/jingle_session_manager.h" | 20 #include "remoting/protocol/jingle_session_manager.h" |
| 19 #include "remoting/protocol/jingle_stream_connector.h" | 21 #include "remoting/protocol/jingle_stream_connector.h" |
| 20 #include "third_party/libjingle/source/talk/base/thread.h" | 22 #include "third_party/libjingle/source/talk/base/thread.h" |
| 21 #include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h" | 23 #include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h" |
| 22 #include "third_party/libjingle/source/talk/p2p/base/session.h" | 24 #include "third_party/libjingle/source/talk/p2p/base/session.h" |
| 23 #include "third_party/libjingle/source/talk/p2p/base/transport.h" | 25 #include "third_party/libjingle/source/talk/p2p/base/transport.h" |
| 24 | 26 |
| 25 using cricket::BaseSession; | 27 using cricket::BaseSession; |
| 26 | 28 |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 cricket_session_->CreateChannel(content_name, name); | 422 cricket_session_->CreateChannel(content_name, name); |
| 421 | 423 |
| 422 if (!jingle_session_manager_->allow_nat_traversal_ && | 424 if (!jingle_session_manager_->allow_nat_traversal_ && |
| 423 !cricket_session_->initiator()) { | 425 !cricket_session_->initiator()) { |
| 424 // Don't make outgoing connections from the host to client when | 426 // Don't make outgoing connections from the host to client when |
| 425 // NAT traversal is disabled. | 427 // NAT traversal is disabled. |
| 426 raw_channel->GetP2PChannel()->set_incoming_only(true); | 428 raw_channel->GetP2PChannel()->set_incoming_only(true); |
| 427 } | 429 } |
| 428 | 430 |
| 429 channel_connectors_[name] = connector; | 431 channel_connectors_[name] = connector; |
| 430 connector->Connect(cricket_session_->initiator(), local_cert_, | 432 ChannelAuthenticator* authenticator; |
| 431 remote_cert_, local_private_key_.get(), raw_channel); | 433 if (cricket_session_->initiator()) { |
| 434 authenticator = new SimpleClientChannelAuthenticator( | |
| 435 remote_cert_, shared_secret_); | |
| 436 } else { | |
| 437 authenticator = new SimpleHostChannelAuthenticator( | |
| 438 local_cert_, local_private_key_.get(), shared_secret_); | |
| 439 } | |
|
Wez
2011/11/22 22:29:48
Is the intent for this code to be replaced with ca
Sergey Ulanov
2011/11/23 01:23:42
Yes, and I have it cooking: http://codereview.chro
| |
| 440 connector->Connect(authenticator, raw_channel); | |
| 432 | 441 |
| 433 // Workaround bug in libjingle - it doesn't connect channels if they | 442 // Workaround bug in libjingle - it doesn't connect channels if they |
| 434 // are created after the session is accepted. See crbug.com/89384. | 443 // are created after the session is accepted. See crbug.com/89384. |
| 435 // TODO(sergeyu): Fix the bug and remove this line. | 444 // TODO(sergeyu): Fix the bug and remove this line. |
| 436 cricket_session_->GetTransport(content_name)->ConnectChannels(); | 445 cricket_session_->GetTransport(content_name)->ConnectChannels(); |
| 437 } | 446 } |
| 438 | 447 |
| 439 void JingleSession::OnChannelConnectorFinished( | 448 void JingleSession::OnChannelConnectorFinished( |
| 440 const std::string& name, JingleChannelConnector* connector) { | 449 const std::string& name, JingleChannelConnector* connector) { |
| 441 DCHECK(CalledOnValidThread()); | 450 DCHECK(CalledOnValidThread()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 DCHECK_NE(state_, FAILED); | 502 DCHECK_NE(state_, FAILED); |
| 494 | 503 |
| 495 state_ = new_state; | 504 state_ = new_state; |
| 496 if (!state_change_callback_.is_null()) | 505 if (!state_change_callback_.is_null()) |
| 497 state_change_callback_.Run(new_state); | 506 state_change_callback_.Run(new_state); |
| 498 } | 507 } |
| 499 } | 508 } |
| 500 | 509 |
| 501 } // namespace protocol | 510 } // namespace protocol |
| 502 } // namespace remoting | 511 } // namespace remoting |
| OLD | NEW |