#ifndef DEVICE_BLUETOOTH_SERVER_SOCKET_H_
#define DEVICE_BLUETOOTH_SERVER_SOCKET_H_
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "device/bluetooth/public/mojom/adapter.mojom.h"
namespace device {
class BluetoothDevice;
class BluetoothSocket;
}
namespace bluetooth {
class ServerSocket : public mojom::ServerSocket {
public:
explicit ServerSocket(
scoped_refptr<device::BluetoothSocket> bluetooth_socket);
~ServerSocket() override;
ServerSocket(const ServerSocket&) = delete;
ServerSocket& operator=(const ServerSocket&) = delete;
void Accept(AcceptCallback callback) override;
void Disconnect(DisconnectCallback callback) override;
private:
void OnAccept(AcceptCallback callback,
const device::BluetoothDevice* device,
scoped_refptr<device::BluetoothSocket> socket);
void OnAcceptError(AcceptCallback callback, const std::string& error_message);
scoped_refptr<device::BluetoothSocket> server_socket_;
base::WeakPtrFactory<ServerSocket> weak_ptr_factory_{this};
};
}
#endif