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

Unified Diff: webrtc/p2p/base/p2ptransportchannel.cc

Issue 2053043003: Update ICE role on all ports, not just ones used for new connections. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Renaming variables, adding tests. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/p2ptransportchannel.cc
diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc
index fc1f0a4e6769ee96ce28f851d0f7cbc368fbf69c..01a67b4a2b350db0d6bf5803bdf3fa302bbb7bc0 100644
--- a/webrtc/p2p/base/p2ptransportchannel.cc
+++ b/webrtc/p2p/base/p2ptransportchannel.cc
@@ -279,6 +279,7 @@ void P2PTransportChannel::AddAllocatorSession(
// We now only want to apply new candidates that we receive to the ports
// created by this new session because these are replacing those of the
// previous sessions.
+ removed_ports_.insert(removed_ports_.end(), ports_.begin(), ports_.end());
ports_.clear();
allocator_sessions_.push_back(std::move(session));
@@ -305,16 +306,18 @@ void P2PTransportChannel::SetIceRole(IceRole ice_role) {
ASSERT(worker_thread_ == rtc::Thread::Current());
if (ice_role_ != ice_role) {
ice_role_ = ice_role;
- for (std::vector<PortInterface *>::iterator it = ports_.begin();
- it != ports_.end(); ++it) {
- (*it)->SetIceRole(ice_role);
+ for (PortInterface* port : ports_) {
+ port->SetIceRole(ice_role);
+ }
+ for (PortInterface* port : removed_ports_) {
+ port->SetIceRole(ice_role);
pthatcher1 2016/06/16 22:36:23 Maybe add a comment of why we set the ICE role of
}
}
}
void P2PTransportChannel::SetIceTiebreaker(uint64_t tiebreaker) {
ASSERT(worker_thread_ == rtc::Thread::Current());
- if (!ports_.empty()) {
+ if (!ports_.empty() || !removed_ports_.empty()) {
LOG(LS_ERROR)
<< "Attempt to change tiebreaker after Port has been allocated.";
return;
@@ -967,13 +970,13 @@ int P2PTransportChannel::SetOption(rtc::Socket::Option opt, int value) {
it->second = value;
}
- for (size_t i = 0; i < ports_.size(); ++i) {
- int val = ports_[i]->SetOption(opt, value);
+ for (PortInterface* port : ports_) {
+ int val = port->SetOption(opt, value);
if (val < 0) {
// Because this also occurs deferred, probably no point in reporting an
// error
- LOG(WARNING) << "SetOption(" << opt << ", " << value << ") failed: "
- << ports_[i]->GetError();
+ LOG(WARNING) << "SetOption(" << opt << ", " << value
+ << ") failed: " << port->GetError();
}
}
return 0;
@@ -1513,10 +1516,9 @@ void P2PTransportChannel::OnPortDestroyed(PortInterface* port) {
ASSERT(worker_thread_ == rtc::Thread::Current());
// Remove this port from the list (if we didn't drop it already).
- std::vector<PortInterface*>::iterator iter =
- std::find(ports_.begin(), ports_.end(), port);
- if (iter != ports_.end())
- ports_.erase(iter);
+ ports_.erase(std::remove(ports_.begin(), ports_.end(), port));
+ removed_ports_.erase(
+ std::remove(removed_ports_.begin(), removed_ports_.end(), port));
LOG(INFO) << "Removed port from p2p socket: "
<< static_cast<int>(ports_.size()) << " remaining";
@@ -1533,6 +1535,7 @@ void P2PTransportChannel::OnPortNetworkInactive(PortInterface* port) {
if (it == ports_.end()) {
return;
}
+ removed_ports_.push_back(*it);
ports_.erase(it);
LOG(INFO) << "Removed port due to inactive networks: " << ports_.size()
<< " remaining";
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698