#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "extensions/browser/api/socket/socket.h"
#include "base/functional/bind.h"
#include "base/lazy_instance.h"
#include "extensions/browser/api/api_resource_manager.h"
#include "net/base/address_list.h"
#include "net/base/io_buffer.h"
#include "net/base/ip_address.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/socket/socket.h"
namespace extensions {
const char kSocketTypeNotSupported[] = …;
static base::LazyInstance<
BrowserContextKeyedAPIFactory<ApiResourceManager<Socket>>>::DestructorAtExit
g_factory = …;
template <>
BrowserContextKeyedAPIFactory<ApiResourceManager<Socket>>*
ApiResourceManager<Socket>::GetFactoryInstance() { … }
Socket::Socket(const std::string& owner_extension_id)
: … { … }
Socket::~Socket() { … }
void Socket::Write(scoped_refptr<net::IOBuffer> io_buffer,
int byte_count,
net::CompletionOnceCallback callback) { … }
void Socket::WriteData() { … }
void Socket::OnWriteComplete(int result) { … }
void Socket::SetKeepAlive(bool enable,
int delay,
SetKeepAliveCallback callback) { … }
void Socket::SetNoDelay(bool no_delay, SetNoDelayCallback callback) { … }
void Socket::Listen(const std::string& address,
uint16_t port,
int backlog,
ListenCallback callback) { … }
void Socket::Accept(AcceptCompletionCallback callback) { … }
bool Socket::StringAndPortToIPEndPoint(const std::string& ip_address_str,
uint16_t port,
net::IPEndPoint* ip_end_point) { … }
void Socket::IPEndPointToStringAndPort(const net::IPEndPoint& address,
std::string* ip_address_str,
uint16_t* port) { … }
Socket::WriteRequest::WriteRequest(scoped_refptr<net::IOBuffer> io_buffer,
int byte_count,
net::CompletionOnceCallback callback)
: … { … }
Socket::WriteRequest::WriteRequest(WriteRequest&& other) = default;
Socket::WriteRequest::~WriteRequest() = default;
net::NetworkTrafficAnnotationTag Socket::GetNetworkTrafficAnnotationTag() { … }
}