#include "extensions/browser/api/bluetooth_socket/bluetooth_api_socket.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/lazy_instance.h"
#include "device/bluetooth/bluetooth_socket.h"
#include "net/base/io_buffer.h"
namespace {
const char kSocketNotConnectedError[] = …;
const char kSocketNotListeningError[] = …;
}
namespace extensions {
static base::LazyInstance<BrowserContextKeyedAPIFactory<
ApiResourceManager<BluetoothApiSocket>>>::DestructorAtExit
g_server_factory = …;
template <>
BrowserContextKeyedAPIFactory<ApiResourceManager<BluetoothApiSocket> >*
ApiResourceManager<BluetoothApiSocket>::GetFactoryInstance() { … }
BluetoothApiSocket::BluetoothApiSocket(const std::string& owner_extension_id)
: … { … }
BluetoothApiSocket::BluetoothApiSocket(
const std::string& owner_extension_id,
scoped_refptr<device::BluetoothSocket> socket,
const std::string& device_address,
const device::BluetoothUUID& uuid)
: … { … }
BluetoothApiSocket::~BluetoothApiSocket() { … }
void BluetoothApiSocket::AdoptConnectedSocket(
scoped_refptr<device::BluetoothSocket> socket,
const std::string& device_address,
const device::BluetoothUUID& uuid) { … }
void BluetoothApiSocket::AdoptListeningSocket(
scoped_refptr<device::BluetoothSocket> socket,
const device::BluetoothUUID& uuid) { … }
void BluetoothApiSocket::Disconnect(base::OnceClosure callback) { … }
bool BluetoothApiSocket::IsPersistent() const { … }
void BluetoothApiSocket::Receive(int count,
ReceiveCompletionCallback success_callback,
ErrorCompletionCallback error_callback) { … }
void BluetoothApiSocket::OnSocketReceiveError(
ErrorCompletionCallback error_callback,
device::BluetoothSocket::ErrorReason reason,
const std::string& message) { … }
void BluetoothApiSocket::Send(scoped_refptr<net::IOBuffer> buffer,
int buffer_size,
SendCompletionCallback success_callback,
ErrorCompletionCallback error_callback) { … }
void BluetoothApiSocket::OnSocketSendError(
ErrorCompletionCallback error_callback,
const std::string& message) { … }
void BluetoothApiSocket::Accept(AcceptCompletionCallback success_callback,
ErrorCompletionCallback error_callback) { … }
void BluetoothApiSocket::OnSocketAcceptError(
ErrorCompletionCallback error_callback,
const std::string& message) { … }
}