Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Side by Side Diff: device/bluetooth/bluez/bluetooth_service_record_bluez.cc

Issue 2102093003: Implement BluetoothDeviceBlueZ::GetServiceRecords. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <utility>
8
7 #include "base/values.h" 9 #include "base/values.h"
8 10
9 namespace bluez { 11 namespace bluez {
10 12
11 BluetoothServiceRecordBlueZ::BluetoothServiceRecordBlueZ( 13 BluetoothServiceRecordBlueZ::BluetoothServiceRecordBlueZ() {}
12 const std::map<uint16_t, BluetoothServiceAttributeValueBlueZ>& attributes)
13 : attributes_(attributes) {}
14 14
15 BluetoothServiceRecordBlueZ::BluetoothServiceRecordBlueZ( 15 BluetoothServiceRecordBlueZ::BluetoothServiceRecordBlueZ(
16 const BluetoothServiceRecordBlueZ& record) { 16 const BluetoothServiceRecordBlueZ& record) {
17 this->attributes_ = record.attributes_; 17 this->attributes_ = record.attributes_;
18 } 18 }
19 19
20 BluetoothServiceRecordBlueZ::~BluetoothServiceRecordBlueZ() {} 20 BluetoothServiceRecordBlueZ::~BluetoothServiceRecordBlueZ() {}
21 21
22 const std::vector<uint16_t> BluetoothServiceRecordBlueZ::GetAttributeIds() 22 const std::vector<uint16_t> BluetoothServiceRecordBlueZ::GetAttributeIds()
23 const { 23 const {
24 std::vector<uint16_t> ids; 24 std::vector<uint16_t> ids;
25 ids.reserve(attributes_.size()); 25 ids.reserve(attributes_.size());
26 for (const auto& attribute : attributes_) 26 for (const auto& attribute : attributes_)
27 ids.emplace_back(attribute.first); 27 ids.emplace_back(attribute.first);
28 return ids; 28 return ids;
29 } 29 }
30 30
31 const BluetoothServiceAttributeValueBlueZ& 31 const BluetoothServiceAttributeValueBlueZ&
32 BluetoothServiceRecordBlueZ::GetAttributeValue(uint16_t attribute_id) const { 32 BluetoothServiceRecordBlueZ::GetAttributeValue(uint16_t attribute_id) const {
33 auto it = attributes_.find(attribute_id); 33 auto it = attributes_.find(attribute_id);
34 CHECK(it != attributes_.end()); 34 CHECK(it != attributes_.end());
35 return it->second; 35 return it->second;
36 } 36 }
37 37
38 void BluetoothServiceRecordBlueZ::AddRecordEntry(
39 uint16_t id,
40 const BluetoothServiceAttributeValueBlueZ& value) {
41 auto it = attributes_.find(id);
42 if (it != attributes_.end())
43 attributes_.erase(it);
44 attributes_.insert(
45 std::pair<uint16_t, BluetoothServiceAttributeValueBlueZ>(id, value));
46 }
47
38 } // namespace bluez 48 } // namespace bluez
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698