Chromium Code Reviews| Index: webrtc/p2p/base/port.h |
| diff --git a/webrtc/p2p/base/port.h b/webrtc/p2p/base/port.h |
| index fbda9cea0104a9078ede4af028dc4e55d9083848..e14c770c94c9e81e812eacca13dac21f8043da95 100644 |
| --- a/webrtc/p2p/base/port.h |
| +++ b/webrtc/p2p/base/port.h |
| @@ -50,8 +50,12 @@ extern const char TCPTYPE_ACTIVE_STR[]; |
| extern const char TCPTYPE_PASSIVE_STR[]; |
| extern const char TCPTYPE_SIMOPEN_STR[]; |
| -// The length of time we wait before timing out readability on a connection. |
| -const uint32 CONNECTION_READ_TIMEOUT = 30 * 1000; // 30 seconds |
| +// If a connection does not receive anything for this long, it is considered |
| +// DEAD. |
|
pthatcher1
2015/09/17 21:45:12
DEAD => dead.
honghaiz3
2015/09/18 02:35:47
Done.
|
| +const uint32 DEAD_CONNECTION_RECEIVE_TIMEOUT = 30 * 1000; // 30 seconds. |
| + |
| +// The timeout duration when a connection does not receive anything. |
| +const uint32 WEAK_CONNECTION_RECEIVE_TIMEOUT = 2500; // 2.5 seconds |
| // The length of time we wait before timing out writability on a connection. |
| const uint32 CONNECTION_WRITE_TIMEOUT = 15 * 1000; // 15 seconds |
| @@ -417,15 +421,6 @@ class Connection : public rtc::MessageHandler, |
| // Returns the pair priority. |
| uint64 priority() const; |
| - enum ReadState { |
| - STATE_READ_INIT = 0, // we have yet to receive a ping |
| - STATE_READABLE = 1, // we have received pings recently |
| - STATE_READ_TIMEOUT = 2, // we haven't received pings in a while |
| - }; |
| - |
| - ReadState read_state() const { return read_state_; } |
| - bool readable() const { return read_state_ == STATE_READABLE; } |
| - |
| enum WriteState { |
| STATE_WRITABLE = 0, // we have received ping responses recently |
| STATE_WRITE_UNRELIABLE = 1, // we have had a few ping failures |
| @@ -435,6 +430,7 @@ class Connection : public rtc::MessageHandler, |
| WriteState write_state() const { return write_state_; } |
| bool writable() const { return write_state_ == STATE_WRITABLE; } |
| + bool receiving() const { return receiving_; } |
| // Determines whether the connection has finished connecting. This can only |
| // be false for TCP connections. |
| @@ -466,8 +462,8 @@ class Connection : public rtc::MessageHandler, |
| // Error if Send() returns < 0 |
| virtual int GetError() = 0; |
| - sigslot::signal4<Connection*, const char*, size_t, |
| - const rtc::PacketTime&> SignalReadPacket; |
| + sigslot::signal4<Connection*, const char*, size_t, const rtc::PacketTime&> |
| + SignalReadPacket; |
| sigslot::signal1<Connection*> SignalReadyToSend; |
| @@ -495,6 +491,10 @@ class Connection : public rtc::MessageHandler, |
| remote_ice_mode_ = mode; |
| } |
| + void set_receiving_timeout(uint32 receiving_timeout_ms) { |
| + receiving_timeout_ = receiving_timeout_ms; |
| + } |
| + |
| // Makes the connection go away. |
| void Destroy(); |
| @@ -565,8 +565,8 @@ class Connection : public rtc::MessageHandler, |
| void OnConnectionRequestSent(ConnectionRequest* req); |
| // Changes the state and signals if necessary. |
| - void set_read_state(ReadState value); |
| void set_write_state(WriteState value); |
| + void set_receiving(bool value); |
| void set_state(State state); |
| void set_connected(bool value); |
| @@ -578,8 +578,8 @@ class Connection : public rtc::MessageHandler, |
| Port* port_; |
| size_t local_candidate_index_; |
| Candidate remote_candidate_; |
| - ReadState read_state_; |
| WriteState write_state_; |
| + bool receiving_; |
| bool connected_; |
| bool pruned_; |
| // By default |use_candidate_attr_| flag will be true, |
| @@ -593,6 +593,7 @@ class Connection : public rtc::MessageHandler, |
| IceMode remote_ice_mode_; |
| StunRequestManager requests_; |
| uint32 rtt_; |
| + uint32 connection_created_; |
|
pthatcher1
2015/09/17 21:45:12
If this is a timestamp, call it something like cre
honghaiz3
2015/09/18 02:35:47
Use name time_created, similar to the style of las
|
| uint32 last_ping_sent_; // last time we sent a ping to the other side |
| uint32 last_ping_received_; // last time we received a ping from the other |
| // side |
| @@ -611,6 +612,8 @@ class Connection : public rtc::MessageHandler, |
| bool reported_; |
| State state_; |
| + // Time duration to switch from receiving to not receiving. |
| + uint32 receiving_timeout_; |
| friend class Port; |
| friend class ConnectionRequest; |