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

Side by Side Diff: webrtc/p2p/base/p2ptransportchannel.cc

Issue 2176743003: Merge SignalPortPruned with SignalPortsRemoved in PortAllocatorSession (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // Add the allocator session to our list so that we know which sessions 131 // Add the allocator session to our list so that we know which sessions
132 // are still active. 132 // are still active.
133 void P2PTransportChannel::AddAllocatorSession( 133 void P2PTransportChannel::AddAllocatorSession(
134 std::unique_ptr<PortAllocatorSession> session) { 134 std::unique_ptr<PortAllocatorSession> session) {
135 ASSERT(worker_thread_ == rtc::Thread::Current()); 135 ASSERT(worker_thread_ == rtc::Thread::Current());
136 136
137 session->set_generation(static_cast<uint32_t>(allocator_sessions_.size())); 137 session->set_generation(static_cast<uint32_t>(allocator_sessions_.size()));
138 session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady); 138 session->SignalPortReady.connect(this, &P2PTransportChannel::OnPortReady);
139 session->SignalPortsRemoved.connect(this, 139 session->SignalPortsRemoved.connect(this,
140 &P2PTransportChannel::OnPortsRemoved); 140 &P2PTransportChannel::OnPortsRemoved);
141 session->SignalPortPruned.connect(this, &P2PTransportChannel::OnPortPruned);
142 session->SignalCandidatesReady.connect( 141 session->SignalCandidatesReady.connect(
143 this, &P2PTransportChannel::OnCandidatesReady); 142 this, &P2PTransportChannel::OnCandidatesReady);
144 session->SignalCandidatesRemoved.connect( 143 session->SignalCandidatesRemoved.connect(
145 this, &P2PTransportChannel::OnCandidatesRemoved); 144 this, &P2PTransportChannel::OnCandidatesRemoved);
146 session->SignalCandidatesAllocationDone.connect( 145 session->SignalCandidatesAllocationDone.connect(
147 this, &P2PTransportChannel::OnCandidatesAllocationDone); 146 this, &P2PTransportChannel::OnCandidatesAllocationDone);
148 147
149 // We now only want to apply new candidates that we receive to the ports 148 // We now only want to apply new candidates that we receive to the ports
150 // created by this new session because these are replacing those of the 149 // created by this new session because these are replacing those of the
151 // previous sessions. 150 // previous sessions.
(...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 std::remove(removed_ports_.begin(), removed_ports_.end(), port), 1681 std::remove(removed_ports_.begin(), removed_ports_.end(), port),
1683 removed_ports_.end()); 1682 removed_ports_.end());
1684 LOG(INFO) << "Removed port because it is destroyed: " << ports_.size() 1683 LOG(INFO) << "Removed port because it is destroyed: " << ports_.size()
1685 << " remaining"; 1684 << " remaining";
1686 } 1685 }
1687 1686
1688 void P2PTransportChannel::OnPortsRemoved( 1687 void P2PTransportChannel::OnPortsRemoved(
1689 PortAllocatorSession* session, 1688 PortAllocatorSession* session,
1690 const std::vector<PortInterface*>& ports) { 1689 const std::vector<PortInterface*>& ports) {
1691 ASSERT(worker_thread_ == rtc::Thread::Current()); 1690 ASSERT(worker_thread_ == rtc::Thread::Current());
1692 LOG(LS_INFO) << "Remove " << ports.size() << " ports";
1693 for (PortInterface* port : ports) { 1691 for (PortInterface* port : ports) {
1694 if (RemovePort(port)) { 1692 if (RemovePort(port)) {
1695 LOG(INFO) << "Removed port: " << port->ToString() << " " << ports_.size() 1693 LOG(INFO) << "Removed port: " << port->ToString() << " " << ports_.size()
1696 << " remaining"; 1694 << " remaining";
1697 } 1695 }
1698 } 1696 }
1699 } 1697 }
1700 1698
1701 void P2PTransportChannel::OnCandidatesRemoved( 1699 void P2PTransportChannel::OnCandidatesRemoved(
1702 PortAllocatorSession* session, 1700 PortAllocatorSession* session,
(...skipping 20 matching lines...) Expand all
1723 // continually, so there is an implicit check on continual gathering here. 1721 // continually, so there is an implicit check on continual gathering here.
1724 if (!allocator_sessions_.empty() && allocator_session()->IsCleared()) { 1722 if (!allocator_sessions_.empty() && allocator_session()->IsCleared()) {
1725 allocator_session()->RegatherOnFailedNetworks(); 1723 allocator_session()->RegatherOnFailedNetworks();
1726 } 1724 }
1727 1725
1728 thread()->PostDelayed(RTC_FROM_HERE, 1726 thread()->PostDelayed(RTC_FROM_HERE,
1729 *config_.regather_on_failed_networks_interval, this, 1727 *config_.regather_on_failed_networks_interval, this,
1730 MSG_REGATHER_ON_FAILED_NETWORKS); 1728 MSG_REGATHER_ON_FAILED_NETWORKS);
1731 } 1729 }
1732 1730
1733 void P2PTransportChannel::OnPortPruned(PortAllocatorSession* session,
1734 PortInterface* port) {
1735 if (RemovePort(port)) {
1736 LOG(INFO) << "Removed port because it is pruned: " << port->ToString()
1737 << " " << ports_.size() << " remaining";
1738 }
1739 }
1740
1741 bool P2PTransportChannel::RemovePort(PortInterface* port) { 1731 bool P2PTransportChannel::RemovePort(PortInterface* port) {
pthatcher1 2016/07/27 18:38:11 This should probably be called OnPortPruned
honghaiz3 2016/07/27 21:31:26 Done.
1742 auto it = std::find(ports_.begin(), ports_.end(), port); 1732 auto it = std::find(ports_.begin(), ports_.end(), port);
1743 // Don't need to do anything if the port has been deleted from the port list. 1733 // Don't need to do anything if the port has been deleted from the port list.
1744 if (it == ports_.end()) { 1734 if (it == ports_.end()) {
1745 return false; 1735 return false;
1746 } 1736 }
1747 ports_.erase(it); 1737 ports_.erase(it);
1748 removed_ports_.push_back(port); 1738 removed_ports_.push_back(port);
1749 return true; 1739 return true;
1750 } 1740 }
1751 1741
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 1883
1894 // During the initial state when nothing has been pinged yet, return the first 1884 // During the initial state when nothing has been pinged yet, return the first
1895 // one in the ordered |connections_|. 1885 // one in the ordered |connections_|.
1896 return *(std::find_if(connections_.begin(), connections_.end(), 1886 return *(std::find_if(connections_.begin(), connections_.end(),
1897 [conn1, conn2](Connection* conn) { 1887 [conn1, conn2](Connection* conn) {
1898 return conn == conn1 || conn == conn2; 1888 return conn == conn1 || conn == conn2;
1899 })); 1889 }));
1900 } 1890 }
1901 1891
1902 } // namespace cricket 1892 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698