OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <list> | 10 #include <list> |
11 #include <memory> | 11 #include <memory> |
12 #include <set> | 12 #include <set> |
13 #include <string> | 13 #include <string> |
14 #include <unordered_map> | 14 #include <unordered_map> |
15 #include <utility> | 15 #include <utility> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "base/callback.h" | 18 #include "base/callback.h" |
19 #include "base/containers/scoped_ptr_hash_map.h" | |
20 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
21 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
22 #include "base/time/time.h" | 21 #include "base/time/time.h" |
23 #include "build/build_config.h" | 22 #include "build/build_config.h" |
24 #include "device/bluetooth/bluetooth_advertisement.h" | 23 #include "device/bluetooth/bluetooth_advertisement.h" |
25 #include "device/bluetooth/bluetooth_device.h" | 24 #include "device/bluetooth/bluetooth_device.h" |
26 #include "device/bluetooth/bluetooth_export.h" | 25 #include "device/bluetooth/bluetooth_export.h" |
27 | 26 |
28 namespace device { | 27 namespace device { |
29 | 28 |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 const std::vector<uint8_t>& value); | 493 const std::vector<uint8_t>& value); |
495 | 494 |
496 // The timeout in seconds used by RemoveTimedOutDevices. | 495 // The timeout in seconds used by RemoveTimedOutDevices. |
497 static const base::TimeDelta timeoutSec; | 496 static const base::TimeDelta timeoutSec; |
498 | 497 |
499 protected: | 498 protected: |
500 friend class base::RefCounted<BluetoothAdapter>; | 499 friend class base::RefCounted<BluetoothAdapter>; |
501 friend class BluetoothDiscoverySession; | 500 friend class BluetoothDiscoverySession; |
502 friend class BluetoothTestBase; | 501 friend class BluetoothTestBase; |
503 | 502 |
504 typedef base::ScopedPtrHashMap<std::string, std::unique_ptr<BluetoothDevice>> | 503 using DevicesMap = |
505 DevicesMap; | 504 std::unordered_map<std::string, std::unique_ptr<BluetoothDevice>>; |
506 typedef std::pair<BluetoothDevice::PairingDelegate*, PairingDelegatePriority> | 505 using PairingDelegatePair = |
507 PairingDelegatePair; | 506 std::pair<BluetoothDevice::PairingDelegate*, PairingDelegatePriority>; |
508 typedef base::Callback<void(UMABluetoothDiscoverySessionOutcome)> | 507 using DiscoverySessionErrorCallback = |
509 DiscoverySessionErrorCallback; | 508 base::Callback<void(UMABluetoothDiscoverySessionOutcome)>; |
510 | 509 |
511 BluetoothAdapter(); | 510 BluetoothAdapter(); |
512 virtual ~BluetoothAdapter(); | 511 virtual ~BluetoothAdapter(); |
513 | 512 |
514 // Internal methods for initiating and terminating device discovery sessions. | 513 // Internal methods for initiating and terminating device discovery sessions. |
515 // An implementation of BluetoothAdapter keeps an internal reference count to | 514 // An implementation of BluetoothAdapter keeps an internal reference count to |
516 // make sure that the underlying controller is constantly searching for nearby | 515 // make sure that the underlying controller is constantly searching for nearby |
517 // devices and retrieving information from them as long as there are clients | 516 // devices and retrieving information from them as long as there are clients |
518 // who have requested discovery. These methods behave in the following way: | 517 // who have requested discovery. These methods behave in the following way: |
519 // | 518 // |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 std::set<BluetoothDiscoverySession*> discovery_sessions_; | 632 std::set<BluetoothDiscoverySession*> discovery_sessions_; |
634 | 633 |
635 // Note: This should remain the last member so it'll be destroyed and | 634 // Note: This should remain the last member so it'll be destroyed and |
636 // invalidate its weak pointers before any other members are destroyed. | 635 // invalidate its weak pointers before any other members are destroyed. |
637 base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_; | 636 base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_; |
638 }; | 637 }; |
639 | 638 |
640 } // namespace device | 639 } // namespace device |
641 | 640 |
642 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ | 641 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ |
OLD | NEW |