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

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

Issue 2143653005: Dampening connection switch. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Address comments 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 PortAllocatorSession* allocator_session() { 201 PortAllocatorSession* allocator_session() {
202 return allocator_sessions_.back().get(); 202 return allocator_sessions_.back().get();
203 } 203 }
204 204
205 // Public for unit tests. 205 // Public for unit tests.
206 const std::vector<RemoteCandidate>& remote_candidates() const { 206 const std::vector<RemoteCandidate>& remote_candidates() const {
207 return remote_candidates_; 207 return remote_candidates_;
208 } 208 }
209 209
210 private: 210 private:
211 rtc::Thread* thread() { return worker_thread_; } 211 rtc::Thread* thread() const { return worker_thread_; }
212 bool IsGettingPorts() { return allocator_session()->IsGettingPorts(); } 212 bool IsGettingPorts() { return allocator_session()->IsGettingPorts(); }
213 213
214 // A transport channel is weak if the current best connection is either 214 // A transport channel is weak if the current best connection is either
215 // not receiving or not writable, or if there is no best connection at all. 215 // not receiving or not writable, or if there is no best connection at all.
216 bool weak() const; 216 bool weak() const;
217 // Returns true if it's possible to send packets on this channel. 217 // Returns true if it's possible to send packets on this channel.
218 bool ReadyToSend() const; 218 bool ReadyToSend() const;
219 void UpdateConnectionStates(); 219 void UpdateConnectionStates();
220 void RequestSortAndStateUpdate(); 220 void RequestSortAndStateUpdate();
221 // Start pinging if we haven't already started, and we now have a connection 221 // Start pinging if we haven't already started, and we now have a connection
222 // that's pingable. 222 // that's pingable.
223 void MaybeStartPinging(); 223 void MaybeStartPinging();
224 224
225 // The methods below return a positive value if a is preferable to b, 225 // The methods below return a positive value if |a| is preferable to |b|,
226 // a negative value if b is preferable, and 0 if they're equally preferable. 226 // a negative value if |b| is preferable, and 0 if they're equally preferable.
227 // If |b_receiving_threshold| is not zero, then when |b| is receiving and |a|
228 // is not, returns a negative value only if the current time is at least
229 // |b_receiving_threshold| milliseconds. If the current time is less than
230 // that, sets |switching_dampened| to be true.
pthatcher1 2016/07/14 18:01:44 to be true => to true Also, "switching_dampened"
honghaiz3 2016/07/14 23:15:01 Done.
227 int CompareConnectionStates(const cricket::Connection* a, 231 int CompareConnectionStates(const cricket::Connection* a,
228 const cricket::Connection* b) const; 232 const cricket::Connection* b,
233 int64_t b_receiving_threshold,
234 bool* switching_dampened) const;
229 int CompareConnectionCandidates(const cricket::Connection* a, 235 int CompareConnectionCandidates(const cricket::Connection* a,
230 const cricket::Connection* b) const; 236 const cricket::Connection* b) const;
231 // Compares two connections based on the connection states 237 // Compares two connections based on the connection states
232 // (writable/receiving/connected), nomination states, last data received time, 238 // (writable/receiving/connected), nomination states, last data received time,
233 // and static preferences. Does not include latency. Used by both sorting 239 // and static preferences. Does not include latency. Used by both sorting
234 // and ShouldSwitchSelectedConnection(). 240 // and ShouldSwitchSelectedConnection().
235 // Returns a positive value if |a| is better than |b|. 241 // Returns a positive value if |a| is better than |b|.
236 int CompareConnections(const cricket::Connection* a, 242 int CompareConnections(const cricket::Connection* a,
237 const cricket::Connection* b) const; 243 const cricket::Connection* b,
244 int64_t b_receiving_threshold,
245 bool* switching_dampened) const;
238 246
239 bool PresumedWritable(const cricket::Connection* conn) const; 247 bool PresumedWritable(const cricket::Connection* conn) const;
240 248
241 bool ShouldSwitchSelectedConnection(const cricket::Connection* selected,
242 const cricket::Connection* conn) const;
243 void SortConnectionsAndUpdateState(); 249 void SortConnectionsAndUpdateState();
244 void SwitchSelectedConnection(Connection* conn); 250 void SwitchSelectedConnection(Connection* conn);
245 void UpdateState(); 251 void UpdateState();
246 void HandleAllTimedOut(); 252 void HandleAllTimedOut();
247 void MaybeStopPortAllocatorSessions(); 253 void MaybeStopPortAllocatorSessions();
248 TransportChannelState ComputeState() const; 254 TransportChannelState ComputeState() const;
249 255
250 Connection* GetBestConnectionOnNetwork(rtc::Network* network) const; 256 Connection* GetBestConnectionOnNetwork(rtc::Network* network) const;
251 bool CreateConnections(const Candidate& remote_candidate, 257 bool CreateConnections(const Candidate& remote_candidate,
252 PortInterface* origin_port); 258 PortInterface* origin_port);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 void OnReadyToSend(Connection* connection); 306 void OnReadyToSend(Connection* connection);
301 void OnConnectionDestroyed(Connection *connection); 307 void OnConnectionDestroyed(Connection *connection);
302 308
303 void OnNominated(Connection* conn); 309 void OnNominated(Connection* conn);
304 310
305 void OnMessage(rtc::Message* pmsg) override; 311 void OnMessage(rtc::Message* pmsg) override;
306 void OnCheckAndPing(); 312 void OnCheckAndPing();
307 void OnRegatherOnFailedNetworks(); 313 void OnRegatherOnFailedNetworks();
308 314
309 // Returns true if the new_connection should be selected for transmission. 315 // Returns true if the new_connection should be selected for transmission.
310 bool ShouldSwitchSelectedConnection(Connection* new_connection) const; 316 bool ShouldSwitchSelectedConnection(Connection* new_connection);
311 317
312 void PruneConnections(); 318 void PruneConnections();
313 bool IsBackupConnection(const Connection* conn) const; 319 bool IsBackupConnection(const Connection* conn) const;
314 320
315 Connection* FindConnectionToPing(int64_t now); 321 Connection* FindConnectionToPing(int64_t now);
316 Connection* FindOldestConnectionNeedingTriggeredCheck(int64_t now); 322 Connection* FindOldestConnectionNeedingTriggeredCheck(int64_t now);
317 // Between |conn1| and |conn2|, this function returns the one which should 323 // Between |conn1| and |conn2|, this function returns the one which should
318 // be pinged first. 324 // be pinged first.
319 Connection* SelectMostPingableConnection(Connection* conn1, 325 Connection* SelectMostPingableConnection(Connection* conn1,
320 Connection* conn2); 326 Connection* conn2);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 uint64_t tiebreaker_; 386 uint64_t tiebreaker_;
381 IceGatheringState gathering_state_; 387 IceGatheringState gathering_state_;
382 388
383 int check_receiving_interval_; 389 int check_receiving_interval_;
384 int64_t last_ping_sent_ms_ = 0; 390 int64_t last_ping_sent_ms_ = 0;
385 int weak_ping_interval_ = WEAK_PING_INTERVAL; 391 int weak_ping_interval_ = WEAK_PING_INTERVAL;
386 TransportChannelState state_ = TransportChannelState::STATE_INIT; 392 TransportChannelState state_ = TransportChannelState::STATE_INIT;
387 IceConfig config_; 393 IceConfig config_;
388 int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before. 394 int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before.
389 bool started_pinging_ = false; 395 bool started_pinging_ = false;
396 bool was_strong_ = false;
390 397
391 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); 398 RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel);
392 }; 399 };
393 400
394 } // namespace cricket 401 } // namespace cricket
395 402
396 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_ 403 #endif // WEBRTC_P2P_BASE_P2PTRANSPORTCHANNEL_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/base/p2ptransportchannel.cc » ('j') | webrtc/p2p/base/p2ptransportchannel.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698