diff options
Diffstat (limited to 'p2p/base/port.h')
-rw-r--r-- | p2p/base/port.h | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/p2p/base/port.h b/p2p/base/port.h index 66da9b841c..9a0073a5da 100644 --- a/p2p/base/port.h +++ b/p2p/base/port.h @@ -41,6 +41,7 @@ #include "rtc_base/rate_tracker.h" #include "rtc_base/socket_address.h" #include "rtc_base/system/rtc_export.h" +#include "rtc_base/task_utils/pending_task_safety_flag.h" #include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/weak_ptr.h" @@ -99,14 +100,24 @@ class StunStats { // Stats that we can return about a candidate. class CandidateStats { public: - CandidateStats(); - explicit CandidateStats(Candidate candidate); - CandidateStats(const CandidateStats&); - ~CandidateStats(); + CandidateStats() = default; + CandidateStats(const CandidateStats&) = default; + CandidateStats(CandidateStats&&) = default; + CandidateStats(Candidate candidate, + absl::optional<StunStats> stats = absl::nullopt) + : candidate_(std::move(candidate)), stun_stats_(std::move(stats)) {} + ~CandidateStats() = default; - Candidate candidate; + CandidateStats& operator=(const CandidateStats& other) = default; + + const Candidate& candidate() const { return candidate_; } + + const absl::optional<StunStats>& stun_stats() const { return stun_stats_; } + + private: + Candidate candidate_; // STUN port stats if this candidate is a STUN candidate. - absl::optional<StunStats> stun_stats; + absl::optional<StunStats> stun_stats_; }; typedef std::vector<CandidateStats> CandidateStatsList; @@ -161,7 +172,6 @@ typedef std::set<rtc::SocketAddress> ServerAddresses; // connections to similar mechanisms of the other client. Subclasses of this // one add support for specific mechanisms like local UDP ports. class Port : public PortInterface, - public rtc::MessageHandler, public sigslot::has_slots<> { public: // INIT: The state when a port is just created. @@ -210,17 +220,11 @@ class Port : public PortInterface, // Allows a port to be destroyed if no connection is using it. void Prune(); - // Call to stop any currently pending operations from running. - void CancelPendingTasks(); - // The thread on which this port performs its I/O. rtc::Thread* thread() { return thread_; } // The factory used to create the sockets of this port. rtc::PacketSocketFactory* socket_factory() const { return factory_; } - void set_socket_factory(rtc::PacketSocketFactory* factory) { - factory_ = factory; - } // For debugging purposes. const std::string& content_name() const { return content_name_; } @@ -321,8 +325,6 @@ class Port : public PortInterface, // Called if the port has no connections and is no longer useful. void Destroy(); - void OnMessage(rtc::Message* pmsg) override; - // Debugging description of this port std::string ToString() const override; uint16_t min_port() { return min_port_; } @@ -373,8 +375,6 @@ class Port : public PortInterface, const rtc::SocketAddress& base_address); protected: - enum { MSG_DESTROY_IF_DEAD = 0, MSG_FIRST_AVAILABLE }; - virtual void UpdateNetworkCost(); void set_type(const std::string& type) { type_ = type; } @@ -441,11 +441,12 @@ class Port : public PortInterface, void Construct(); // Called when one of our connections deletes itself. void OnConnectionDestroyed(Connection* conn); - void OnNetworkTypeChanged(const rtc::Network* network); + void ScheduleDelayedDestructionIfDead(); + void DestroyIfDead(); rtc::Thread* const thread_; - rtc::PacketSocketFactory* factory_; + rtc::PacketSocketFactory* const factory_; std::string type_; bool send_retransmit_count_attribute_; rtc::Network* network_; @@ -492,6 +493,7 @@ class Port : public PortInterface, friend class Connection; webrtc::CallbackList<PortInterface*> port_destroyed_callback_list_; + webrtc::ScopedTaskSafety safety_; }; } // namespace cricket |