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

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

Issue 1371623003: Delete a connection only if it has timed out on writing and not receiving for 10 seconds. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: A minor change in GetStats 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
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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 ASSERT(worker_thread_ == rtc::Thread::Current()); 279 ASSERT(worker_thread_ == rtc::Thread::Current());
280 if (!ports_.empty()) { 280 if (!ports_.empty()) {
281 LOG(LS_ERROR) 281 LOG(LS_ERROR)
282 << "Attempt to change tiebreaker after Port has been allocated."; 282 << "Attempt to change tiebreaker after Port has been allocated.";
283 return; 283 return;
284 } 284 }
285 285
286 tiebreaker_ = tiebreaker; 286 tiebreaker_ = tiebreaker;
287 } 287 }
288 288
289 // Currently a channel is considered ICE completed once there is no 289 // Currently a channel is considered ICE completed once there is at least one
pthatcher1 2015/09/28 23:07:27 Just remove "Currently" and say "A channel ..."
honghaiz3 2015/09/29 18:47:49 Done.
290 // more than one connection per Network. This works for a single NIC 290 // connection that has not timed out on writing and there is no more than one
291 // with both IPv4 and IPv6 enabled. However, this condition won't 291 // such connection per Network.
pthatcher1 2015/09/28 23:07:27 This would be more clear as "once there is at leas
honghaiz3 2015/09/29 18:47:49 Done.
292 // happen when there are multiple NICs and all of them have
293 // connectivity.
294 // TODO(guoweis): Change Completion to be driven by a channel level
295 // timer.
296 TransportChannelState P2PTransportChannel::GetState() const { 292 TransportChannelState P2PTransportChannel::GetState() const {
293 bool has_non_write_timeout_connections = false;
pthatcher1 2015/09/28 23:07:27 I think this would be much more clear as: bool Co
honghaiz3 2015/09/29 18:47:49 Done.
297 std::set<rtc::Network*> networks; 294 std::set<rtc::Network*> networks;
298 295 for (Connection* connection : connections_) {
299 if (connections_.empty()) { 296 if (connection->write_state() == Connection::STATE_WRITE_TIMEOUT) {
300 return had_connection_ ? TransportChannelState::STATE_FAILED 297 continue;
301 : TransportChannelState::STATE_INIT; 298 }
302 } 299 has_non_write_timeout_connections = true;
303 300 rtc::Network* network = connection->port()->Network();
304 for (uint32 i = 0; i < connections_.size(); ++i) {
305 rtc::Network* network = connections_[i]->port()->Network();
306 if (networks.find(network) == networks.end()) { 301 if (networks.find(network) == networks.end()) {
307 networks.insert(network); 302 networks.insert(network);
308 } else { 303 } else {
309 LOG_J(LS_VERBOSE, this) << "Ice not completed yet for this channel as " 304 LOG_J(LS_VERBOSE, this) << "Ice not completed yet for this channel as "
310 << network->ToString() 305 << network->ToString()
311 << " has more than 1 connection."; 306 << " has more than 1 connection.";
312 return TransportChannelState::STATE_CONNECTING; 307 return TransportChannelState::STATE_CONNECTING;
313 } 308 }
314 } 309 }
315 LOG_J(LS_VERBOSE, this) << "Ice is completed for this channel."; 310 if (has_non_write_timeout_connections) {
316 311 LOG_J(LS_VERBOSE, this) << "Ice is completed for this channel.";
317 return TransportChannelState::STATE_COMPLETED; 312 return TransportChannelState::STATE_COMPLETED;
313 }
314 return had_connection_ ? TransportChannelState::STATE_FAILED
315 : TransportChannelState::STATE_INIT;
318 } 316 }
319 317
320 void P2PTransportChannel::SetIceCredentials(const std::string& ice_ufrag, 318 void P2PTransportChannel::SetIceCredentials(const std::string& ice_ufrag,
321 const std::string& ice_pwd) { 319 const std::string& ice_pwd) {
322 ASSERT(worker_thread_ == rtc::Thread::Current()); 320 ASSERT(worker_thread_ == rtc::Thread::Current());
323 ice_ufrag_ = ice_ufrag; 321 ice_ufrag_ = ice_ufrag;
324 ice_pwd_ = ice_pwd; 322 ice_pwd_ = ice_pwd;
325 // Note: Candidate gathering will restart when MaybeStartGathering is next 323 // Note: Candidate gathering will restart when MaybeStartGathering is next
326 // called. 324 // called.
327 } 325 }
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 } 863 }
866 return sent; 864 return sent;
867 } 865 }
868 866
869 bool P2PTransportChannel::GetStats(ConnectionInfos *infos) { 867 bool P2PTransportChannel::GetStats(ConnectionInfos *infos) {
870 ASSERT(worker_thread_ == rtc::Thread::Current()); 868 ASSERT(worker_thread_ == rtc::Thread::Current());
871 // Gather connection infos. 869 // Gather connection infos.
872 infos->clear(); 870 infos->clear();
873 871
874 std::vector<Connection *>::const_iterator it; 872 std::vector<Connection *>::const_iterator it;
875 for (it = connections_.begin(); it != connections_.end(); ++it) { 873 for (Connection* connection : connections_) {
876 Connection* connection = *it; 874 if (connection->write_state() == Connection::STATE_WRITE_TIMEOUT &&
875 !connection->receiving()) {
pthatcher1 2015/09/28 23:07:27 This is basically saying "Don't report stats for c
honghaiz3 2015/09/29 18:47:49 I wanted to keep the same app behavior, but think
876 continue;
877 }
877 ConnectionInfo info; 878 ConnectionInfo info;
878 info.best_connection = (best_connection_ == connection); 879 info.best_connection = (best_connection_ == connection);
879 info.receiving = connection->receiving(); 880 info.receiving = connection->receiving();
880 info.writable = 881 info.writable =
881 (connection->write_state() == Connection::STATE_WRITABLE); 882 (connection->write_state() == Connection::STATE_WRITABLE);
882 info.timeout = 883 info.timeout =
883 (connection->write_state() == Connection::STATE_WRITE_TIMEOUT); 884 (connection->write_state() == Connection::STATE_WRITE_TIMEOUT);
884 info.new_connection = !connection->reported(); 885 info.new_connection = !connection->reported();
885 connection->set_reported(true); 886 connection->set_reported(true);
886 info.rtt = connection->rtt(); 887 info.rtt = connection->rtt();
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 } 1346 }
1346 } 1347 }
1347 1348
1348 void P2PTransportChannel::OnReadyToSend(Connection* connection) { 1349 void P2PTransportChannel::OnReadyToSend(Connection* connection) {
1349 if (connection == best_connection_ && writable()) { 1350 if (connection == best_connection_ && writable()) {
1350 SignalReadyToSend(this); 1351 SignalReadyToSend(this);
1351 } 1352 }
1352 } 1353 }
1353 1354
1354 } // namespace cricket 1355 } // namespace cricket
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698