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 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_win.h" | 5 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_win.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "device/bluetooth/bluetooth_adapter_win.h" | 8 #include "device/bluetooth/bluetooth_adapter_win.h" |
9 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_win.h" | 9 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_win.h" |
10 #include "device/bluetooth/bluetooth_remote_gatt_service_win.h" | 10 #include "device/bluetooth/bluetooth_remote_gatt_service_win.h" |
11 | 11 |
12 namespace device { | 12 namespace device { |
13 | 13 |
14 BluetoothRemoteGattDescriptorWin::BluetoothRemoteGattDescriptorWin( | 14 BluetoothRemoteGattDescriptorWin::BluetoothRemoteGattDescriptorWin( |
15 BluetoothRemoteGattCharacteristicWin* parent_characteristic, | 15 BluetoothRemoteGattCharacteristicWin* parent_characteristic, |
16 BTH_LE_GATT_DESCRIPTOR* descriptor_info, | 16 BTH_LE_GATT_DESCRIPTOR* descriptor_info, |
17 scoped_refptr<base::SequencedTaskRunner>& ui_task_runner) | 17 scoped_refptr<base::SequencedTaskRunner>& ui_task_runner) |
18 : parent_characteristic_(parent_characteristic), | 18 : parent_characteristic_(parent_characteristic), |
19 descriptor_info_(descriptor_info), | 19 descriptor_info_(descriptor_info), |
20 ui_task_runner_(ui_task_runner), | 20 ui_task_runner_(ui_task_runner), |
21 weak_ptr_factory_(this) { | 21 weak_ptr_factory_(this) { |
22 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 22 DCHECK(ui_task_runner_->RunsTasksInCurrentSequence()); |
23 DCHECK(parent_characteristic_); | 23 DCHECK(parent_characteristic_); |
24 DCHECK(descriptor_info_.get()); | 24 DCHECK(descriptor_info_.get()); |
25 | 25 |
26 task_manager_ = parent_characteristic_->GetWinService() | 26 task_manager_ = parent_characteristic_->GetWinService() |
27 ->GetWinAdapter() | 27 ->GetWinAdapter() |
28 ->GetWinBluetoothTaskManager(); | 28 ->GetWinBluetoothTaskManager(); |
29 DCHECK(task_manager_); | 29 DCHECK(task_manager_); |
30 service_path_ = parent_characteristic_->GetWinService()->GetServicePath(); | 30 service_path_ = parent_characteristic_->GetWinService()->GetServicePath(); |
31 DCHECK(!service_path_.empty()); | 31 DCHECK(!service_path_.empty()); |
32 descriptor_uuid_ = | 32 descriptor_uuid_ = |
33 BluetoothTaskManagerWin::BluetoothLowEnergyUuidToBluetoothUuid( | 33 BluetoothTaskManagerWin::BluetoothLowEnergyUuidToBluetoothUuid( |
34 descriptor_info_.get()->DescriptorUuid); | 34 descriptor_info_.get()->DescriptorUuid); |
35 DCHECK(descriptor_uuid_.IsValid()); | 35 DCHECK(descriptor_uuid_.IsValid()); |
36 descriptor_identifier_ = parent_characteristic_->GetIdentifier() + "_" + | 36 descriptor_identifier_ = parent_characteristic_->GetIdentifier() + "_" + |
37 std::to_string(descriptor_info_->AttributeHandle); | 37 std::to_string(descriptor_info_->AttributeHandle); |
38 } | 38 } |
39 | 39 |
40 BluetoothRemoteGattDescriptorWin::~BluetoothRemoteGattDescriptorWin() { | 40 BluetoothRemoteGattDescriptorWin::~BluetoothRemoteGattDescriptorWin() { |
41 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 41 DCHECK(ui_task_runner_->RunsTasksInCurrentSequence()); |
42 | 42 |
43 parent_characteristic_->GetWinService() | 43 parent_characteristic_->GetWinService() |
44 ->GetWinAdapter() | 44 ->GetWinAdapter() |
45 ->NotifyGattDescriptorRemoved(this); | 45 ->NotifyGattDescriptorRemoved(this); |
46 } | 46 } |
47 | 47 |
48 std::string BluetoothRemoteGattDescriptorWin::GetIdentifier() const { | 48 std::string BluetoothRemoteGattDescriptorWin::GetIdentifier() const { |
49 return descriptor_identifier_; | 49 return descriptor_identifier_; |
50 } | 50 } |
51 | 51 |
(...skipping 13 matching lines...) Expand all Loading... |
65 | 65 |
66 BluetoothRemoteGattCharacteristic::Permissions | 66 BluetoothRemoteGattCharacteristic::Permissions |
67 BluetoothRemoteGattDescriptorWin::GetPermissions() const { | 67 BluetoothRemoteGattDescriptorWin::GetPermissions() const { |
68 NOTIMPLEMENTED(); | 68 NOTIMPLEMENTED(); |
69 return descriptor_permissions_; | 69 return descriptor_permissions_; |
70 } | 70 } |
71 | 71 |
72 void BluetoothRemoteGattDescriptorWin::ReadRemoteDescriptor( | 72 void BluetoothRemoteGattDescriptorWin::ReadRemoteDescriptor( |
73 const ValueCallback& callback, | 73 const ValueCallback& callback, |
74 const ErrorCallback& error_callback) { | 74 const ErrorCallback& error_callback) { |
75 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 75 DCHECK(ui_task_runner_->RunsTasksInCurrentSequence()); |
76 | 76 |
77 NOTIMPLEMENTED(); | 77 NOTIMPLEMENTED(); |
78 error_callback.Run(BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED); | 78 error_callback.Run(BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED); |
79 } | 79 } |
80 | 80 |
81 void BluetoothRemoteGattDescriptorWin::WriteRemoteDescriptor( | 81 void BluetoothRemoteGattDescriptorWin::WriteRemoteDescriptor( |
82 const std::vector<uint8_t>& new_value, | 82 const std::vector<uint8_t>& new_value, |
83 const base::Closure& callback, | 83 const base::Closure& callback, |
84 const ErrorCallback& error_callback) { | 84 const ErrorCallback& error_callback) { |
85 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 85 DCHECK(ui_task_runner_->RunsTasksInCurrentSequence()); |
86 | 86 |
87 NOTIMPLEMENTED(); | 87 NOTIMPLEMENTED(); |
88 error_callback.Run(BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED); | 88 error_callback.Run(BluetoothRemoteGattService::GATT_ERROR_NOT_SUPPORTED); |
89 } | 89 } |
90 | 90 |
91 uint16_t BluetoothRemoteGattDescriptorWin::GetAttributeHandle() const { | 91 uint16_t BluetoothRemoteGattDescriptorWin::GetAttributeHandle() const { |
92 return descriptor_info_->AttributeHandle; | 92 return descriptor_info_->AttributeHandle; |
93 } | 93 } |
94 | 94 |
95 } // namespace device. | 95 } // namespace device. |
OLD | NEW |