Delete unused method ProxyServer::OnBindingDestroyed
Also use unique_ptr, to simplify destruction. Bug: webrtc:6424 Change-Id: I091980bca37ec5320f33f8219590e507d2e910d7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/129421 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27269}
This commit is contained in:
parent
c29cb2c42a
commit
d97096706b
@ -13,6 +13,7 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "absl/memory/memory.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
#include "rtc_base/socket_factory.h"
|
#include "rtc_base/socket_factory.h"
|
||||||
@ -35,12 +36,7 @@ ProxyServer::ProxyServer(SocketFactory* int_factory,
|
|||||||
server_socket_->SignalReadEvent.connect(this, &ProxyServer::OnAcceptEvent);
|
server_socket_->SignalReadEvent.connect(this, &ProxyServer::OnAcceptEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxyServer::~ProxyServer() {
|
ProxyServer::~ProxyServer() = default;
|
||||||
for (BindingList::iterator it = bindings_.begin(); it != bindings_.end();
|
|
||||||
++it) {
|
|
||||||
delete (*it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SocketAddress ProxyServer::GetServerAddress() {
|
SocketAddress ProxyServer::GetServerAddress() {
|
||||||
return server_socket_->GetLocalAddress();
|
return server_socket_->GetLocalAddress();
|
||||||
@ -55,20 +51,14 @@ void ProxyServer::OnAcceptEvent(AsyncSocket* socket) {
|
|||||||
ext_factory_->CreateAsyncSocket(ext_ip_.family(), SOCK_STREAM);
|
ext_factory_->CreateAsyncSocket(ext_ip_.family(), SOCK_STREAM);
|
||||||
if (ext_socket) {
|
if (ext_socket) {
|
||||||
ext_socket->Bind(ext_ip_);
|
ext_socket->Bind(ext_ip_);
|
||||||
bindings_.push_back(new ProxyBinding(wrapped_socket, ext_socket));
|
bindings_.emplace_back(
|
||||||
|
absl::make_unique<ProxyBinding>(wrapped_socket, ext_socket));
|
||||||
} else {
|
} else {
|
||||||
RTC_LOG(LS_ERROR)
|
RTC_LOG(LS_ERROR)
|
||||||
<< "Unable to create external socket on proxy accept event";
|
<< "Unable to create external socket on proxy accept event";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProxyServer::OnBindingDestroyed(ProxyBinding* binding) {
|
|
||||||
BindingList::iterator it =
|
|
||||||
std::find(bindings_.begin(), bindings_.end(), binding);
|
|
||||||
delete (*it);
|
|
||||||
bindings_.erase(it);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ProxyBinding
|
// ProxyBinding
|
||||||
ProxyBinding::ProxyBinding(AsyncProxyServerSocket* int_socket,
|
ProxyBinding::ProxyBinding(AsyncProxyServerSocket* int_socket,
|
||||||
AsyncSocket* ext_socket)
|
AsyncSocket* ext_socket)
|
||||||
|
|||||||
@ -11,8 +11,10 @@
|
|||||||
#ifndef RTC_BASE_PROXY_SERVER_H_
|
#ifndef RTC_BASE_PROXY_SERVER_H_
|
||||||
#define RTC_BASE_PROXY_SERVER_H_
|
#define RTC_BASE_PROXY_SERVER_H_
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "absl/memory/memory.h"
|
||||||
#include "rtc_base/async_socket.h"
|
#include "rtc_base/async_socket.h"
|
||||||
#include "rtc_base/constructor_magic.h"
|
#include "rtc_base/constructor_magic.h"
|
||||||
#include "rtc_base/server_socket_adapters.h"
|
#include "rtc_base/server_socket_adapters.h"
|
||||||
@ -74,14 +76,12 @@ class ProxyServer : public sigslot::has_slots<> {
|
|||||||
protected:
|
protected:
|
||||||
void OnAcceptEvent(AsyncSocket* socket);
|
void OnAcceptEvent(AsyncSocket* socket);
|
||||||
virtual AsyncProxyServerSocket* WrapSocket(AsyncSocket* socket) = 0;
|
virtual AsyncProxyServerSocket* WrapSocket(AsyncSocket* socket) = 0;
|
||||||
void OnBindingDestroyed(ProxyBinding* binding);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::list<ProxyBinding*> BindingList;
|
|
||||||
SocketFactory* ext_factory_;
|
SocketFactory* ext_factory_;
|
||||||
SocketAddress ext_ip_;
|
SocketAddress ext_ip_;
|
||||||
std::unique_ptr<AsyncSocket> server_socket_;
|
std::unique_ptr<AsyncSocket> server_socket_;
|
||||||
BindingList bindings_;
|
std::vector<std::unique_ptr<ProxyBinding>> bindings_;
|
||||||
RTC_DISALLOW_COPY_AND_ASSIGN(ProxyServer);
|
RTC_DISALLOW_COPY_AND_ASSIGN(ProxyServer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user