Chromium Code Reviews| Index: webrtc/p2p/base/p2ptransportchannel.cc |
| diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc |
| index 5e5ba0156e66de9f527609fbe7b2e4e708a5a32f..a62e4aa1943a4676543aedf0abcdbeb36014aba3 100644 |
| --- a/webrtc/p2p/base/p2ptransportchannel.cc |
| +++ b/webrtc/p2p/base/p2ptransportchannel.cc |
| @@ -215,7 +215,6 @@ P2PTransportChannel::P2PTransportChannel(const std::string& transport_name, |
| best_connection_(NULL), |
| pending_best_connection_(NULL), |
| sort_dirty_(false), |
| - was_writable_(false), |
| remote_ice_mode_(ICEMODE_FULL), |
| ice_role_(ICEROLE_UNKNOWN), |
| tiebreaker_(0), |
| @@ -241,6 +240,8 @@ P2PTransportChannel::~P2PTransportChannel() { |
| // Add the allocator session to our list so that we know which sessions |
| // are still active. |
| void P2PTransportChannel::AddAllocatorSession(PortAllocatorSession* session) { |
| + ASSERT(worker_thread_ == rtc::Thread::Current()); |
| + |
| session->set_generation(static_cast<uint32_t>(allocator_sessions_.size())); |
| allocator_sessions_.push_back(session); |
| @@ -1078,11 +1079,8 @@ void P2PTransportChannel::UpdateChannelState() { |
| set_receiving(receiving); |
| } |
| -// We checked the status of our connections and we had at least one that |
| -// was writable, go into the writable state. |
| -void P2PTransportChannel::HandleWritable() { |
| - ASSERT(worker_thread_ == rtc::Thread::Current()); |
| - if (writable()) { |
| +void P2PTransportChannel::MaybeStopPortAllocatorSessions() { |
| + if (!IsGettingPorts()) { |
| return; |
| } |
| @@ -1098,16 +1096,20 @@ void P2PTransportChannel::HandleWritable() { |
| } |
| session->StopGettingPorts(); |
| } |
| +} |
| - was_writable_ = true; |
| - set_writable(true); |
| +// Go into the writable state and notify upper layer if it was not before. |
| +void P2PTransportChannel::HandleWritable() { |
| + ASSERT(worker_thread_ == rtc::Thread::Current()); |
| + if (!writable()) { |
| + set_writable(true); |
| + } |
| } |
| // Notify upper layer about channel not writable state, if it was before. |
| void P2PTransportChannel::HandleNotWritable() { |
| ASSERT(worker_thread_ == rtc::Thread::Current()); |
| - if (was_writable_) { |
| - was_writable_ = false; |
| + if (writable()) { |
| set_writable(false); |
| } |
| } |
| @@ -1291,6 +1293,14 @@ void P2PTransportChannel::OnConnectionStateChange(Connection* connection) { |
| } |
| } |
| + // May stop the session after at least one connection becomes strong |
|
pthatcher1
2015/11/04 15:06:14
strong => strongly connected
pthatcher1
2015/11/04 15:06:14
the session => allocator sessions
honghaiz3
2015/11/04 18:27:12
Done.
honghaiz3
2015/11/04 18:27:12
Done.
|
| + // after starting to get ports. It is not enough to check that the connection |
| + // becomes writable because the connection may be changing from |
|
pthatcher1
2015/11/04 15:06:14
writable => weakly connected
honghaiz3
2015/11/04 18:27:12
Done.
|
| + // (writable, receiving) to (writable, not receiving). |
| + if (!connection->weak()) { |
| + MaybeStopPortAllocatorSessions(); |
| + } |
| + |
| // We have to unroll the stack before doing this because we may be changing |
| // the state of connections while sorting. |
| RequestSort(); |