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_manager.h" | 5 #include "remoting/protocol/jingle_session_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "remoting/jingle_glue/iq_sender.h" | 8 #include "remoting/jingle_glue/iq_sender.h" |
9 #include "remoting/jingle_glue/jingle_info_request.h" | 9 #include "remoting/jingle_glue/jingle_info_request.h" |
10 #include "remoting/jingle_glue/signal_strategy.h" | 10 #include "remoting/jingle_glue/signal_strategy.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 } | 33 } |
34 | 34 |
35 void JingleSessionManager::Init( | 35 void JingleSessionManager::Init( |
36 SignalStrategy* signal_strategy, | 36 SignalStrategy* signal_strategy, |
37 SessionManager::Listener* listener, | 37 SessionManager::Listener* listener, |
38 const NetworkSettings& network_settings) { | 38 const NetworkSettings& network_settings) { |
39 listener_ = listener; | 39 listener_ = listener; |
40 signal_strategy_ = signal_strategy; | 40 signal_strategy_ = signal_strategy; |
41 iq_sender_.reset(new IqSender(signal_strategy_)); | 41 iq_sender_.reset(new IqSender(signal_strategy_)); |
42 | 42 |
43 transport_config_.nat_traversal = network_settings.allow_nat_traversal; | 43 transport_config_.nat_traversal_mode = |
| 44 network_settings.allow_nat_traversal ? |
| 45 TransportConfig::NAT_TRAVERSAL_ENABLED : |
| 46 TransportConfig::NAT_TRAVERSAL_DISABLED; |
44 transport_config_.min_port = network_settings.min_port; | 47 transport_config_.min_port = network_settings.min_port; |
45 transport_config_.max_port = network_settings.max_port; | 48 transport_config_.max_port = network_settings.max_port; |
46 | 49 |
47 signal_strategy_->AddListener(this); | 50 signal_strategy_->AddListener(this); |
48 | 51 |
49 OnSignalStrategyStateChange(signal_strategy_->GetState()); | 52 OnSignalStrategyStateChange(signal_strategy_->GetState()); |
50 } | 53 } |
51 | 54 |
52 void JingleSessionManager::OnJingleInfo( | 55 void JingleSessionManager::OnJingleInfo( |
53 const std::string& relay_token, | 56 const std::string& relay_token, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 void JingleSessionManager::set_authenticator_factory( | 103 void JingleSessionManager::set_authenticator_factory( |
101 scoped_ptr<AuthenticatorFactory> authenticator_factory) { | 104 scoped_ptr<AuthenticatorFactory> authenticator_factory) { |
102 DCHECK(CalledOnValidThread()); | 105 DCHECK(CalledOnValidThread()); |
103 authenticator_factory_ = authenticator_factory.Pass(); | 106 authenticator_factory_ = authenticator_factory.Pass(); |
104 } | 107 } |
105 | 108 |
106 void JingleSessionManager::OnSignalStrategyStateChange( | 109 void JingleSessionManager::OnSignalStrategyStateChange( |
107 SignalStrategy::State state) { | 110 SignalStrategy::State state) { |
108 // If NAT traversal is enabled then we need to request STUN/Relay info. | 111 // If NAT traversal is enabled then we need to request STUN/Relay info. |
109 if (state == SignalStrategy::CONNECTED) { | 112 if (state == SignalStrategy::CONNECTED) { |
110 if (transport_config_.nat_traversal) { | 113 if (transport_config_.nat_traversal_mode == |
| 114 TransportConfig::NAT_TRAVERSAL_ENABLED) { |
111 jingle_info_request_.reset(new JingleInfoRequest(signal_strategy_)); | 115 jingle_info_request_.reset(new JingleInfoRequest(signal_strategy_)); |
112 jingle_info_request_->Send(base::Bind(&JingleSessionManager::OnJingleInfo, | 116 jingle_info_request_->Send(base::Bind(&JingleSessionManager::OnJingleInfo, |
113 base::Unretained(this))); | 117 base::Unretained(this))); |
114 } else if (!ready_) { | 118 } else if (!ready_) { |
115 ready_ = true; | 119 ready_ = true; |
116 listener_->OnSessionManagerReady(); | 120 listener_->OnSessionManagerReady(); |
117 } | 121 } |
118 } | 122 } |
119 } | 123 } |
120 | 124 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 signal_strategy_->SendStanza( | 178 signal_strategy_->SendStanza( |
175 JingleMessageReply(error).ToXml(original_stanza)); | 179 JingleMessageReply(error).ToXml(original_stanza)); |
176 } | 180 } |
177 | 181 |
178 void JingleSessionManager::SessionDestroyed(JingleSession* session) { | 182 void JingleSessionManager::SessionDestroyed(JingleSession* session) { |
179 sessions_.erase(session->session_id_); | 183 sessions_.erase(session->session_id_); |
180 } | 184 } |
181 | 185 |
182 } // namespace protocol | 186 } // namespace protocol |
183 } // namespace remoting | 187 } // namespace remoting |
OLD | NEW |