| 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_TASK_MANAGER_WIN_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "base/win/scoped_handle.h" | 15 #include "base/win/scoped_handle.h" |
| 16 #include "device/bluetooth/bluetooth_adapter.h" | 16 #include "device/bluetooth/bluetooth_adapter.h" |
| 17 #include "device/bluetooth/bluetooth_export.h" | |
| 18 | 17 |
| 19 namespace base { | 18 namespace base { |
| 20 | 19 |
| 21 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
| 22 class SequencedWorkerPool; | 21 class SequencedWorkerPool; |
| 23 | 22 |
| 24 } // namespace base | 23 } // namespace base |
| 25 | 24 |
| 26 namespace device { | 25 namespace device { |
| 27 | 26 |
| 28 // Manages the blocking Bluetooth tasks using |SequencedWorkerPool|. It runs | 27 // Manages the blocking Bluetooth tasks using |SequencedWorkerPool|. It runs |
| 29 // bluetooth tasks using |SequencedWorkerPool| and informs its observers of | 28 // bluetooth tasks using |SequencedWorkerPool| and informs its observers of |
| 30 // bluetooth adapter state changes and any other bluetooth device inquiry | 29 // bluetooth adapter state changes and any other bluetooth device inquiry |
| 31 // result. | 30 // result. |
| 32 // | 31 // |
| 33 // It delegates the blocking Windows API calls to |bluetooth_task_runner_|'s | 32 // It delegates the blocking Windows API calls to |bluetooth_task_runner_|'s |
| 34 // message loop, and receives responses via methods like OnAdapterStateChanged | 33 // message loop, and receives responses via methods like OnAdapterStateChanged |
| 35 // posted to UI thread. | 34 // posted to UI thread. |
| 36 class DEVICE_BLUETOOTH_EXPORT BluetoothTaskManagerWin | 35 class BluetoothTaskManagerWin |
| 37 : public base::RefCountedThreadSafe<BluetoothTaskManagerWin> { | 36 : public base::RefCountedThreadSafe<BluetoothTaskManagerWin> { |
| 38 public: | 37 public: |
| 39 struct DEVICE_BLUETOOTH_EXPORT AdapterState { | 38 struct AdapterState { |
| 40 AdapterState(); | 39 AdapterState(); |
| 41 ~AdapterState(); | 40 ~AdapterState(); |
| 42 std::string name; | 41 std::string name; |
| 43 std::string address; | 42 std::string address; |
| 44 bool powered; | 43 bool powered; |
| 45 }; | 44 }; |
| 46 | 45 |
| 47 struct DEVICE_BLUETOOTH_EXPORT ServiceRecordState { | 46 struct ServiceRecordState { |
| 48 ServiceRecordState(); | 47 ServiceRecordState(); |
| 49 ~ServiceRecordState(); | 48 ~ServiceRecordState(); |
| 50 // Properties common to Bluetooth Classic and LE devices. | 49 // Properties common to Bluetooth Classic and LE devices. |
| 51 std::string name; | 50 std::string name; |
| 52 // Properties specific to Bluetooth Classic devices. | 51 // Properties specific to Bluetooth Classic devices. |
| 53 std::vector<uint8> sdp_bytes; | 52 std::vector<uint8> sdp_bytes; |
| 54 // Properties specific to Bluetooth LE devices. | 53 // Properties specific to Bluetooth LE devices. |
| 55 BluetoothUUID gatt_uuid; | 54 BluetoothUUID gatt_uuid; |
| 56 }; | 55 }; |
| 57 | 56 |
| 58 struct DEVICE_BLUETOOTH_EXPORT DeviceState { | 57 struct DeviceState { |
| 59 DeviceState(); | 58 DeviceState(); |
| 60 ~DeviceState(); | 59 ~DeviceState(); |
| 61 | 60 |
| 62 bool is_bluetooth_classic() const { return path.empty(); } | 61 bool is_bluetooth_classic() const { return path.empty(); } |
| 63 | 62 |
| 64 // Properties common to Bluetooth Classic and LE devices. | 63 // Properties common to Bluetooth Classic and LE devices. |
| 65 std::string address; // This uniquely identifies the device. | 64 std::string address; // This uniquely identifies the device. |
| 66 std::string name; // Friendly name | 65 std::string name; // Friendly name |
| 67 bool visible; | 66 bool visible; |
| 68 bool connected; | 67 bool connected; |
| 69 bool authenticated; | 68 bool authenticated; |
| 70 ScopedVector<ServiceRecordState> service_record_states; | 69 ScopedVector<ServiceRecordState> service_record_states; |
| 71 // Properties specific to Bluetooth Classic devices. | 70 // Properties specific to Bluetooth Classic devices. |
| 72 uint32 bluetooth_class; | 71 uint32 bluetooth_class; |
| 73 // Properties specific to Bluetooth LE devices. | 72 // Properties specific to Bluetooth LE devices. |
| 74 base::FilePath path; | 73 base::FilePath path; |
| 75 }; | 74 }; |
| 76 | 75 |
| 77 class DEVICE_BLUETOOTH_EXPORT Observer { | 76 class Observer { |
| 78 public: | 77 public: |
| 79 virtual ~Observer() {} | 78 virtual ~Observer() {} |
| 80 | 79 |
| 81 virtual void AdapterStateChanged(const AdapterState& state) {} | 80 virtual void AdapterStateChanged(const AdapterState& state) {} |
| 82 virtual void DiscoveryStarted(bool success) {} | 81 virtual void DiscoveryStarted(bool success) {} |
| 83 virtual void DiscoveryStopped() {} | 82 virtual void DiscoveryStopped() {} |
| 84 // Called when the adapter has just been polled for the list of *all* known | 83 // Called when the adapter has just been polled for the list of *all* known |
| 85 // devices. This includes devices previously paired, devices paired using | 84 // devices. This includes devices previously paired, devices paired using |
| 86 // the underlying Operating System UI, and devices discovered recently due | 85 // the underlying Operating System UI, and devices discovered recently due |
| 87 // to an active discovery session. Note that for a given device (address), | 86 // to an active discovery session. Note that for a given device (address), |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 // Use for discarding too many log messages. | 210 // Use for discarding too many log messages. |
| 212 base::TimeTicks current_logging_batch_ticks_; | 211 base::TimeTicks current_logging_batch_ticks_; |
| 213 int current_logging_batch_count_; | 212 int current_logging_batch_count_; |
| 214 | 213 |
| 215 DISALLOW_COPY_AND_ASSIGN(BluetoothTaskManagerWin); | 214 DISALLOW_COPY_AND_ASSIGN(BluetoothTaskManagerWin); |
| 216 }; | 215 }; |
| 217 | 216 |
| 218 } // namespace device | 217 } // namespace device |
| 219 | 218 |
| 220 #endif // DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_ | 219 #endif // DEVICE_BLUETOOTH_BLUETOOTH_TASK_MANAGER_WIN_H_ |
| OLD | NEW |