Delete AsyncSocket class, merge into Socket class
Bug: webrtc:13065 Change-Id: I13afee2386ea9c4de0e4fa95133f0c4d3ec826e8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227031 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34787}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
45b3e530cb
commit
d0b8879770
@ -61,8 +61,8 @@ rtc::IPAddress QueryDefaultLocalAddress(int family) {
|
||||
RTC_DCHECK(thread->socketserver() != nullptr);
|
||||
RTC_DCHECK(family == AF_INET || family == AF_INET6);
|
||||
|
||||
std::unique_ptr<rtc::AsyncSocket> socket(
|
||||
thread->socketserver()->CreateAsyncSocket(family, SOCK_DGRAM));
|
||||
std::unique_ptr<rtc::Socket> socket(
|
||||
thread->socketserver()->CreateSocket(family, SOCK_DGRAM));
|
||||
if (!socket) {
|
||||
RTC_LOG_ERR(LERROR) << "Socket creation failed";
|
||||
return rtc::IPAddress();
|
||||
|
||||
@ -26,7 +26,7 @@ const char kByeMessage[] = "BYE";
|
||||
// Delay between server connection retries, in milliseconds
|
||||
const int kReconnectDelay = 2000;
|
||||
|
||||
rtc::AsyncSocket* CreateClientSocket(int family) {
|
||||
rtc::Socket* CreateClientSocket(int family) {
|
||||
#ifdef WIN32
|
||||
rtc::Win32Socket* sock = new rtc::Win32Socket();
|
||||
sock->CreateT(family, SOCK_STREAM);
|
||||
@ -34,7 +34,7 @@ rtc::AsyncSocket* CreateClientSocket(int family) {
|
||||
#elif defined(WEBRTC_POSIX)
|
||||
rtc::Thread* thread = rtc::Thread::Current();
|
||||
RTC_DCHECK(thread != NULL);
|
||||
return thread->socketserver()->CreateAsyncSocket(family, SOCK_STREAM);
|
||||
return thread->socketserver()->CreateSocket(family, SOCK_STREAM);
|
||||
#else
|
||||
#error Platform not supported.
|
||||
#endif
|
||||
@ -227,14 +227,14 @@ bool PeerConnectionClient::ConnectControlSocket() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void PeerConnectionClient::OnConnect(rtc::AsyncSocket* socket) {
|
||||
void PeerConnectionClient::OnConnect(rtc::Socket* socket) {
|
||||
RTC_DCHECK(!onconnect_data_.empty());
|
||||
size_t sent = socket->Send(onconnect_data_.c_str(), onconnect_data_.length());
|
||||
RTC_DCHECK(sent == onconnect_data_.length());
|
||||
onconnect_data_.clear();
|
||||
}
|
||||
|
||||
void PeerConnectionClient::OnHangingGetConnect(rtc::AsyncSocket* socket) {
|
||||
void PeerConnectionClient::OnHangingGetConnect(rtc::Socket* socket) {
|
||||
char buffer[1024];
|
||||
snprintf(buffer, sizeof(buffer), "GET /wait?peer_id=%i HTTP/1.0\r\n\r\n",
|
||||
my_id_);
|
||||
@ -283,7 +283,7 @@ bool PeerConnectionClient::GetHeaderValue(const std::string& data,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PeerConnectionClient::ReadIntoBuffer(rtc::AsyncSocket* socket,
|
||||
bool PeerConnectionClient::ReadIntoBuffer(rtc::Socket* socket,
|
||||
std::string* data,
|
||||
size_t* content_length) {
|
||||
char buffer[0xffff];
|
||||
@ -321,7 +321,7 @@ bool PeerConnectionClient::ReadIntoBuffer(rtc::AsyncSocket* socket,
|
||||
return ret;
|
||||
}
|
||||
|
||||
void PeerConnectionClient::OnRead(rtc::AsyncSocket* socket) {
|
||||
void PeerConnectionClient::OnRead(rtc::Socket* socket) {
|
||||
size_t content_length = 0;
|
||||
if (ReadIntoBuffer(socket, &control_data_, &content_length)) {
|
||||
size_t peer_id = 0, eoh = 0;
|
||||
@ -373,7 +373,7 @@ void PeerConnectionClient::OnRead(rtc::AsyncSocket* socket) {
|
||||
}
|
||||
}
|
||||
|
||||
void PeerConnectionClient::OnHangingGetRead(rtc::AsyncSocket* socket) {
|
||||
void PeerConnectionClient::OnHangingGetRead(rtc::Socket* socket) {
|
||||
RTC_LOG(INFO) << __FUNCTION__;
|
||||
size_t content_length = 0;
|
||||
if (ReadIntoBuffer(socket, ¬ification_data_, &content_length)) {
|
||||
@ -471,7 +471,7 @@ bool PeerConnectionClient::ParseServerResponse(const std::string& response,
|
||||
return true;
|
||||
}
|
||||
|
||||
void PeerConnectionClient::OnClose(rtc::AsyncSocket* socket, int err) {
|
||||
void PeerConnectionClient::OnClose(rtc::Socket* socket, int err) {
|
||||
RTC_LOG(INFO) << __FUNCTION__;
|
||||
|
||||
socket->Close();
|
||||
|
||||
@ -73,8 +73,8 @@ class PeerConnectionClient : public sigslot::has_slots<>,
|
||||
void Close();
|
||||
void InitSocketSignals();
|
||||
bool ConnectControlSocket();
|
||||
void OnConnect(rtc::AsyncSocket* socket);
|
||||
void OnHangingGetConnect(rtc::AsyncSocket* socket);
|
||||
void OnConnect(rtc::Socket* socket);
|
||||
void OnHangingGetConnect(rtc::Socket* socket);
|
||||
void OnMessageFromPeer(int peer_id, const std::string& message);
|
||||
|
||||
// Quick and dirty support for parsing HTTP header values.
|
||||
@ -89,13 +89,13 @@ class PeerConnectionClient : public sigslot::has_slots<>,
|
||||
std::string* value);
|
||||
|
||||
// Returns true if the whole response has been read.
|
||||
bool ReadIntoBuffer(rtc::AsyncSocket* socket,
|
||||
bool ReadIntoBuffer(rtc::Socket* socket,
|
||||
std::string* data,
|
||||
size_t* content_length);
|
||||
|
||||
void OnRead(rtc::AsyncSocket* socket);
|
||||
void OnRead(rtc::Socket* socket);
|
||||
|
||||
void OnHangingGetRead(rtc::AsyncSocket* socket);
|
||||
void OnHangingGetRead(rtc::Socket* socket);
|
||||
|
||||
// Parses a single line entry in the form "<name>,<id>,<connected>"
|
||||
bool ParseEntry(const std::string& entry,
|
||||
@ -110,15 +110,15 @@ class PeerConnectionClient : public sigslot::has_slots<>,
|
||||
size_t* peer_id,
|
||||
size_t* eoh);
|
||||
|
||||
void OnClose(rtc::AsyncSocket* socket, int err);
|
||||
void OnClose(rtc::Socket* socket, int err);
|
||||
|
||||
void OnResolveResult(rtc::AsyncResolverInterface* resolver);
|
||||
|
||||
PeerConnectionClientObserver* callback_;
|
||||
rtc::SocketAddress server_address_;
|
||||
rtc::AsyncResolver* resolver_;
|
||||
std::unique_ptr<rtc::AsyncSocket> control_socket_;
|
||||
std::unique_ptr<rtc::AsyncSocket> hanging_get_;
|
||||
std::unique_ptr<rtc::Socket> control_socket_;
|
||||
std::unique_ptr<rtc::Socket> hanging_get_;
|
||||
std::string onconnect_data_;
|
||||
std::string control_data_;
|
||||
std::string notification_data_;
|
||||
|
||||
Reference in New Issue
Block a user