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

Side by Side Diff: extensions/browser/api/bluetooth/bluetooth_api_utils.cc

Issue 2244693002: bluetooth: Refactor how we update based on Advertising Data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "extensions/browser/api/bluetooth/bluetooth_api_utils.h" 5 #include "extensions/browser/api/bluetooth/bluetooth_api_utils.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "device/bluetooth/bluetooth_adapter.h" 9 #include "device/bluetooth/bluetooth_adapter.h"
10 #include "device/bluetooth/bluetooth_device.h" 10 #include "device/bluetooth/bluetooth_device.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 109 }
110 110
111 ConvertDeviceTypeToApi(device.GetDeviceType(), &(out->type)); 111 ConvertDeviceTypeToApi(device.GetDeviceType(), &(out->type));
112 112
113 out->paired.reset(new bool(device.IsPaired())); 113 out->paired.reset(new bool(device.IsPaired()));
114 out->connected.reset(new bool(device.IsConnected())); 114 out->connected.reset(new bool(device.IsConnected()));
115 out->connecting.reset(new bool(device.IsConnecting())); 115 out->connecting.reset(new bool(device.IsConnecting()));
116 out->connectable.reset(new bool(device.IsConnectable())); 116 out->connectable.reset(new bool(device.IsConnectable()));
117 117
118 std::vector<std::string>* string_uuids = new std::vector<std::string>(); 118 std::vector<std::string>* string_uuids = new std::vector<std::string>();
119 const device::BluetoothDevice::UUIDList& uuids = device.GetUUIDs(); 119 const device::BluetoothDevice::UUIDSet& uuids = device.GetUUIDs();
120 for (device::BluetoothDevice::UUIDList::const_iterator iter = uuids.begin(); 120 for (const auto& uuid : uuids) {
121 iter != uuids.end(); ++iter) 121 string_uuids->push_back(uuid.canonical_value());
122 string_uuids->push_back(iter->canonical_value()); 122 }
123 out->uuids.reset(string_uuids); 123 out->uuids.reset(string_uuids);
124 124
125 if (device.GetInquiryRSSI()) 125 if (device.GetInquiryRSSI())
126 out->inquiry_rssi.reset(new int(device.GetInquiryRSSI().value())); 126 out->inquiry_rssi.reset(new int(device.GetInquiryRSSI().value()));
127 else 127 else
128 out->inquiry_rssi.reset(); 128 out->inquiry_rssi.reset();
129 129
130 if (device.GetInquiryTxPower()) 130 if (device.GetInquiryTxPower())
131 out->inquiry_tx_power.reset(new int(device.GetInquiryTxPower().value())); 131 out->inquiry_tx_power.reset(new int(device.GetInquiryTxPower().value()));
132 else 132 else
133 out->inquiry_tx_power.reset(); 133 out->inquiry_tx_power.reset();
134 } 134 }
135 135
136 void PopulateAdapterState(const device::BluetoothAdapter& adapter, 136 void PopulateAdapterState(const device::BluetoothAdapter& adapter,
137 AdapterState* out) { 137 AdapterState* out) {
138 out->discovering = adapter.IsDiscovering(); 138 out->discovering = adapter.IsDiscovering();
139 out->available = adapter.IsPresent(); 139 out->available = adapter.IsPresent();
140 out->powered = adapter.IsPowered(); 140 out->powered = adapter.IsPowered();
141 out->name = adapter.GetName(); 141 out->name = adapter.GetName();
142 out->address = adapter.GetAddress(); 142 out->address = adapter.GetAddress();
143 } 143 }
144 144
145 } // namespace bluetooth 145 } // namespace bluetooth
146 } // namespace api 146 } // namespace api
147 } // namespace extensions 147 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698