#include "extensions/browser/api/sockets_tcp/sockets_tcp_api.h"
#include <memory>
#include <string>
#include <unordered_set>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/types/optional_util.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/socket_permission_request.h"
#include "extensions/browser/api/socket/tcp_socket.h"
#include "extensions/browser/api/socket/tls_socket.h"
#include "extensions/browser/api/sockets_tcp/tcp_socket_event_dispatcher.h"
#include "extensions/common/api/sockets_tcp.h"
#include "net/base/net_errors.h"
ResumableTCPSocket;
SocketInfo;
SocketProperties;
namespace {
const char kSocketNotFoundError[] = …;
const char kPermissionError[] = …;
const char kInvalidSocketStateError[] = …;
const char kSocketNotConnectedError[] = …;
SocketInfo CreateSocketInfo(int socket_id, ResumableTCPSocket* socket) { … }
void SetSocketProperties(ResumableTCPSocket* socket,
SocketProperties* properties) { … }
}
namespace extensions {
namespace api {
SocketPermissionRequest;
TCPSocketApiFunction::~TCPSocketApiFunction() = default;
std::unique_ptr<SocketResourceManagerInterface>
TCPSocketApiFunction::CreateSocketResourceManager() { … }
ResumableTCPSocket* TCPSocketApiFunction::GetTcpSocket(int socket_id) { … }
TCPSocketExtensionWithDnsLookupFunction::
~TCPSocketExtensionWithDnsLookupFunction() = default;
std::unique_ptr<SocketResourceManagerInterface>
TCPSocketExtensionWithDnsLookupFunction::CreateSocketResourceManager() { … }
ResumableTCPSocket* TCPSocketExtensionWithDnsLookupFunction::GetTcpSocket(
int socket_id) { … }
SocketsTcpCreateFunction::SocketsTcpCreateFunction() = default;
SocketsTcpCreateFunction::~SocketsTcpCreateFunction() = default;
ExtensionFunction::ResponseAction SocketsTcpCreateFunction::Work() { … }
SocketsTcpUpdateFunction::SocketsTcpUpdateFunction() = default;
SocketsTcpUpdateFunction::~SocketsTcpUpdateFunction() = default;
ExtensionFunction::ResponseAction SocketsTcpUpdateFunction::Work() { … }
SocketsTcpSetPausedFunction::SocketsTcpSetPausedFunction() = default;
SocketsTcpSetPausedFunction::~SocketsTcpSetPausedFunction() = default;
ExtensionFunction::ResponseAction SocketsTcpSetPausedFunction::Work() { … }
SocketsTcpSetKeepAliveFunction::SocketsTcpSetKeepAliveFunction() = default;
SocketsTcpSetKeepAliveFunction::~SocketsTcpSetKeepAliveFunction() = default;
ExtensionFunction::ResponseAction SocketsTcpSetKeepAliveFunction::Work() { … }
void SocketsTcpSetKeepAliveFunction::OnCompleted(bool success) { … }
SocketsTcpSetNoDelayFunction::SocketsTcpSetNoDelayFunction() = default;
SocketsTcpSetNoDelayFunction::~SocketsTcpSetNoDelayFunction() = default;
ExtensionFunction::ResponseAction SocketsTcpSetNoDelayFunction::Work() { … }
void SocketsTcpSetNoDelayFunction::OnCompleted(bool success) { … }
SocketsTcpConnectFunction::SocketsTcpConnectFunction() = default;
SocketsTcpConnectFunction::~SocketsTcpConnectFunction() = default;
ExtensionFunction::ResponseAction SocketsTcpConnectFunction::Work() { … }
void SocketsTcpConnectFunction::AfterDnsLookup(int lookup_result) { … }
void SocketsTcpConnectFunction::StartConnect() { … }
void SocketsTcpConnectFunction::OnCompleted(int net_result) { … }
SocketsTcpDisconnectFunction::SocketsTcpDisconnectFunction() = default;
SocketsTcpDisconnectFunction::~SocketsTcpDisconnectFunction() = default;
ExtensionFunction::ResponseAction SocketsTcpDisconnectFunction::Work() { … }
SocketsTcpSendFunction::SocketsTcpSendFunction() = default;
SocketsTcpSendFunction::~SocketsTcpSendFunction() = default;
ExtensionFunction::ResponseAction SocketsTcpSendFunction::Work() { … }
void SocketsTcpSendFunction::OnCompleted(int net_result) { … }
void SocketsTcpSendFunction::SetSendResult(int net_result, int bytes_sent) { … }
SocketsTcpCloseFunction::SocketsTcpCloseFunction() = default;
SocketsTcpCloseFunction::~SocketsTcpCloseFunction() = default;
ExtensionFunction::ResponseAction SocketsTcpCloseFunction::Work() { … }
SocketsTcpGetInfoFunction::SocketsTcpGetInfoFunction() = default;
SocketsTcpGetInfoFunction::~SocketsTcpGetInfoFunction() = default;
ExtensionFunction::ResponseAction SocketsTcpGetInfoFunction::Work() { … }
SocketsTcpGetSocketsFunction::SocketsTcpGetSocketsFunction() = default;
SocketsTcpGetSocketsFunction::~SocketsTcpGetSocketsFunction() = default;
ExtensionFunction::ResponseAction SocketsTcpGetSocketsFunction::Work() { … }
SocketsTcpSecureFunction::SocketsTcpSecureFunction() = default;
SocketsTcpSecureFunction::~SocketsTcpSecureFunction() = default;
ExtensionFunction::ResponseAction SocketsTcpSecureFunction::Work() { … }
void SocketsTcpSecureFunction::TlsConnectDone(
int result,
mojo::PendingRemote<network::mojom::TLSClientSocket> tls_socket,
const net::IPEndPoint& local_addr,
const net::IPEndPoint& peer_addr,
mojo::ScopedDataPipeConsumerHandle receive_pipe_handle,
mojo::ScopedDataPipeProducerHandle send_pipe_handle) { … }
}
}