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

Side by Side Diff: chromeos/components/tether/ble_scanner.h

Issue 2951303002: [CrOS Tether] Move LocalDeviceDataProvider from //chromeos/components/tether to //components/crypta… (Closed)
Patch Set: Rebased. Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_COMPONENTS_BLE_SCANNER_H_ 5 #ifndef CHROMEOS_COMPONENTS_BLE_SCANNER_H_
6 #define CHROMEOS_COMPONENTS_BLE_SCANNER_H_ 6 #define CHROMEOS_COMPONENTS_BLE_SCANNER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "chromeos/components/tether/local_device_data_provider.h"
14 #include "components/cryptauth/foreground_eid_generator.h" 13 #include "components/cryptauth/foreground_eid_generator.h"
14 #include "components/cryptauth/local_device_data_provider.h"
15 #include "device/bluetooth/bluetooth_adapter.h" 15 #include "device/bluetooth/bluetooth_adapter.h"
16 #include "device/bluetooth/bluetooth_adapter_factory.h" 16 #include "device/bluetooth/bluetooth_adapter_factory.h"
17 17
18 namespace device { 18 namespace device {
19 class BluetoothDevice; 19 class BluetoothDevice;
20 class BluetoothDiscoverySession; 20 class BluetoothDiscoverySession;
21 } 21 }
22 22
23 namespace chromeos { 23 namespace chromeos {
24 24
25 namespace tether { 25 namespace tether {
26 26
27 class BleScanner : public device::BluetoothAdapter::Observer { 27 class BleScanner : public device::BluetoothAdapter::Observer {
28 public: 28 public:
29 class Observer { 29 class Observer {
30 public: 30 public:
31 virtual void OnReceivedAdvertisementFromDevice( 31 virtual void OnReceivedAdvertisementFromDevice(
32 const std::string& device_address, 32 const std::string& device_address,
33 cryptauth::RemoteDevice remote_device) = 0; 33 cryptauth::RemoteDevice remote_device) = 0;
34 }; 34 };
35 35
36 BleScanner(scoped_refptr<device::BluetoothAdapter> adapter, 36 BleScanner(
37 const LocalDeviceDataProvider* local_device_data_provider); 37 scoped_refptr<device::BluetoothAdapter> adapter,
38 const cryptauth::LocalDeviceDataProvider* local_device_data_provider);
38 ~BleScanner() override; 39 ~BleScanner() override;
39 40
40 virtual bool RegisterScanFilterForDevice( 41 virtual bool RegisterScanFilterForDevice(
41 const cryptauth::RemoteDevice& remote_device); 42 const cryptauth::RemoteDevice& remote_device);
42 virtual bool UnregisterScanFilterForDevice( 43 virtual bool UnregisterScanFilterForDevice(
43 const cryptauth::RemoteDevice& remote_device); 44 const cryptauth::RemoteDevice& remote_device);
44 45
45 bool IsDeviceRegistered(const std::string& device_id); 46 bool IsDeviceRegistered(const std::string& device_id);
46 47
47 void AddObserver(Observer* observer); 48 void AddObserver(Observer* observer);
(...skipping 21 matching lines...) Expand all
69 }; 70 };
70 71
71 class ServiceDataProviderImpl : public ServiceDataProvider { 72 class ServiceDataProviderImpl : public ServiceDataProvider {
72 public: 73 public:
73 ServiceDataProviderImpl(); 74 ServiceDataProviderImpl();
74 ~ServiceDataProviderImpl() override; 75 ~ServiceDataProviderImpl() override;
75 const std::vector<uint8_t>* GetServiceDataForUUID( 76 const std::vector<uint8_t>* GetServiceDataForUUID(
76 device::BluetoothDevice* bluetooth_device) override; 77 device::BluetoothDevice* bluetooth_device) override;
77 }; 78 };
78 79
79 BleScanner(std::unique_ptr<ServiceDataProvider> service_data_provider, 80 BleScanner(
80 scoped_refptr<device::BluetoothAdapter> adapter, 81 std::unique_ptr<ServiceDataProvider> service_data_provider,
81 std::unique_ptr<cryptauth::ForegroundEidGenerator> eid_generator, 82 scoped_refptr<device::BluetoothAdapter> adapter,
82 const LocalDeviceDataProvider* local_device_data_provider); 83 std::unique_ptr<cryptauth::ForegroundEidGenerator> eid_generator,
84 const cryptauth::LocalDeviceDataProvider* local_device_data_provider);
83 85
84 void UpdateDiscoveryStatus(); 86 void UpdateDiscoveryStatus();
85 void StartDiscoverySession(); 87 void StartDiscoverySession();
86 void OnDiscoverySessionStarted( 88 void OnDiscoverySessionStarted(
87 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session); 89 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session);
88 void OnStartDiscoverySessionError(); 90 void OnStartDiscoverySessionError();
89 void StopDiscoverySession(); 91 void StopDiscoverySession();
90 void HandleDeviceUpdated(device::BluetoothDevice* bluetooth_device); 92 void HandleDeviceUpdated(device::BluetoothDevice* bluetooth_device);
91 void CheckForMatchingScanFilters(device::BluetoothDevice* bluetooth_device, 93 void CheckForMatchingScanFilters(device::BluetoothDevice* bluetooth_device,
92 std::string& service_data); 94 std::string& service_data);
93 95
94 std::unique_ptr<ServiceDataProvider> service_data_provider_; 96 std::unique_ptr<ServiceDataProvider> service_data_provider_;
95 97
96 scoped_refptr<device::BluetoothAdapter> adapter_; 98 scoped_refptr<device::BluetoothAdapter> adapter_;
97 99
98 std::unique_ptr<cryptauth::ForegroundEidGenerator> eid_generator_; 100 std::unique_ptr<cryptauth::ForegroundEidGenerator> eid_generator_;
99 // |local_device_data_provider_| is not owned by this instance and must 101 // |local_device_data_provider_| is not owned by this instance and must
100 // outlive it. 102 // outlive it.
101 const LocalDeviceDataProvider* local_device_data_provider_; 103 const cryptauth::LocalDeviceDataProvider* local_device_data_provider_;
102 104
103 bool is_initializing_discovery_session_; 105 bool is_initializing_discovery_session_;
104 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; 106 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_;
105 107
106 std::vector<cryptauth::RemoteDevice> registered_remote_devices_; 108 std::vector<cryptauth::RemoteDevice> registered_remote_devices_;
107 109
108 base::WeakPtrFactory<BleScanner> weak_ptr_factory_; 110 base::WeakPtrFactory<BleScanner> weak_ptr_factory_;
109 111
110 DISALLOW_COPY_AND_ASSIGN(BleScanner); 112 DISALLOW_COPY_AND_ASSIGN(BleScanner);
111 }; 113 };
112 114
113 } // namespace tether 115 } // namespace tether
114 116
115 } // namespace chromeos 117 } // namespace chromeos
116 118
117 #endif // CHROMEOS_COMPONENTS_BLE_SCANNER_H_ 119 #endif // CHROMEOS_COMPONENTS_BLE_SCANNER_H_
OLDNEW
« no previous file with comments | « chromeos/components/tether/ble_connection_manager.cc ('k') | chromeos/components/tether/ble_scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698