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

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
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel_unittest.cc ('k') | webrtc/p2p/base/port.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/port.h
diff --git a/webrtc/p2p/base/port.h b/webrtc/p2p/base/port.h
index 811ffed2cc990e7725104190ebccfc1c92744d54..081e81af1d0c32db9a88510181745dd4ce18b673 100644
--- a/webrtc/p2p/base/port.h
+++ b/webrtc/p2p/base/port.h
@@ -122,6 +122,12 @@ typedef std::set<rtc::SocketAddress> ServerAddresses;
class Port : public PortInterface, public rtc::MessageHandler,
public sigslot::has_slots<> {
public:
+ // INIT: The state when a port is just created.
+ // KEEP_ALIVE_UNTIL_PRUNED: A port should not be destroyed even if no
+ // connection is using it.
+ // PRUNED: It will be destroyed if no connection is using it for a period of
+ // 30 seconds.
+ enum class State { INIT, KEEP_ALIVE_UNTIL_PRUNED, PRUNED };
Port(rtc::Thread* thread,
const std::string& type,
rtc::PacketSocketFactory* factory,
@@ -153,6 +159,12 @@ class Port : public PortInterface, public rtc::MessageHandler,
virtual bool SharedSocket() const { return shared_socket_; }
void ResetSharedSocket() { shared_socket_ = false; }
+ // Should not destroy the port even if no connection is using it. Called when
+ // a port is ready to use.
+ void KeepAliveUntilPruned();
+ // Allows a port to be destroyed if no connection is using it.
+ void Prune();
+
// The thread on which this port performs its I/O.
rtc::Thread* thread() { return thread_; }
@@ -297,7 +309,7 @@ class Port : public PortInterface, public rtc::MessageHandler,
int16_t network_cost() const { return network_cost_; }
protected:
- enum { MSG_CHECK_DEAD = 0, MSG_FIRST_AVAILABLE };
+ enum { MSG_DESTROY_IF_DEAD = 0, MSG_FIRST_AVAILABLE };
virtual void UpdateNetworkCost();
@@ -354,10 +366,6 @@ 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;
-
void OnNetworkTypeChanged(const rtc::Network* network);
rtc::Thread* thread_;
@@ -396,6 +404,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;
int64_t last_time_all_connections_removed_ = 0;
friend class Connection;
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel_unittest.cc ('k') | webrtc/p2p/base/port.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698