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

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

Issue 2228953003: bluetooth: Change GetInquiryTxPower and GetInquiryRSSI to return optional. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: TIL value_or 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
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_device.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::UUIDList& uuids = device.GetUUIDs();
120 for (device::BluetoothDevice::UUIDList::const_iterator iter = uuids.begin(); 120 for (device::BluetoothDevice::UUIDList::const_iterator iter = uuids.begin();
121 iter != uuids.end(); ++iter) 121 iter != uuids.end(); ++iter)
122 string_uuids->push_back(iter->canonical_value()); 122 string_uuids->push_back(iter->canonical_value());
123 out->uuids.reset(string_uuids); 123 out->uuids.reset(string_uuids);
124 124
125 if (device.GetInquiryRSSI() != device::BluetoothDevice::kUnknownPower) 125 if (device.GetInquiryRSSI())
126 out->inquiry_rssi.reset(new int(device.GetInquiryRSSI())); 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() != device::BluetoothDevice::kUnknownPower) 130 if (device.GetInquiryTxPower())
131 out->inquiry_tx_power.reset(new int(device.GetInquiryTxPower())); 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
« no previous file with comments | « device/bluetooth/test/mock_bluetooth_device.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698