Chromium Code Reviews| Index: webrtc/p2p/base/port.h |
| diff --git a/webrtc/p2p/base/port.h b/webrtc/p2p/base/port.h |
| index 4d156567766746405c54cc94d4911effbc4dd2a6..46d18c514d5bb7258093b2e225f181ce610e5435 100644 |
| --- a/webrtc/p2p/base/port.h |
| +++ b/webrtc/p2p/base/port.h |
| @@ -433,6 +433,47 @@ class Port : public PortInterface, public rtc::MessageHandler, |
| friend class Connection; |
| }; |
| +class PacketLossEstimator { |
|
Taylor Brandstetter
2017/03/01 02:26:12
Some comments around this class may be helpful. Su
Zach Stein
2017/03/02 00:02:23
Done.
|
| + public: |
| + struct PacketInfo { |
|
Taylor Brandstetter
2017/03/01 02:26:12
It looks like this struct can be private.
Zach Stein
2017/03/02 00:02:23
Don't need this now that outstanding_packets_ is a
|
| + PacketInfo(const std::string id, int64_t sent_time) |
| + : id(id), sent_time(sent_time) {} |
| + |
| + std::string id; |
| + int64_t sent_time; |
| + }; |
| + |
| + PacketLossEstimator(int64_t expire_after); |
|
Taylor Brandstetter
2017/03/01 02:26:12
Doesn't have to be in this CL, but it may be usefu
Zach Stein
2017/03/02 00:02:23
I like this idea but will leave it for another CL.
|
| + |
| + void ExpectResponse(std::string id, int64_t sent_time); |
| + |
| + void ReceivedResponse(std::string id, int64_t received_time); |
| + |
| + void RemoveExpiredPackets(int64_t now); |
| + |
| + // This is updated during ReceivedResponse and RemoveExpiredPackets. |
|
Taylor Brandstetter
2017/03/01 02:26:12
The code may be more readable if only "RemoveExpir
Zach Stein
2017/03/02 00:02:23
Good suggestion, I think this will be cleaner.
|
| + // You may want to call RemoveExpiredPackets to ensure the data is up to date. |
| + double get_response_rate() const { return response_rate_; } |
| + |
| + protected: |
| + // for unittests |
| + int64_t get_responses_expected() const { return responses_expected_; } |
| + // for unittests |
| + int64_t get_responses_received() const { return responses_received_; } |
|
Taylor Brandstetter
2017/03/01 02:26:13
I'd prefer not having "for test" methods unless ab
Zach Stein
2017/03/02 00:02:23
I think this gives better coverage (ResponseLost/R
Taylor Brandstetter
2017/03/02 03:09:57
ResponseLate and ResponseLost could be updated to
|
| + |
| + private: |
| + void UpdateResponseRate(); |
| + |
| + bool IsExpired(const PacketInfo& packet, int64_t received_time) const; |
| + |
| + int64_t expire_after_; // in milliseconds |
| + |
| + std::vector<PacketInfo> outstanding_packets_; |
|
Taylor Brandstetter
2017/03/01 02:26:12
nit: Probably doesn't matter, but would an unorder
Zach Stein
2017/03/02 00:02:23
Maybe. Thinking about this did make me realize tha
|
| + int64_t responses_expected_ = 0; |
| + int64_t responses_received_ = 0; |
| + double response_rate_ = 1.0; |
| +}; |
|
Taylor Brandstetter
2017/03/01 02:26:12
I think we can move this to its own file; port.h a
Zach Stein
2017/03/02 00:02:23
Acknowledged. I will do this in a separate upload
Taylor Brandstetter
2017/03/02 03:09:57
Thanks; that does help a lot.
|
| + |
| // Represents a communication link between a port on the local client and a |
| // port on the remote client. |
| class Connection : public CandidatePairInterface, |
| @@ -719,6 +760,8 @@ class Connection : public CandidatePairInterface, |
| int64_t receiving_unchanged_since_ = 0; |
| std::vector<SentPing> pings_since_last_response_; |
| + PacketLossEstimator packet_loss_estimator_; |
| + |
| bool reported_; |
| IceCandidatePairState state_; |
| // Time duration to switch from receiving to not receiving. |