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

Side by Side Diff: webrtc/p2p/base/p2ptransportchannel.cc

Issue 2099563004: Start ICE connectivity checks as soon as the first pair is pingable. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Updating unit test failures. We ping too fast for our own good. Created 4 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 connection->SignalReadPacket.connect( 147 connection->SignalReadPacket.connect(
148 this, &P2PTransportChannel::OnReadPacket); 148 this, &P2PTransportChannel::OnReadPacket);
149 connection->SignalReadyToSend.connect( 149 connection->SignalReadyToSend.connect(
150 this, &P2PTransportChannel::OnReadyToSend); 150 this, &P2PTransportChannel::OnReadyToSend);
151 connection->SignalStateChange.connect( 151 connection->SignalStateChange.connect(
152 this, &P2PTransportChannel::OnConnectionStateChange); 152 this, &P2PTransportChannel::OnConnectionStateChange);
153 connection->SignalDestroyed.connect( 153 connection->SignalDestroyed.connect(
154 this, &P2PTransportChannel::OnConnectionDestroyed); 154 this, &P2PTransportChannel::OnConnectionDestroyed);
155 connection->SignalNominated.connect(this, &P2PTransportChannel::OnNominated); 155 connection->SignalNominated.connect(this, &P2PTransportChannel::OnNominated);
156 had_connection_ = true; 156 had_connection_ = true;
157 if (!started_pinging_) {
158 // Start checking and pinging as soon as we have the first connection.
159 thread()->Post(RTC_FROM_HERE, this, MSG_CHECK_AND_PING);
honghaiz3 2016/06/27 16:24:20 Should we worry about that the first connection ma
pthatcher1 2016/06/27 18:32:20 It's true that we need to make sure we have the re
Taylor Brandstetter 2016/06/27 22:19:34 Great observation, Honghai. I was only thinking ab
160 started_pinging_ = true;
honghaiz3 2016/06/27 16:24:20 The two variables had_connection_ and started_ping
pthatcher1 2016/06/27 18:32:20 I won't any more if we check that we have the remo
Taylor Brandstetter 2016/06/27 22:19:34 Peter is correct.
161 }
157 } 162 }
158 163
159 // Determines whether we should switch the selected connection to 164 // Determines whether we should switch the selected connection to
160 // |new_connection| based the writable/receiving state, the nomination state, 165 // |new_connection| based the writable/receiving state, the nomination state,
161 // and the last data received time. This prevents the controlled side from 166 // and the last data received time. This prevents the controlled side from
162 // switching the selected connection too frequently when the controlling side 167 // switching the selected connection too frequently when the controlling side
163 // is doing aggressive nominations. The precedence of the connection switching 168 // is doing aggressive nominations. The precedence of the connection switching
164 // criteria is as follows: 169 // criteria is as follows:
165 // i) write/receiving/connected states 170 // i) write/receiving/connected states
166 // ii) For controlled side, 171 // ii) For controlled side,
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 LOG(LS_INFO) << "Set presume writable when fully relayed to " 350 LOG(LS_INFO) << "Set presume writable when fully relayed to "
346 << config_.presume_writable_when_fully_relayed; 351 << config_.presume_writable_when_fully_relayed;
347 } 352 }
348 } 353 }
349 } 354 }
350 355
351 const IceConfig& P2PTransportChannel::config() const { 356 const IceConfig& P2PTransportChannel::config() const {
352 return config_; 357 return config_;
353 } 358 }
354 359
355 // Go into the state of processing candidates, and running in general 360 void P2PTransportChannel::MaybeStartGathering() {
356 void P2PTransportChannel::Connect() {
357 ASSERT(worker_thread_ == rtc::Thread::Current());
358 if (ice_ufrag_.empty() || ice_pwd_.empty()) { 361 if (ice_ufrag_.empty() || ice_pwd_.empty()) {
359 ASSERT(false);
360 LOG(LS_ERROR) << "P2PTransportChannel::Connect: The ice_ufrag_ and the "
361 << "ice_pwd_ are not set.";
362 return; 362 return;
363 } 363 }
364
365 // Start checking and pinging as the ports come in.
366 thread()->Post(RTC_FROM_HERE, this, MSG_CHECK_AND_PING);
367 }
368
369 void P2PTransportChannel::MaybeStartGathering() {
370 // Start gathering if we never started before, or if an ICE restart occurred. 364 // Start gathering if we never started before, or if an ICE restart occurred.
371 if (allocator_sessions_.empty() || 365 if (allocator_sessions_.empty() ||
372 IceCredentialsChanged(allocator_sessions_.back()->ice_ufrag(), 366 IceCredentialsChanged(allocator_sessions_.back()->ice_ufrag(),
373 allocator_sessions_.back()->ice_pwd(), ice_ufrag_, 367 allocator_sessions_.back()->ice_pwd(), ice_ufrag_,
374 ice_pwd_)) { 368 ice_pwd_)) {
375 if (gathering_state_ != kIceGatheringGathering) { 369 if (gathering_state_ != kIceGatheringGathering) {
376 gathering_state_ = kIceGatheringGathering; 370 gathering_state_ = kIceGatheringGathering;
377 SignalGatheringState(this); 371 SignalGatheringState(this);
378 } 372 }
379 // Time for a new allocator. 373 // Time for a new allocator.
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 1793
1800 // During the initial state when nothing has been pinged yet, return the first 1794 // During the initial state when nothing has been pinged yet, return the first
1801 // one in the ordered |connections_|. 1795 // one in the ordered |connections_|.
1802 return *(std::find_if(connections_.begin(), connections_.end(), 1796 return *(std::find_if(connections_.begin(), connections_.end(),
1803 [conn1, conn2](Connection* conn) { 1797 [conn1, conn2](Connection* conn) {
1804 return conn == conn1 || conn == conn2; 1798 return conn == conn1 || conn == conn2;
1805 })); 1799 }));
1806 } 1800 }
1807 1801
1808 } // namespace cricket 1802 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698