OLD | NEW |
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 COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ | 5 #ifndef COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ |
6 #define COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ | 6 #define COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 explicit ArcBluetoothBridge(ArcBridgeService* bridge_service); | 45 explicit ArcBluetoothBridge(ArcBridgeService* bridge_service); |
46 ~ArcBluetoothBridge() override; | 46 ~ArcBluetoothBridge() override; |
47 | 47 |
48 // Overridden from InstanceHolder<mojom::BluetoothInstance>::Observer: | 48 // Overridden from InstanceHolder<mojom::BluetoothInstance>::Observer: |
49 void OnInstanceReady() override; | 49 void OnInstanceReady() override; |
50 void OnInstanceClosed() override; | 50 void OnInstanceClosed() override; |
51 | 51 |
52 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); | 52 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); |
53 | 53 |
54 // Overridden from device::BluetoothAdadpter::Observer | 54 // Overridden from device::BluetoothAdadpter::Observer |
55 void AdapterPoweredChanged(device::BluetoothAdapter* adapter, | |
56 bool powered) override; | |
57 | |
58 void DeviceAdded(device::BluetoothAdapter* adapter, | 55 void DeviceAdded(device::BluetoothAdapter* adapter, |
59 device::BluetoothDevice* device) override; | 56 device::BluetoothDevice* device) override; |
60 | 57 |
61 void DeviceChanged(device::BluetoothAdapter* adapter, | 58 void DeviceChanged(device::BluetoothAdapter* adapter, |
62 device::BluetoothDevice* device) override; | 59 device::BluetoothDevice* device) override; |
63 | 60 |
64 void DeviceAddressChanged(device::BluetoothAdapter* adapter, | 61 void DeviceAddressChanged(device::BluetoothAdapter* adapter, |
65 device::BluetoothDevice* device, | 62 device::BluetoothDevice* device, |
66 const std::string& old_address) override; | 63 const std::string& old_address) override; |
67 | 64 |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 // Monotonically increasing value to use as handle to give to Android side. | 396 // Monotonically increasing value to use as handle to give to Android side. |
400 int32_t gatt_server_attribute_next_handle_ = 0; | 397 int32_t gatt_server_attribute_next_handle_ = 0; |
401 // Keeps track of all devices which initiated a GATT connection to us. | 398 // Keeps track of all devices which initiated a GATT connection to us. |
402 std::unordered_set<std::string> gatt_connection_cache_; | 399 std::unordered_set<std::string> gatt_connection_cache_; |
403 // Map of device address to GATT connection objects for connections we | 400 // Map of device address to GATT connection objects for connections we |
404 // have made. We need to hang on to these as long as the connection is | 401 // have made. We need to hang on to these as long as the connection is |
405 // active since their destructors will drop the connections otherwise. | 402 // active since their destructors will drop the connections otherwise. |
406 std::unordered_map<std::string, | 403 std::unordered_map<std::string, |
407 std::unique_ptr<device::BluetoothGattConnection>> | 404 std::unique_ptr<device::BluetoothGattConnection>> |
408 gatt_connections_; | 405 gatt_connections_; |
| 406 // Timer to turn discovery off. |
| 407 base::OneShotTimer discovery_off_timer_; |
409 // Timer to turn adapter discoverable off. | 408 // Timer to turn adapter discoverable off. |
410 base::OneShotTimer discoverable_off_timer_; | 409 base::OneShotTimer discoverable_off_timer_; |
411 | 410 |
412 base::ThreadChecker thread_checker_; | 411 base::ThreadChecker thread_checker_; |
413 | 412 |
414 // WeakPtrFactory to use for callbacks. | 413 // WeakPtrFactory to use for callbacks. |
415 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; | 414 base::WeakPtrFactory<ArcBluetoothBridge> weak_factory_; |
416 | 415 |
417 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); | 416 DISALLOW_COPY_AND_ASSIGN(ArcBluetoothBridge); |
418 }; | 417 }; |
419 | 418 |
420 } // namespace arc | 419 } // namespace arc |
421 | 420 |
422 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ | 421 #endif // COMPONENTS_ARC_BLUETOOTH_ARC_BLUETOOTH_BRIDGE_H_ |
OLD | NEW |