#include "extensions/browser/api/sockets_tcp_server/tcp_server_socket_event_dispatcher.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/lazy_instance.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/api/socket/tcp_socket.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/common/extension_id.h"
#include "net/base/net_errors.h"
namespace extensions {
namespace api {
BrowserThread;
static base::LazyInstance<BrowserContextKeyedAPIFactory<
TCPServerSocketEventDispatcher>>::DestructorAtExit g_factory = …;
BrowserContextKeyedAPIFactory<TCPServerSocketEventDispatcher>*
TCPServerSocketEventDispatcher::GetFactoryInstance() { … }
TCPServerSocketEventDispatcher* TCPServerSocketEventDispatcher::Get(
content::BrowserContext* context) { … }
TCPServerSocketEventDispatcher::TCPServerSocketEventDispatcher(
content::BrowserContext* context)
: … { … }
TCPServerSocketEventDispatcher::~TCPServerSocketEventDispatcher() = default;
TCPServerSocketEventDispatcher::AcceptParams::AcceptParams() = default;
TCPServerSocketEventDispatcher::AcceptParams::AcceptParams(
const AcceptParams& other) = default;
TCPServerSocketEventDispatcher::AcceptParams::~AcceptParams() = default;
void TCPServerSocketEventDispatcher::OnServerSocketListen(
const ExtensionId& extension_id,
int socket_id) { … }
void TCPServerSocketEventDispatcher::OnServerSocketResume(
const ExtensionId& extension_id,
int socket_id) { … }
void TCPServerSocketEventDispatcher::StartSocketAccept(
const ExtensionId& extension_id,
int socket_id) { … }
void TCPServerSocketEventDispatcher::StartAccept(const AcceptParams& params) { … }
void TCPServerSocketEventDispatcher::AcceptCallback(
const AcceptParams& params,
int result_code,
mojo::PendingRemote<network::mojom::TCPConnectedSocket> socket,
const std::optional<net::IPEndPoint>& remote_addr,
mojo::ScopedDataPipeConsumerHandle receive_pipe_handle,
mojo::ScopedDataPipeProducerHandle send_pipe_handle) { … }
void TCPServerSocketEventDispatcher::PostEvent(const AcceptParams& params,
std::unique_ptr<Event> event) { … }
void TCPServerSocketEventDispatcher::DispatchEvent(
void* browser_context_id,
const ExtensionId& extension_id,
std::unique_ptr<Event> event) { … }
}
}