Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(651)

Side by Side Diff: remoting/protocol/libjingle_transport_factory.cc

Issue 1323243006: Roll WebRTC 10010:10022, Libjingle 10011:10022 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed DEPS that were being unintentionally modified by git merge Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « DEPS ('k') | third_party/libjingle/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/libjingle_transport_factory.h" 5 #include "remoting/protocol/libjingle_transport_factory.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 const std::string& password) override; 72 const std::string& password) override;
73 void AddRemoteCandidate(const cricket::Candidate& candidate) override; 73 void AddRemoteCandidate(const cricket::Candidate& candidate) override;
74 const std::string& name() const override; 74 const std::string& name() const override;
75 bool is_connected() const override; 75 bool is_connected() const override;
76 76
77 private: 77 private:
78 void DoStart(); 78 void DoStart();
79 void NotifyConnected(); 79 void NotifyConnected();
80 80
81 // Signal handlers for cricket::TransportChannel. 81 // Signal handlers for cricket::TransportChannel.
82 void OnRequestSignaling(cricket::TransportChannelImpl* channel); 82 void OnCandidateGathered(cricket::TransportChannelImpl* channel,
83 void OnCandidateReady(cricket::TransportChannelImpl* channel, 83 const cricket::Candidate& candidate);
84 const cricket::Candidate& candidate);
85 void OnRouteChange(cricket::TransportChannel* channel, 84 void OnRouteChange(cricket::TransportChannel* channel,
86 const cricket::Candidate& candidate); 85 const cricket::Candidate& candidate);
87 void OnWritableState(cricket::TransportChannel* channel); 86 void OnWritableState(cricket::TransportChannel* channel);
88 87
89 // Callback for TransportChannelSocketAdapter to notify when the socket is 88 // Callback for TransportChannelSocketAdapter to notify when the socket is
90 // destroyed. 89 // destroyed.
91 void OnChannelDestroyed(); 90 void OnChannelDestroyed();
92 91
93 void NotifyRouteChanged(); 92 void NotifyRouteChanged();
94 93
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 if (!callback_.is_null()) 153 if (!callback_.is_null())
155 DoStart(); 154 DoStart();
156 155
157 // Pass pending ICE credentials and candidates to the channel. 156 // Pass pending ICE credentials and candidates to the channel.
158 if (!remote_ice_username_fragment_.empty()) { 157 if (!remote_ice_username_fragment_.empty()) {
159 channel_->SetRemoteIceCredentials(remote_ice_username_fragment_, 158 channel_->SetRemoteIceCredentials(remote_ice_username_fragment_,
160 remote_ice_password_); 159 remote_ice_password_);
161 } 160 }
162 161
163 while (!pending_candidates_.empty()) { 162 while (!pending_candidates_.empty()) {
164 channel_->OnCandidate(pending_candidates_.front()); 163 channel_->AddRemoteCandidate(pending_candidates_.front());
165 pending_candidates_.pop_front(); 164 pending_candidates_.pop_front();
166 } 165 }
167 } 166 }
168 167
169 void LibjingleTransport::Connect( 168 void LibjingleTransport::Connect(
170 const std::string& name, 169 const std::string& name,
171 Transport::EventHandler* event_handler, 170 Transport::EventHandler* event_handler,
172 const Transport::ConnectedCallback& callback) { 171 const Transport::ConnectedCallback& callback) {
173 DCHECK(CalledOnValidThread()); 172 DCHECK(CalledOnValidThread());
174 DCHECK(!name.empty()); 173 DCHECK(!name.empty());
(...skipping 17 matching lines...) Expand all
192 channel_.reset(new cricket::P2PTransportChannel( 191 channel_.reset(new cricket::P2PTransportChannel(
193 std::string(), 0, nullptr, port_allocator_)); 192 std::string(), 0, nullptr, port_allocator_));
194 std::string ice_password = rtc::CreateRandomString(cricket::ICE_PWD_LENGTH); 193 std::string ice_password = rtc::CreateRandomString(cricket::ICE_PWD_LENGTH);
195 channel_->SetIceProtocolType(cricket::ICEPROTO_RFC5245); 194 channel_->SetIceProtocolType(cricket::ICEPROTO_RFC5245);
196 channel_->SetIceRole((role_ == TransportRole::CLIENT) 195 channel_->SetIceRole((role_ == TransportRole::CLIENT)
197 ? cricket::ICEROLE_CONTROLLING 196 ? cricket::ICEROLE_CONTROLLING
198 : cricket::ICEROLE_CONTROLLED); 197 : cricket::ICEROLE_CONTROLLED);
199 event_handler_->OnTransportIceCredentials(this, ice_username_fragment_, 198 event_handler_->OnTransportIceCredentials(this, ice_username_fragment_,
200 ice_password); 199 ice_password);
201 channel_->SetIceCredentials(ice_username_fragment_, ice_password); 200 channel_->SetIceCredentials(ice_username_fragment_, ice_password);
202 channel_->SignalRequestSignaling.connect( 201 channel_->SignalCandidateGathered.connect(
203 this, &LibjingleTransport::OnRequestSignaling); 202 this, &LibjingleTransport::OnCandidateGathered);
204 channel_->SignalCandidateReady.connect(
205 this, &LibjingleTransport::OnCandidateReady);
206 channel_->SignalRouteChange.connect( 203 channel_->SignalRouteChange.connect(
207 this, &LibjingleTransport::OnRouteChange); 204 this, &LibjingleTransport::OnRouteChange);
208 channel_->SignalWritableState.connect( 205 channel_->SignalWritableState.connect(
209 this, &LibjingleTransport::OnWritableState); 206 this, &LibjingleTransport::OnWritableState);
210 channel_->set_incoming_only( 207 channel_->set_incoming_only(
211 !(network_settings_.flags & NetworkSettings::NAT_TRAVERSAL_OUTGOING)); 208 !(network_settings_.flags & NetworkSettings::NAT_TRAVERSAL_OUTGOING));
212 209
213 channel_->Connect(); 210 channel_->Connect();
211 channel_->MaybeStartGathering();
214 212
215 --connect_attempts_left_; 213 --connect_attempts_left_;
216 214
217 // Start reconnection timer. 215 // Start reconnection timer.
218 reconnect_timer_.Start( 216 reconnect_timer_.Start(
219 FROM_HERE, base::TimeDelta::FromSeconds(kReconnectDelaySeconds), 217 FROM_HERE, base::TimeDelta::FromSeconds(kReconnectDelaySeconds),
220 this, &LibjingleTransport::TryReconnect); 218 this, &LibjingleTransport::TryReconnect);
221 219
222 base::ThreadTaskRunnerHandle::Get()->PostTask( 220 base::ThreadTaskRunnerHandle::Get()->PostTask(
223 FROM_HERE, base::Bind(&LibjingleTransport::NotifyConnected, 221 FROM_HERE, base::Bind(&LibjingleTransport::NotifyConnected,
(...skipping 25 matching lines...) Expand all
249 DCHECK(CalledOnValidThread()); 247 DCHECK(CalledOnValidThread());
250 248
251 // To enforce the no-relay setting, it's not enough to not produce relay 249 // To enforce the no-relay setting, it's not enough to not produce relay
252 // candidates. It's also necessary to discard remote relay candidates. 250 // candidates. It's also necessary to discard remote relay candidates.
253 bool relay_allowed = (network_settings_.flags & 251 bool relay_allowed = (network_settings_.flags &
254 NetworkSettings::NAT_TRAVERSAL_RELAY) != 0; 252 NetworkSettings::NAT_TRAVERSAL_RELAY) != 0;
255 if (!relay_allowed && candidate.type() == cricket::RELAY_PORT_TYPE) 253 if (!relay_allowed && candidate.type() == cricket::RELAY_PORT_TYPE)
256 return; 254 return;
257 255
258 if (channel_) { 256 if (channel_) {
259 channel_->OnCandidate(candidate); 257 channel_->AddRemoteCandidate(candidate);
260 } else { 258 } else {
261 pending_candidates_.push_back(candidate); 259 pending_candidates_.push_back(candidate);
262 } 260 }
263 } 261 }
264 262
265 const std::string& LibjingleTransport::name() const { 263 const std::string& LibjingleTransport::name() const {
266 DCHECK(CalledOnValidThread()); 264 DCHECK(CalledOnValidThread());
267 return name_; 265 return name_;
268 } 266 }
269 267
270 bool LibjingleTransport::is_connected() const { 268 bool LibjingleTransport::is_connected() const {
271 DCHECK(CalledOnValidThread()); 269 DCHECK(CalledOnValidThread());
272 return callback_.is_null(); 270 return callback_.is_null();
273 } 271 }
274 272
275 void LibjingleTransport::OnRequestSignaling( 273 void LibjingleTransport::OnCandidateGathered(
276 cricket::TransportChannelImpl* channel) {
277 DCHECK(CalledOnValidThread());
278 channel_->OnSignalingReady();
279 }
280
281 void LibjingleTransport::OnCandidateReady(
282 cricket::TransportChannelImpl* channel, 274 cricket::TransportChannelImpl* channel,
283 const cricket::Candidate& candidate) { 275 const cricket::Candidate& candidate) {
284 DCHECK(CalledOnValidThread()); 276 DCHECK(CalledOnValidThread());
285 event_handler_->OnTransportCandidate(this, candidate); 277 event_handler_->OnTransportCandidate(this, candidate);
286 } 278 }
287 279
288 void LibjingleTransport::OnRouteChange( 280 void LibjingleTransport::OnRouteChange(
289 cricket::TransportChannel* channel, 281 cricket::TransportChannel* channel,
290 const cricket::Candidate& candidate) { 282 const cricket::Candidate& candidate) {
291 // Ignore notifications if the channel is not writable. 283 // Ignore notifications if the channel is not writable.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 last_jingle_info_update_time_ = base::TimeTicks::Now(); 438 last_jingle_info_update_time_ = base::TimeTicks::Now();
447 439
448 while (!on_jingle_info_callbacks_.empty()) { 440 while (!on_jingle_info_callbacks_.empty()) {
449 on_jingle_info_callbacks_.begin()->Run(); 441 on_jingle_info_callbacks_.begin()->Run();
450 on_jingle_info_callbacks_.pop_front(); 442 on_jingle_info_callbacks_.pop_front();
451 } 443 }
452 } 444 }
453 445
454 } // namespace protocol 446 } // namespace protocol
455 } // namespace remoting 447 } // namespace remoting
OLDNEW
« no previous file with comments | « DEPS ('k') | third_party/libjingle/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698