Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_win.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "device/bluetooth/bluetooth_adapter_win.h" | |
| 9 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_win.h" | |
| 10 #include "device/bluetooth/bluetooth_remote_gatt_service_win.h" | |
| 11 | |
| 12 namespace device { | |
| 13 | |
| 14 BluetoothRemoteGattDescriptorWin::BluetoothRemoteGattDescriptorWin( | |
| 15 BluetoothRemoteGattCharacteristicWin* parent_characteristic, | |
| 16 BTH_LE_GATT_DESCRIPTOR* descriptor_info, | |
| 17 scoped_refptr<base::SequencedTaskRunner>& ui_task_runner) | |
| 18 : parent_characteristic_(parent_characteristic), | |
| 19 descriptor_info_(descriptor_info), | |
| 20 ui_task_runner_(ui_task_runner), | |
| 21 weak_ptr_factory_(this) { | |
| 22 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | |
| 23 DCHECK(parent_characteristic_); | |
| 24 DCHECK(descriptor_info_.get()); | |
| 25 | |
| 26 adapter_ = static_cast<BluetoothAdapterWin*>( | |
| 27 parent_characteristic->GetService()->GetDevice()->GetAdapter()); | |
| 28 DCHECK(adapter_); | |
| 29 task_manager_ = adapter_->GetWinBluetoothTaskManager(); | |
| 30 DCHECK(task_manager_); | |
| 31 service_path_ = static_cast<BluetoothRemoteGattServiceWin*>( | |
|
scheib
2016/03/01 00:06:22
Static casts are always a red flag and should be m
gogerald1
2016/03/01 17:00:13
Done.
| |
| 32 parent_characteristic->GetService()) | |
| 33 ->GetServicePath(); | |
| 34 DCHECK(!service_path_.empty()); | |
| 35 descriptor_uuid_ = | |
| 36 BluetoothTaskManagerWin::BluetoothLowEnergyUuidToBluetoothUuid( | |
| 37 descriptor_info_.get()->DescriptorUuid); | |
| 38 DCHECK(descriptor_uuid_.IsValid()); | |
| 39 descriptor_identifier_ = parent_characteristic_->GetIdentifier() + "_" + | |
| 40 std::to_string(descriptor_info_->AttributeHandle); | |
| 41 } | |
| 42 | |
| 43 BluetoothRemoteGattDescriptorWin::~BluetoothRemoteGattDescriptorWin() { | |
| 44 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | |
| 45 adapter_->NotifyGattDescriptorRemoved(this); | |
| 46 } | |
| 47 | |
| 48 std::string BluetoothRemoteGattDescriptorWin::GetIdentifier() const { | |
| 49 return descriptor_identifier_; | |
| 50 } | |
| 51 | |
| 52 BluetoothUUID BluetoothRemoteGattDescriptorWin::GetUUID() const { | |
| 53 return descriptor_uuid_; | |
| 54 } | |
| 55 | |
| 56 bool BluetoothRemoteGattDescriptorWin::IsLocal() const { | |
| 57 return false; | |
| 58 } | |
| 59 | |
| 60 std::vector<uint8_t>& BluetoothRemoteGattDescriptorWin::GetValue() const { | |
| 61 NOTIMPLEMENTED(); | |
| 62 return const_cast<std::vector<uint8_t>&>(descriptor_value_); | |
| 63 } | |
| 64 | |
| 65 BluetoothGattCharacteristic* | |
| 66 BluetoothRemoteGattDescriptorWin::GetCharacteristic() const { | |
| 67 return parent_characteristic_; | |
| 68 } | |
| 69 | |
| 70 BluetoothGattCharacteristic::Permissions | |
| 71 BluetoothRemoteGattDescriptorWin::GetPermissions() const { | |
| 72 NOTIMPLEMENTED(); | |
| 73 return descriptor_permissions_; | |
| 74 } | |
| 75 | |
| 76 void BluetoothRemoteGattDescriptorWin::ReadRemoteDescriptor( | |
| 77 const ValueCallback& callback, | |
| 78 const ErrorCallback& error_callback) { | |
| 79 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | |
| 80 | |
| 81 NOTIMPLEMENTED(); | |
| 82 error_callback.Run(BluetoothGattService::GATT_ERROR_NOT_SUPPORTED); | |
| 83 } | |
| 84 | |
| 85 void BluetoothRemoteGattDescriptorWin::WriteRemoteDescriptor( | |
| 86 const std::vector<uint8_t>& new_value, | |
| 87 const base::Closure& callback, | |
| 88 const ErrorCallback& error_callback) { | |
| 89 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | |
| 90 | |
| 91 NOTIMPLEMENTED(); | |
| 92 error_callback.Run(BluetoothGattService::GATT_ERROR_NOT_SUPPORTED); | |
| 93 } | |
| 94 | |
| 95 uint16_t BluetoothRemoteGattDescriptorWin::GetAttributeHandle() const { | |
| 96 return descriptor_info_->AttributeHandle; | |
| 97 } | |
| 98 | |
| 99 } // namespace device. | |
| OLD | NEW |