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

Side by Side Diff: webrtc/p2p/base/port.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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 int generation); 583 int generation);
584 584
585 // If |remote_candidate_| is peer reflexive and is equivalent to 585 // If |remote_candidate_| is peer reflexive and is equivalent to
586 // |new_candidate| except the type, update |remote_candidate_| to 586 // |new_candidate| except the type, update |remote_candidate_| to
587 // |new_candidate|. 587 // |new_candidate|.
588 void MaybeUpdatePeerReflexiveCandidate(const Candidate& new_candidate); 588 void MaybeUpdatePeerReflexiveCandidate(const Candidate& new_candidate);
589 589
590 // Returns the last received time of any data, stun request, or stun 590 // Returns the last received time of any data, stun request, or stun
591 // response in milliseconds 591 // response in milliseconds
592 int64_t last_received() const; 592 int64_t last_received() const;
593 // Returns the first time since which the connection has been in receiving
594 // state.
pthatcher1 2016/07/14 18:01:44 I think it should be more like the time at which w
honghaiz3 2016/07/14 23:15:01 Done.
595 int64_t continuously_receiving_since() const {
596 return continuously_receiving_since_;
597 }
598
599 void reset_continuously_receiving_since(int64_t now) {
600 if (continuously_receiving_since_ > 0) {
601 continuously_receiving_since_ = now;
602 }
603 }
593 604
594 bool stable(int64_t now) const; 605 bool stable(int64_t now) const;
595 606
596 protected: 607 protected:
597 enum { MSG_DELETE = 0, MSG_FIRST_AVAILABLE }; 608 enum { MSG_DELETE = 0, MSG_FIRST_AVAILABLE };
598 609
599 // Constructs a new connection to the given remote port. 610 // Constructs a new connection to the given remote port.
600 Connection(Port* port, size_t index, const Candidate& candidate); 611 Connection(Port* port, size_t index, const Candidate& candidate);
601 612
602 // Called back when StunRequestManager has a stun packet to send 613 // Called back when StunRequestManager has a stun packet to send
603 void OnSendStunPacket(const void* data, size_t size, StunRequest* req); 614 void OnSendStunPacket(const void* data, size_t size, StunRequest* req);
604 615
605 // Callbacks from ConnectionRequest 616 // Callbacks from ConnectionRequest
606 virtual void OnConnectionRequestResponse(ConnectionRequest* req, 617 virtual void OnConnectionRequestResponse(ConnectionRequest* req,
607 StunMessage* response); 618 StunMessage* response);
608 void OnConnectionRequestErrorResponse(ConnectionRequest* req, 619 void OnConnectionRequestErrorResponse(ConnectionRequest* req,
609 StunMessage* response); 620 StunMessage* response);
610 void OnConnectionRequestTimeout(ConnectionRequest* req); 621 void OnConnectionRequestTimeout(ConnectionRequest* req);
611 void OnConnectionRequestSent(ConnectionRequest* req); 622 void OnConnectionRequestSent(ConnectionRequest* req);
612 623
613 bool rtt_converged() const; 624 bool rtt_converged() const;
614 625
615 // If the response is not received within 2 * RTT, the response is assumed to 626 // If the response is not received within 2 * RTT, the response is assumed to
616 // be missing. 627 // be missing.
617 bool missing_responses(int64_t now) const; 628 bool missing_responses(int64_t now) const;
618 629
619 // Changes the state and signals if necessary. 630 // Changes the state and signals if necessary.
620 void set_write_state(WriteState value); 631 void set_write_state(WriteState value);
621 void set_receiving(bool value); 632 void UpdateReceiving(int64_t now);
622 void set_state(State state); 633 void set_state(State state);
623 void set_connected(bool value); 634 void set_connected(bool value);
624 635
625 void OnMessage(rtc::Message *pmsg); 636 void OnMessage(rtc::Message *pmsg);
626 637
627 Port* port_; 638 Port* port_;
628 size_t local_candidate_index_; 639 size_t local_candidate_index_;
629 Candidate remote_candidate_; 640 Candidate remote_candidate_;
630 WriteState write_state_; 641 WriteState write_state_;
631 bool receiving_; 642 bool receiving_;
632 bool connected_; 643 bool connected_;
633 bool pruned_; 644 bool pruned_;
634 // By default |use_candidate_attr_| flag will be true, 645 // By default |use_candidate_attr_| flag will be true,
635 // as we will be using aggressive nomination. 646 // as we will be using aggressive nomination.
636 // But when peer is ice-lite, this flag "must" be initialized to false and 647 // But when peer is ice-lite, this flag "must" be initialized to false and
637 // turn on when connection becomes "best connection". 648 // turn on when connection becomes "best connection".
638 bool use_candidate_attr_; 649 bool use_candidate_attr_;
639 // Whether this connection has been nominated by the controlling side via 650 // Whether this connection has been nominated by the controlling side via
640 // the use_candidate attribute. 651 // the use_candidate attribute.
641 bool nominated_; 652 bool nominated_;
642 IceMode remote_ice_mode_; 653 IceMode remote_ice_mode_;
643 StunRequestManager requests_; 654 StunRequestManager requests_;
644 int rtt_; 655 int rtt_;
645 int rtt_samples_ = 0; 656 int rtt_samples_ = 0;
646 int64_t last_ping_sent_; // last time we sent a ping to the other side 657 int64_t last_ping_sent_; // last time we sent a ping to the other side
647 int64_t last_ping_received_; // last time we received a ping from the other 658 int64_t last_ping_received_; // last time we received a ping from the other
648 // side 659 // side
649 int64_t last_data_received_; 660 int64_t last_data_received_;
650 int64_t last_ping_response_received_; 661 int64_t last_ping_response_received_;
662 int64_t continuously_receiving_since_ = 0;
pthatcher1 2016/07/14 18:01:44 Well, that makes it sounds like we've been continu
honghaiz3 2016/07/14 23:15:01 As I said, the value should not be used at all if
651 std::vector<SentPing> pings_since_last_response_; 663 std::vector<SentPing> pings_since_last_response_;
652 664
653 rtc::RateTracker recv_rate_tracker_; 665 rtc::RateTracker recv_rate_tracker_;
654 rtc::RateTracker send_rate_tracker_; 666 rtc::RateTracker send_rate_tracker_;
655 667
656 ConnectionInfo stats_; 668 ConnectionInfo stats_;
657 669
658 private: 670 private:
659 void MaybeAddPrflxCandidate(ConnectionRequest* request, 671 void MaybeAddPrflxCandidate(ConnectionRequest* request,
660 StunMessage* response); 672 StunMessage* response);
(...skipping 19 matching lines...) Expand all
680 const rtc::PacketOptions& options) override; 692 const rtc::PacketOptions& options) override;
681 int GetError() override { return error_; } 693 int GetError() override { return error_; }
682 694
683 private: 695 private:
684 int error_ = 0; 696 int error_ = 0;
685 }; 697 };
686 698
687 } // namespace cricket 699 } // namespace cricket
688 700
689 #endif // WEBRTC_P2P_BASE_PORT_H_ 701 #endif // WEBRTC_P2P_BASE_PORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698