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

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

Issue 1668073002: Add network cost as part of the connection comparison. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 // Called when the socket is currently able to send. 289 // Called when the socket is currently able to send.
290 void OnReadyToSend(); 290 void OnReadyToSend();
291 291
292 // Called when the Connection discovers a local peer reflexive candidate. 292 // Called when the Connection discovers a local peer reflexive candidate.
293 // Returns the index of the new local candidate. 293 // Returns the index of the new local candidate.
294 size_t AddPrflxCandidate(const Candidate& local); 294 size_t AddPrflxCandidate(const Candidate& local);
295 295
296 void set_candidate_filter(uint32_t candidate_filter) { 296 void set_candidate_filter(uint32_t candidate_filter) {
297 candidate_filter_ = candidate_filter; 297 candidate_filter_ = candidate_filter;
298 } 298 }
299 int32_t network_cost() const { return network_cost_; }
299 300
300 protected: 301 protected:
301 enum { 302 enum {
302 MSG_DEAD = 0, 303 MSG_DEAD = 0,
303 MSG_FIRST_AVAILABLE 304 MSG_FIRST_AVAILABLE
304 }; 305 };
305 306
306 void set_type(const std::string& type) { type_ = type; } 307 void set_type(const std::string& type) { type_ = type; }
307 308
308 void AddAddress(const rtc::SocketAddress& address, 309 void AddAddress(const rtc::SocketAddress& address,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 // Information to use when going through a proxy. 389 // Information to use when going through a proxy.
389 std::string user_agent_; 390 std::string user_agent_;
390 rtc::ProxyInfo proxy_; 391 rtc::ProxyInfo proxy_;
391 392
392 // Candidate filter is pushed down to Port such that each Port could 393 // Candidate filter is pushed down to Port such that each Port could
393 // make its own decision on how to create candidates. For example, 394 // make its own decision on how to create candidates. For example,
394 // when IceTransportsType is set to relay, both RelayPort and 395 // when IceTransportsType is set to relay, both RelayPort and
395 // TurnPort will hide raddr to avoid local address leakage. 396 // TurnPort will hide raddr to avoid local address leakage.
396 uint32_t candidate_filter_; 397 uint32_t candidate_filter_;
397 398
399 // A virtual cost perceived by the user based on the network type. It is
pthatcher1 2016/02/04 23:16:21 You should say, usually according to network type
honghaiz3 2016/02/05 01:36:46 Done.
400 // used to determine the rank of connections.
pthatcher1 2016/02/04 23:16:21 Instead of talking about rank, just say that cost
honghaiz3 2016/02/05 01:36:46 Done.
401 uint32_t network_cost_;
402
398 friend class Connection; 403 friend class Connection;
399 }; 404 };
400 405
401 // Represents a communication link between a port on the local client and a 406 // Represents a communication link between a port on the local client and a
402 // port on the remote client. 407 // port on the remote client.
403 class Connection : public rtc::MessageHandler, 408 class Connection : public rtc::MessageHandler,
404 public sigslot::has_slots<> { 409 public sigslot::has_slots<> {
405 public: 410 public:
406 struct SentPing { 411 struct SentPing {
407 SentPing(const std::string id, uint32_t sent_time) 412 SentPing(const std::string id, uint32_t sent_time)
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 // controlling side. 558 // controlling side.
554 sigslot::signal1<Connection*> SignalNominated; 559 sigslot::signal1<Connection*> SignalNominated;
555 560
556 // Invoked when Connection receives STUN error response with 487 code. 561 // Invoked when Connection receives STUN error response with 487 code.
557 void HandleRoleConflictFromPeer(); 562 void HandleRoleConflictFromPeer();
558 563
559 State state() const { return state_; } 564 State state() const { return state_; }
560 565
561 IceMode remote_ice_mode() const { return remote_ice_mode_; } 566 IceMode remote_ice_mode() const { return remote_ice_mode_; }
562 567
568 int ComputeNetworkCost() const;
569
563 // Update the ICE password of the remote candidate if |ice_ufrag| matches 570 // Update the ICE password of the remote candidate if |ice_ufrag| matches
564 // the candidate's ufrag, and the candidate's passwrod has not been set. 571 // the candidate's ufrag, and the candidate's passwrod has not been set.
565 void MaybeSetRemoteIceCredentials(const std::string& ice_ufrag, 572 void MaybeSetRemoteIceCredentials(const std::string& ice_ufrag,
566 const std::string& ice_pwd); 573 const std::string& ice_pwd);
567 574
568 // If |remote_candidate_| is peer reflexive and is equivalent to 575 // If |remote_candidate_| is peer reflexive and is equivalent to
569 // |new_candidate| except the type, update |remote_candidate_| to 576 // |new_candidate| except the type, update |remote_candidate_| to
570 // |new_candidate|. 577 // |new_candidate|.
571 void MaybeUpdatePeerReflexiveCandidate(const Candidate& new_candidate); 578 void MaybeUpdatePeerReflexiveCandidate(const Candidate& new_candidate);
572 579
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 const rtc::PacketOptions& options) override; 660 const rtc::PacketOptions& options) override;
654 int GetError() override { return error_; } 661 int GetError() override { return error_; }
655 662
656 private: 663 private:
657 int error_ = 0; 664 int error_ = 0;
658 }; 665 };
659 666
660 } // namespace cricket 667 } // namespace cricket
661 668
662 #endif // WEBRTC_P2P_BASE_PORT_H_ 669 #endif // WEBRTC_P2P_BASE_PORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698