#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "extensions/browser/api/sockets_udp/udp_socket_event_dispatcher.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/lazy_instance.h"
#include "base/task/single_thread_task_runner.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/api/socket/udp_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<UDPSocketEventDispatcher>>::DestructorAtExit
g_factory = …;
BrowserContextKeyedAPIFactory<UDPSocketEventDispatcher>*
UDPSocketEventDispatcher::GetFactoryInstance() { … }
UDPSocketEventDispatcher* UDPSocketEventDispatcher::Get(
content::BrowserContext* context) { … }
UDPSocketEventDispatcher::UDPSocketEventDispatcher(
content::BrowserContext* context)
: … { … }
UDPSocketEventDispatcher::~UDPSocketEventDispatcher() = default;
UDPSocketEventDispatcher::ReceiveParams::ReceiveParams() = default;
UDPSocketEventDispatcher::ReceiveParams::ReceiveParams(
const ReceiveParams& other) = default;
UDPSocketEventDispatcher::ReceiveParams::~ReceiveParams() = default;
void UDPSocketEventDispatcher::OnSocketBind(const ExtensionId& extension_id,
int socket_id) { … }
void UDPSocketEventDispatcher::OnSocketResume(const ExtensionId& extension_id,
int socket_id) { … }
void UDPSocketEventDispatcher::StartReceive(const ReceiveParams& params) { … }
void UDPSocketEventDispatcher::ReceiveCallback(
const ReceiveParams& params,
int bytes_read,
scoped_refptr<net::IOBuffer> io_buffer,
bool socket_destroying,
const std::string& address,
uint16_t port) { … }
void UDPSocketEventDispatcher::PostEvent(const ReceiveParams& params,
std::unique_ptr<Event> event) { … }
void UDPSocketEventDispatcher::DispatchEvent(void* browser_context_id,
const ExtensionId& extension_id,
std::unique_ptr<Event> event) { … }
}
}