Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2879)

Unified Diff: chromeos/components/tether/ble_scanner.h

Issue 2803153002: [CrOS Tether] Refactor BleScanner so that it takes a BluetoothAdapter in its constructor instead of… (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromeos/components/tether/ble_scanner.h
diff --git a/chromeos/components/tether/ble_scanner.h b/chromeos/components/tether/ble_scanner.h
index a2771af8f552a9e999e306c82d31d2c22b879764..3faffc017ab9189d8bcfb575214a647668dbe4e8 100644
--- a/chromeos/components/tether/ble_scanner.h
+++ b/chromeos/components/tether/ble_scanner.h
@@ -33,7 +33,8 @@ class BleScanner : public device::BluetoothAdapter::Observer {
cryptauth::RemoteDevice remote_device) = 0;
};
- BleScanner(const LocalDeviceDataProvider* local_device_data_provider);
+ BleScanner(scoped_refptr<device::BluetoothAdapter> adapter,
+ const LocalDeviceDataProvider* local_device_data_provider);
~BleScanner() override;
virtual bool RegisterScanFilterForDevice(
@@ -60,30 +61,23 @@ class BleScanner : public device::BluetoothAdapter::Observer {
private:
friend class BleScannerTest;
- class Delegate {
+ class ServiceDataProvider {
public:
- virtual ~Delegate() {}
- virtual bool IsBluetoothAdapterAvailable() const = 0;
- virtual void GetAdapter(
- const device::BluetoothAdapterFactory::AdapterCallback& callback) = 0;
+ virtual ~ServiceDataProvider() {}
virtual const std::vector<uint8_t>* GetServiceDataForUUID(
- const device::BluetoothUUID& service_uuid,
device::BluetoothDevice* bluetooth_device) = 0;
};
- class DelegateImpl : public Delegate {
+ class ServiceDataProviderImpl : public ServiceDataProvider {
public:
- DelegateImpl();
- ~DelegateImpl() override;
- bool IsBluetoothAdapterAvailable() const override;
- void GetAdapter(const device::BluetoothAdapterFactory::AdapterCallback&
- callback) override;
+ ServiceDataProviderImpl();
+ ~ServiceDataProviderImpl() override;
const std::vector<uint8_t>* GetServiceDataForUUID(
- const device::BluetoothUUID& service_uuid,
device::BluetoothDevice* bluetooth_device) override;
};
- BleScanner(std::unique_ptr<Delegate> delegate,
+ BleScanner(std::unique_ptr<ServiceDataProvider> service_data_provider,
+ scoped_refptr<device::BluetoothAdapter> adapter,
const cryptauth::EidGenerator* eid_generator,
const LocalDeviceDataProvider* local_device_data_provider);
@@ -99,16 +93,15 @@ class BleScanner : public device::BluetoothAdapter::Observer {
void CheckForMatchingScanFilters(device::BluetoothDevice* bluetooth_device,
std::string& service_data);
- std::unique_ptr<Delegate> delegate_;
+ std::unique_ptr<ServiceDataProvider> service_data_provider_;
+
+ scoped_refptr<device::BluetoothAdapter> adapter_;
// |eid_generator_| and |local_device_data_provider_| are not owned by this
// instance and must outlive it.
const cryptauth::EidGenerator* eid_generator_;
const LocalDeviceDataProvider* local_device_data_provider_;
- bool is_initializing_adapter_;
- scoped_refptr<device::BluetoothAdapter> adapter_;
-
bool is_initializing_discovery_session_;
std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_;
« no previous file with comments | « chromeos/components/tether/ble_connection_manager_unittest.cc ('k') | chromeos/components/tether/ble_scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698