| 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_service_win.h" | 5 #include "device/bluetooth/bluetooth_remote_gatt_service_win.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 | 60 |
| 61 std::string BluetoothRemoteGattServiceWin::GetIdentifier() const { | 61 std::string BluetoothRemoteGattServiceWin::GetIdentifier() const { |
| 62 return service_identifier_; | 62 return service_identifier_; |
| 63 } | 63 } |
| 64 | 64 |
| 65 BluetoothUUID BluetoothRemoteGattServiceWin::GetUUID() const { | 65 BluetoothUUID BluetoothRemoteGattServiceWin::GetUUID() const { |
| 66 return const_cast<BluetoothUUID&>(service_uuid_); | 66 return const_cast<BluetoothUUID&>(service_uuid_); |
| 67 } | 67 } |
| 68 | 68 |
| 69 bool BluetoothRemoteGattServiceWin::IsLocal() const { | |
| 70 return false; | |
| 71 } | |
| 72 | |
| 73 bool BluetoothRemoteGattServiceWin::IsPrimary() const { | 69 bool BluetoothRemoteGattServiceWin::IsPrimary() const { |
| 74 return is_primary_; | 70 return is_primary_; |
| 75 } | 71 } |
| 76 | 72 |
| 77 BluetoothDevice* BluetoothRemoteGattServiceWin::GetDevice() const { | 73 BluetoothDevice* BluetoothRemoteGattServiceWin::GetDevice() const { |
| 78 return device_; | 74 return device_; |
| 79 } | 75 } |
| 80 | 76 |
| 81 std::vector<BluetoothGattCharacteristic*> | 77 std::vector<BluetoothRemoteGattCharacteristic*> |
| 82 BluetoothRemoteGattServiceWin::GetCharacteristics() const { | 78 BluetoothRemoteGattServiceWin::GetCharacteristics() const { |
| 83 std::vector<BluetoothGattCharacteristic*> has_characteristics; | 79 std::vector<BluetoothRemoteGattCharacteristic*> has_characteristics; |
| 84 for (const auto& c : included_characteristics_) | 80 for (const auto& c : included_characteristics_) |
| 85 has_characteristics.push_back(c.second.get()); | 81 has_characteristics.push_back(c.second.get()); |
| 86 return has_characteristics; | 82 return has_characteristics; |
| 87 } | 83 } |
| 88 | 84 |
| 89 std::vector<BluetoothGattService*> | 85 std::vector<BluetoothRemoteGattService*> |
| 90 BluetoothRemoteGattServiceWin::GetIncludedServices() const { | 86 BluetoothRemoteGattServiceWin::GetIncludedServices() const { |
| 91 NOTIMPLEMENTED(); | 87 NOTIMPLEMENTED(); |
| 92 // TODO(crbug.com/590008): Needs implementation. | 88 // TODO(crbug.com/590008): Needs implementation. |
| 93 return std::vector<BluetoothGattService*>(); | 89 return std::vector<BluetoothRemoteGattService*>(); |
| 94 } | 90 } |
| 95 | 91 |
| 96 BluetoothGattCharacteristic* BluetoothRemoteGattServiceWin::GetCharacteristic( | 92 BluetoothRemoteGattCharacteristic* |
| 93 BluetoothRemoteGattServiceWin::GetCharacteristic( |
| 97 const std::string& identifier) const { | 94 const std::string& identifier) const { |
| 98 GattCharacteristicsMap::const_iterator it = | 95 GattCharacteristicsMap::const_iterator it = |
| 99 included_characteristics_.find(identifier); | 96 included_characteristics_.find(identifier); |
| 100 if (it != included_characteristics_.end()) | 97 if (it != included_characteristics_.end()) |
| 101 return it->second.get(); | 98 return it->second.get(); |
| 102 return nullptr; | 99 return nullptr; |
| 103 } | 100 } |
| 104 | 101 |
| 105 bool BluetoothRemoteGattServiceWin::AddCharacteristic( | |
| 106 device::BluetoothGattCharacteristic* characteristic) { | |
| 107 NOTIMPLEMENTED(); | |
| 108 return false; | |
| 109 } | |
| 110 | |
| 111 bool BluetoothRemoteGattServiceWin::AddIncludedService( | |
| 112 device::BluetoothGattService* service) { | |
| 113 NOTIMPLEMENTED(); | |
| 114 return false; | |
| 115 } | |
| 116 | |
| 117 void BluetoothRemoteGattServiceWin::Register( | |
| 118 const base::Closure& callback, | |
| 119 const ErrorCallback& error_callback) { | |
| 120 NOTIMPLEMENTED(); | |
| 121 error_callback.Run(GATT_ERROR_NOT_SUPPORTED); | |
| 122 } | |
| 123 | |
| 124 void BluetoothRemoteGattServiceWin::Unregister( | |
| 125 const base::Closure& callback, | |
| 126 const ErrorCallback& error_callback) { | |
| 127 NOTIMPLEMENTED(); | |
| 128 error_callback.Run(GATT_ERROR_NOT_SUPPORTED); | |
| 129 } | |
| 130 | |
| 131 void BluetoothRemoteGattServiceWin::GattCharacteristicDiscoveryComplete( | 102 void BluetoothRemoteGattServiceWin::GattCharacteristicDiscoveryComplete( |
| 132 BluetoothRemoteGattCharacteristicWin* characteristic) { | 103 BluetoothRemoteGattCharacteristicWin* characteristic) { |
| 133 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 104 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
| 134 DCHECK(included_characteristics_.find(characteristic->GetIdentifier()) != | 105 DCHECK(included_characteristics_.find(characteristic->GetIdentifier()) != |
| 135 included_characteristics_.end()); | 106 included_characteristics_.end()); |
| 136 | 107 |
| 137 discovery_completed_included_charateristics_.insert( | 108 discovery_completed_included_charateristics_.insert( |
| 138 characteristic->GetIdentifier()); | 109 characteristic->GetIdentifier()); |
| 139 adapter_->NotifyGattCharacteristicAdded(characteristic); | 110 adapter_->NotifyGattCharacteristicAdded(characteristic); |
| 140 NotifyGattDiscoveryCompleteForServiceIfNecessary(); | 111 NotifyGattDiscoveryCompleteForServiceIfNecessary(); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 void BluetoothRemoteGattServiceWin::ClearIncludedCharacteristics() { | 228 void BluetoothRemoteGattServiceWin::ClearIncludedCharacteristics() { |
| 258 discovery_completed_included_charateristics_.clear(); | 229 discovery_completed_included_charateristics_.clear(); |
| 259 // Explicitly reset to null to ensure that calling GetCharacteristic() on the | 230 // Explicitly reset to null to ensure that calling GetCharacteristic() on the |
| 260 // removed characteristic in GattDescriptorRemoved() returns null. | 231 // removed characteristic in GattDescriptorRemoved() returns null. |
| 261 for (auto& entry : included_characteristics_) | 232 for (auto& entry : included_characteristics_) |
| 262 entry.second.reset(); | 233 entry.second.reset(); |
| 263 included_characteristics_.clear(); | 234 included_characteristics_.clear(); |
| 264 } | 235 } |
| 265 | 236 |
| 266 } // namespace device. | 237 } // namespace device. |
| OLD | NEW |