#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "extensions/browser/api/sockets_tcp/tcp_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/extension_system.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/common/extension_id.h"
#include "net/base/net_errors.h"
namespace {
int kDefaultBufferSize = …;
}
namespace extensions {
namespace api {
BrowserThread;
static base::LazyInstance<
BrowserContextKeyedAPIFactory<TCPSocketEventDispatcher>>::DestructorAtExit
g_factory = …;
BrowserContextKeyedAPIFactory<TCPSocketEventDispatcher>*
TCPSocketEventDispatcher::GetFactoryInstance() { … }
TCPSocketEventDispatcher* TCPSocketEventDispatcher::Get(
content::BrowserContext* context) { … }
TCPSocketEventDispatcher::TCPSocketEventDispatcher(
content::BrowserContext* context)
: … { … }
TCPSocketEventDispatcher::~TCPSocketEventDispatcher() = default;
TCPSocketEventDispatcher::ReadParams::ReadParams() = default;
TCPSocketEventDispatcher::ReadParams::ReadParams(const ReadParams& other) =
default;
TCPSocketEventDispatcher::ReadParams::~ReadParams() = default;
void TCPSocketEventDispatcher::OnSocketConnect(const ExtensionId& extension_id,
int socket_id) { … }
void TCPSocketEventDispatcher::OnSocketResume(const ExtensionId& extension_id,
int socket_id) { … }
void TCPSocketEventDispatcher::StartSocketRead(const ExtensionId& extension_id,
int socket_id) { … }
void TCPSocketEventDispatcher::StartRead(const ReadParams& params) { … }
void TCPSocketEventDispatcher::ReadCallback(
const ReadParams& params,
int bytes_read,
scoped_refptr<net::IOBuffer> io_buffer,
bool socket_destroying) { … }
void TCPSocketEventDispatcher::PostEvent(const ReadParams& params,
std::unique_ptr<Event> event) { … }
void TCPSocketEventDispatcher::DispatchEvent(void* browser_context_id,
const ExtensionId& extension_id,
std::unique_ptr<Event> event) { … }
}
}