[Connection] Remove friend clause for ConnectionRequest
* Switch to StunRequest where ConnectionRequest isn't needed. * Move ConnectionRequest into Connection as a subclass * Move declaration+implementation into the .cc file. Bug: none Change-Id: I1591a91d8e13a0db9f89cfbba0fbc9478a55b789 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/264150 Reviewed-by: Niels Moller <nisse@webrtc.org> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37036}
This commit is contained in:
@ -162,13 +162,27 @@ constexpr int kSupportGoogPingVersionResponseIndex =
|
|||||||
|
|
||||||
namespace cricket {
|
namespace cricket {
|
||||||
|
|
||||||
|
class Connection::ConnectionRequest : public StunRequest {
|
||||||
|
public:
|
||||||
|
ConnectionRequest(StunRequestManager& manager, Connection* connection);
|
||||||
|
void Prepare(StunMessage* message) override;
|
||||||
|
void OnResponse(StunMessage* response) override;
|
||||||
|
void OnErrorResponse(StunMessage* response) override;
|
||||||
|
void OnTimeout() override;
|
||||||
|
void OnSent() override;
|
||||||
|
int resend_delay() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Connection* const connection_;
|
||||||
|
};
|
||||||
|
|
||||||
// A ConnectionRequest is a STUN binding used to determine writability.
|
// A ConnectionRequest is a STUN binding used to determine writability.
|
||||||
ConnectionRequest::ConnectionRequest(StunRequestManager& manager,
|
Connection::ConnectionRequest::ConnectionRequest(StunRequestManager& manager,
|
||||||
Connection* connection)
|
Connection* connection)
|
||||||
: StunRequest(manager, std::make_unique<IceMessage>()),
|
: StunRequest(manager, std::make_unique<IceMessage>()),
|
||||||
connection_(connection) {}
|
connection_(connection) {}
|
||||||
|
|
||||||
void ConnectionRequest::Prepare(StunMessage* message) {
|
void Connection::ConnectionRequest::Prepare(StunMessage* message) {
|
||||||
RTC_DCHECK_RUN_ON(connection_->network_thread_);
|
RTC_DCHECK_RUN_ON(connection_->network_thread_);
|
||||||
message->SetType(STUN_BINDING_REQUEST);
|
message->SetType(STUN_BINDING_REQUEST);
|
||||||
std::string username;
|
std::string username;
|
||||||
@ -258,22 +272,22 @@ void ConnectionRequest::Prepare(StunMessage* message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionRequest::OnResponse(StunMessage* response) {
|
void Connection::ConnectionRequest::OnResponse(StunMessage* response) {
|
||||||
RTC_DCHECK_RUN_ON(connection_->network_thread_);
|
RTC_DCHECK_RUN_ON(connection_->network_thread_);
|
||||||
connection_->OnConnectionRequestResponse(this, response);
|
connection_->OnConnectionRequestResponse(this, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionRequest::OnErrorResponse(StunMessage* response) {
|
void Connection::ConnectionRequest::OnErrorResponse(StunMessage* response) {
|
||||||
RTC_DCHECK_RUN_ON(connection_->network_thread_);
|
RTC_DCHECK_RUN_ON(connection_->network_thread_);
|
||||||
connection_->OnConnectionRequestErrorResponse(this, response);
|
connection_->OnConnectionRequestErrorResponse(this, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionRequest::OnTimeout() {
|
void Connection::ConnectionRequest::OnTimeout() {
|
||||||
RTC_DCHECK_RUN_ON(connection_->network_thread_);
|
RTC_DCHECK_RUN_ON(connection_->network_thread_);
|
||||||
connection_->OnConnectionRequestTimeout(this);
|
connection_->OnConnectionRequestTimeout(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionRequest::OnSent() {
|
void Connection::ConnectionRequest::OnSent() {
|
||||||
RTC_DCHECK_RUN_ON(connection_->network_thread_);
|
RTC_DCHECK_RUN_ON(connection_->network_thread_);
|
||||||
connection_->OnConnectionRequestSent(this);
|
connection_->OnConnectionRequestSent(this);
|
||||||
// Each request is sent only once. After a single delay , the request will
|
// Each request is sent only once. After a single delay , the request will
|
||||||
@ -281,7 +295,7 @@ void ConnectionRequest::OnSent() {
|
|||||||
set_timed_out();
|
set_timed_out();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ConnectionRequest::resend_delay() {
|
int Connection::ConnectionRequest::resend_delay() {
|
||||||
return CONNECTION_RESPONSE_TIMEOUT;
|
return CONNECTION_RESPONSE_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1313,7 +1327,7 @@ void Connection::LogCandidatePairEvent(webrtc::IceCandidatePairEventType type,
|
|||||||
ice_event_log_->LogCandidatePairEvent(type, id(), transaction_id);
|
ice_event_log_->LogCandidatePairEvent(type, id(), transaction_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::OnConnectionRequestResponse(ConnectionRequest* request,
|
void Connection::OnConnectionRequestResponse(StunRequest* request,
|
||||||
StunMessage* response) {
|
StunMessage* response) {
|
||||||
RTC_DCHECK_RUN_ON(network_thread_);
|
RTC_DCHECK_RUN_ON(network_thread_);
|
||||||
// Log at LS_INFO if we receive a ping response on an unwritable
|
// Log at LS_INFO if we receive a ping response on an unwritable
|
||||||
@ -1498,7 +1512,7 @@ ConnectionInfo Connection::stats() {
|
|||||||
return stats_;
|
return stats_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::MaybeUpdateLocalCandidate(ConnectionRequest* request,
|
void Connection::MaybeUpdateLocalCandidate(StunRequest* request,
|
||||||
StunMessage* response) {
|
StunMessage* response) {
|
||||||
// RFC 5245
|
// RFC 5245
|
||||||
// The agent checks the mapped address from the STUN response. If the
|
// The agent checks the mapped address from the STUN response. If the
|
||||||
|
@ -55,21 +55,6 @@ struct CandidatePair final : public CandidatePairInterface {
|
|||||||
Candidate remote;
|
Candidate remote;
|
||||||
};
|
};
|
||||||
|
|
||||||
// A ConnectionRequest is a simple STUN ping used to determine writability.
|
|
||||||
class ConnectionRequest : public StunRequest {
|
|
||||||
public:
|
|
||||||
ConnectionRequest(StunRequestManager& manager, Connection* connection);
|
|
||||||
void Prepare(StunMessage* message) override;
|
|
||||||
void OnResponse(StunMessage* response) override;
|
|
||||||
void OnErrorResponse(StunMessage* response) override;
|
|
||||||
void OnTimeout() override;
|
|
||||||
void OnSent() override;
|
|
||||||
int resend_delay() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Connection* const connection_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Represents a communication link between a port on the local client and a
|
// Represents a communication link between a port on the local client and a
|
||||||
// port on the remote client.
|
// port on the remote client.
|
||||||
class Connection : public CandidatePairInterface {
|
class Connection : public CandidatePairInterface {
|
||||||
@ -329,6 +314,9 @@ class Connection : public CandidatePairInterface {
|
|||||||
void set_remote_nomination(uint32_t remote_nomination);
|
void set_remote_nomination(uint32_t remote_nomination);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// A ConnectionRequest is a simple STUN ping used to determine writability.
|
||||||
|
class ConnectionRequest;
|
||||||
|
|
||||||
// Constructs a new connection to the given remote port.
|
// Constructs a new connection to the given remote port.
|
||||||
Connection(rtc::WeakPtr<Port> port, size_t index, const Candidate& candidate);
|
Connection(rtc::WeakPtr<Port> port, size_t index, const Candidate& candidate);
|
||||||
|
|
||||||
@ -336,7 +324,7 @@ class Connection : public CandidatePairInterface {
|
|||||||
void OnSendStunPacket(const void* data, size_t size, StunRequest* req);
|
void OnSendStunPacket(const void* data, size_t size, StunRequest* req);
|
||||||
|
|
||||||
// Callbacks from ConnectionRequest
|
// Callbacks from ConnectionRequest
|
||||||
virtual void OnConnectionRequestResponse(ConnectionRequest* req,
|
virtual void OnConnectionRequestResponse(StunRequest* req,
|
||||||
StunMessage* response);
|
StunMessage* response);
|
||||||
void OnConnectionRequestErrorResponse(ConnectionRequest* req,
|
void OnConnectionRequestErrorResponse(ConnectionRequest* req,
|
||||||
StunMessage* response)
|
StunMessage* response)
|
||||||
@ -380,8 +368,7 @@ class Connection : public CandidatePairInterface {
|
|||||||
private:
|
private:
|
||||||
// Update the local candidate based on the mapped address attribute.
|
// Update the local candidate based on the mapped address attribute.
|
||||||
// If the local candidate changed, fires SignalStateChange.
|
// If the local candidate changed, fires SignalStateChange.
|
||||||
void MaybeUpdateLocalCandidate(ConnectionRequest* request,
|
void MaybeUpdateLocalCandidate(StunRequest* request, StunMessage* response)
|
||||||
StunMessage* response)
|
|
||||||
RTC_RUN_ON(network_thread_);
|
RTC_RUN_ON(network_thread_);
|
||||||
|
|
||||||
void LogCandidatePairConfig(webrtc::IceCandidatePairConfigType type)
|
void LogCandidatePairConfig(webrtc::IceCandidatePairConfigType type)
|
||||||
@ -467,8 +454,6 @@ class Connection : public CandidatePairInterface {
|
|||||||
const IceFieldTrials* field_trials_;
|
const IceFieldTrials* field_trials_;
|
||||||
rtc::EventBasedExponentialMovingAverage rtt_estimate_
|
rtc::EventBasedExponentialMovingAverage rtt_estimate_
|
||||||
RTC_GUARDED_BY(network_thread_);
|
RTC_GUARDED_BY(network_thread_);
|
||||||
|
|
||||||
friend class ConnectionRequest;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ProxyConnection defers all the interesting work to the port.
|
// ProxyConnection defers all the interesting work to the port.
|
||||||
|
@ -419,7 +419,7 @@ int TCPConnection::GetError() {
|
|||||||
return error_;
|
return error_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCPConnection::OnConnectionRequestResponse(ConnectionRequest* req,
|
void TCPConnection::OnConnectionRequestResponse(StunRequest* req,
|
||||||
StunMessage* response) {
|
StunMessage* response) {
|
||||||
// Process the STUN response before we inform upper layer ready to send.
|
// Process the STUN response before we inform upper layer ready to send.
|
||||||
Connection::OnConnectionRequestResponse(req, response);
|
Connection::OnConnectionRequestResponse(req, response);
|
||||||
|
@ -148,7 +148,7 @@ class TCPConnection : public Connection, public sigslot::has_slots<> {
|
|||||||
protected:
|
protected:
|
||||||
// Set waiting_for_stun_binding_complete_ to false to allow data packets in
|
// Set waiting_for_stun_binding_complete_ to false to allow data packets in
|
||||||
// addition to what Port::OnConnectionRequestResponse does.
|
// addition to what Port::OnConnectionRequestResponse does.
|
||||||
void OnConnectionRequestResponse(ConnectionRequest* req,
|
void OnConnectionRequestResponse(StunRequest* req,
|
||||||
StunMessage* response) override;
|
StunMessage* response) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user