#include "extensions/browser/api/serial/serial_port_manager.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/lazy_instance.h"
#include "base/no_destructor.h"
#include "build/build_config.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/device_service.h"
#include "extensions/browser/api/serial/serial_connection.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/common/extension_id.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
namespace extensions {
namespace api {
namespace {
bool ShouldPauseOnReceiveError(serial::ReceiveError error) { … }
SerialPortManager::Binder& GetBinderOverride() { … }
}
static base::LazyInstance<BrowserContextKeyedAPIFactory<SerialPortManager>>::
DestructorAtExit g_factory = …;
BrowserContextKeyedAPIFactory<SerialPortManager>*
SerialPortManager::GetFactoryInstance() { … }
SerialPortManager* SerialPortManager::Get(content::BrowserContext* context) { … }
SerialPortManager::SerialPortManager(content::BrowserContext* context)
: … { … }
SerialPortManager::~SerialPortManager() = default;
SerialPortManager::ReceiveParams::ReceiveParams() = default;
SerialPortManager::ReceiveParams::ReceiveParams(const ReceiveParams& other) =
default;
SerialPortManager::ReceiveParams::~ReceiveParams() = default;
void SerialPortManager::GetDevices(
device::mojom::SerialPortManager::GetDevicesCallback callback) { … }
void SerialPortManager::OpenPort(
const std::string& path,
device::mojom::SerialConnectionOptionsPtr options,
mojo::PendingRemote<device::mojom::SerialPortClient> client,
OpenPortCallback callback) { … }
void SerialPortManager::StartConnectionPolling(const ExtensionId& extension_id,
int connection_id) { … }
void SerialPortManager::OverrideBinderForTesting(Binder binder) { … }
void SerialPortManager::DispatchReceiveEvent(const ReceiveParams& params,
std::vector<uint8_t> data,
serial::ReceiveError error) { … }
void SerialPortManager::DispatchEvent(
const ReceiveParams& params,
std::unique_ptr<extensions::Event> event) { … }
void SerialPortManager::EnsureConnection() { … }
void SerialPortManager::OnGotDevicesToGetPort(
const std::string& path,
device::mojom::SerialConnectionOptionsPtr options,
mojo::PendingRemote<device::mojom::SerialPortClient> client,
OpenPortCallback callback,
std::vector<device::mojom::SerialPortInfoPtr> devices) { … }
void SerialPortManager::OnPortManagerConnectionError() { … }
}
}