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

Unified Diff: webrtc/p2p/base/port.h

Issue 2171183002: Remove ports that are not used by any channel after timeout (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 side-by-side diff with in-line comments
Download patch
Index: webrtc/p2p/base/port.h
diff --git a/webrtc/p2p/base/port.h b/webrtc/p2p/base/port.h
index 37926c955603a3f27918270b5b43b177cdccddf9..94214b09bdd15047b5755eac00bcd3536b810c80 100644
--- a/webrtc/p2p/base/port.h
+++ b/webrtc/p2p/base/port.h
@@ -122,6 +122,7 @@ typedef std::set<rtc::SocketAddress> ServerAddresses;
class Port : public PortInterface, public rtc::MessageHandler,
public sigslot::has_slots<> {
public:
+ enum class State { INIT, READY, PRUNED };
pthatcher1 2016/07/28 19:35:05 This could use a description of states. Such as:
honghaiz3 2016/07/28 22:51:44 Done.
Port(rtc::Thread* thread,
const std::string& type,
rtc::PacketSocketFactory* factory,
@@ -153,6 +154,11 @@ class Port : public PortInterface, public rtc::MessageHandler,
virtual bool SharedSocket() const { return shared_socket_; }
void ResetSharedSocket() { shared_socket_ = false; }
+ // Called when a port is ready to use.
+ void BecomeReady();
pthatcher1 2016/07/28 19:35:05 I think a better name would be "KeepAliveUntilPrun
honghaiz3 2016/07/28 22:51:44 Done.
+ // Called when a port is pruned.
pthatcher1 2016/07/28 19:35:05 A better comment would be "Allows the port to be d
honghaiz3 2016/07/28 22:52:28 Done.
+ void Prune();
+
// The thread on which this port performs its I/O.
rtc::Thread* thread() { return thread_; }
@@ -297,10 +303,7 @@ class Port : public PortInterface, public rtc::MessageHandler,
int16_t network_cost() const { return network_cost_; }
protected:
- enum {
- MSG_DEAD = 0,
- MSG_FIRST_AVAILABLE
- };
+ enum { MSG_CHECK_DEAD = 0, MSG_FIRST_AVAILABLE };
pthatcher1 2016/07/28 19:35:05 MSG_MAYBE_DESTORY might be a better name than MSG_
honghaiz3 2016/07/28 22:51:44 Using MSG_DESTROY_IF_DEAD.
virtual void UpdateNetworkCost();
@@ -357,11 +360,8 @@ class Port : public PortInterface, public rtc::MessageHandler,
// Called when one of our connections deletes itself.
void OnConnectionDestroyed(Connection* conn);
- // Whether this port is dead, and hence, should be destroyed on the controlled
- // side.
- bool dead() const {
- return ice_role_ == ICEROLE_CONTROLLED && connections_.empty();
- }
+ // Whether this port is dead, and hence, should be destroyed.
+ bool dead() const;
void OnNetworkTypeChanged(const rtc::Network* network);
@@ -401,6 +401,7 @@ class Port : public PortInterface, public rtc::MessageHandler,
// (WiFi. vs. Cellular). It takes precedence over the priority when
// comparing two connections.
uint16_t network_cost_;
+ State state_ = State::INIT;
friend class Connection;
};

Powered by Google App Engine
This is Rietveld 408576698