#include "device/bluetooth/bluetooth_socket_net.h"
#include <memory>
#include <string>
#include <utility>
#include "base/check.h"
#include "base/containers/queue.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/ref_counted.h"
#include "base/task/sequenced_task_runner.h"
#include "base/threading/scoped_blocking_call.h"
#include "device/bluetooth/bluetooth_socket.h"
#include "device/bluetooth/bluetooth_socket_thread.h"
#include "net/base/completion_repeating_callback.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/log/net_log_source.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
namespace {
const char kSocketNotConnected[] = …;
static void DeactivateSocket(
const scoped_refptr<device::BluetoothSocketThread>& socket_thread) { … }
}
namespace device {
BluetoothSocketNet::WriteRequest::WriteRequest()
: … { … }
BluetoothSocketNet::WriteRequest::~WriteRequest() = default;
BluetoothSocketNet::BluetoothSocketNet(
scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
scoped_refptr<BluetoothSocketThread> socket_thread)
: … { … }
BluetoothSocketNet::~BluetoothSocketNet() { … }
void BluetoothSocketNet::Disconnect(base::OnceClosure success_callback) { … }
void BluetoothSocketNet::Receive(
int buffer_size,
ReceiveCompletionCallback success_callback,
ReceiveErrorCompletionCallback error_callback) { … }
void BluetoothSocketNet::Send(scoped_refptr<net::IOBuffer> buffer,
int buffer_size,
SendCompletionCallback success_callback,
ErrorCompletionCallback error_callback) { … }
void BluetoothSocketNet::ResetData() { … }
void BluetoothSocketNet::ResetTCPSocket() { … }
void BluetoothSocketNet::SetTCPSocket(
std::unique_ptr<net::TCPSocket> tcp_socket) { … }
void BluetoothSocketNet::PostSuccess(base::OnceClosure callback) { … }
void BluetoothSocketNet::PostErrorCompletion(ErrorCompletionCallback callback,
const std::string& error) { … }
void BluetoothSocketNet::DoDisconnect(base::OnceClosure callback) { … }
void BluetoothSocketNet::DoReceive(
int buffer_size,
ReceiveCompletionCallback success_callback,
ReceiveErrorCompletionCallback error_callback) { … }
void BluetoothSocketNet::OnSocketReadComplete(
ReceiveCompletionCallback success_callback,
ReceiveErrorCompletionCallback error_callback,
int read_result) { … }
void BluetoothSocketNet::DoSend(scoped_refptr<net::IOBuffer> buffer,
int buffer_size,
SendCompletionCallback success_callback,
ErrorCompletionCallback error_callback) { … }
void BluetoothSocketNet::SendFrontWriteRequest() { … }
void BluetoothSocketNet::OnSocketWriteComplete(
SendCompletionCallback success_callback,
ErrorCompletionCallback error_callback,
int send_result) { … }
void BluetoothSocketNet::PostReceiveCompletion(
ReceiveCompletionCallback callback,
int io_buffer_size,
scoped_refptr<net::IOBuffer> io_buffer) { … }
void BluetoothSocketNet::PostReceiveErrorCompletion(
ReceiveErrorCompletionCallback callback,
ErrorReason reason,
const std::string& error_message) { … }
void BluetoothSocketNet::PostSendCompletion(SendCompletionCallback callback,
int bytes_written) { … }
}