Chromium Code Reviews| 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/bluez/bluetooth_service_record_bluez.h" | 5 #include "device/bluetooth/bluez/bluetooth_service_record_bluez.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 | 8 |
| 9 namespace bluez { | 9 namespace bluez { |
| 10 | 10 |
| 11 BluetoothServiceRecordBlueZ::BluetoothServiceRecordBlueZ() {} | 11 BluetoothServiceRecordBlueZ::BluetoothServiceRecordBlueZ( |
| 12 const std::map<uint16_t, BluetoothServiceAttributeValueBlueZ>& attributes) | |
| 13 : attributes_(attributes) {} | |
| 14 | |
| 15 BluetoothServiceRecordBlueZ::BluetoothServiceRecordBlueZ( | |
| 16 const BluetoothServiceRecordBlueZ& record) { | |
| 17 this->attributes_ = record.attributes_; | |
| 18 } | |
| 12 | 19 |
| 13 BluetoothServiceRecordBlueZ::~BluetoothServiceRecordBlueZ() {} | 20 BluetoothServiceRecordBlueZ::~BluetoothServiceRecordBlueZ() {} |
| 14 | 21 |
| 15 std::vector<uint16_t> BluetoothServiceRecordBlueZ::GetAttributeIds() { | 22 const std::vector<uint16_t> BluetoothServiceRecordBlueZ::GetAttributeIds() |
| 16 // TODO(rkc): Implement this. | 23 const { |
| 17 return std::vector<uint16_t>(); | 24 std::vector<uint16_t> ids; |
|
xiyuan
2016/06/22 15:53:05
nit: ids.reserve(attributes_.size());
rkc
2016/06/22 21:06:37
Done.
| |
| 25 for (const auto& attribute : attributes_) | |
| 26 ids.emplace_back(attribute.first); | |
| 27 return ids; | |
| 18 } | 28 } |
| 19 | 29 |
| 20 base::Value* BluetoothServiceRecordBlueZ::GetAttributeValue( | 30 const BluetoothServiceAttributeValueBlueZ& |
| 21 uint16_t attribute_id) { | 31 BluetoothServiceRecordBlueZ::GetAttributeValue(uint16_t attribute_id) const { |
| 22 // TODO(rkc): Implement this. | 32 auto it = attributes_.find(attribute_id); |
| 23 return nullptr; | 33 CHECK(it != attributes_.end()); |
| 34 return it->second; | |
| 24 } | 35 } |
| 25 | 36 |
| 26 } // namespace bluez | 37 } // namespace bluez |
| OLD | NEW |