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

Side by Side Diff: content/renderer/bluetooth/web_bluetooth_impl.cc

Issue 2456613002: Remove BluetoothDevice.uuids attribute from WebBluetooth (Closed)
Patch Set: address more comments Created 4 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/renderer/bluetooth/web_bluetooth_impl.h" 5 #include "content/renderer/bluetooth/web_bluetooth_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 base::Bind(&WebBluetoothImpl::DispatchCharacteristicValueChanged, 179 base::Bind(&WebBluetoothImpl::DispatchCharacteristicValueChanged,
180 base::Unretained(this), characteristic_instance_id, 180 base::Unretained(this), characteristic_instance_id,
181 value.PassStorage())); 181 value.PassStorage()));
182 } 182 }
183 183
184 void WebBluetoothImpl::OnRequestDeviceComplete( 184 void WebBluetoothImpl::OnRequestDeviceComplete(
185 std::unique_ptr<blink::WebBluetoothRequestDeviceCallbacks> callbacks, 185 std::unique_ptr<blink::WebBluetoothRequestDeviceCallbacks> callbacks,
186 const blink::mojom::WebBluetoothResult result, 186 const blink::mojom::WebBluetoothResult result,
187 blink::mojom::WebBluetoothDevicePtr device) { 187 blink::mojom::WebBluetoothDevicePtr device) {
188 if (result == blink::mojom::WebBluetoothResult::SUCCESS) { 188 if (result == blink::mojom::WebBluetoothResult::SUCCESS) {
189 blink::WebVector<blink::WebString> uuids(device->uuids.size());
190 for (size_t i = 0; i < device->uuids.size(); ++i)
191 uuids[i] = blink::WebString::fromUTF8(device->uuids[i]);
192
193 callbacks->onSuccess(base::MakeUnique<blink::WebBluetoothDeviceInit>( 189 callbacks->onSuccess(base::MakeUnique<blink::WebBluetoothDeviceInit>(
194 blink::WebString::fromUTF8(device->id.str()), 190 blink::WebString::fromUTF8(device->id.str()),
195 device->name.is_null() ? blink::WebString() 191 device->name.is_null() ? blink::WebString()
196 : blink::WebString::fromUTF8(device->name), 192 : blink::WebString::fromUTF8(device->name)));
197 uuids));
198 } else { 193 } else {
199 callbacks->onError(ToInt32(result)); 194 callbacks->onError(ToInt32(result));
200 } 195 }
201 } 196 }
202 197
203 void WebBluetoothImpl::GattServerDisconnected( 198 void WebBluetoothImpl::GattServerDisconnected(
204 const WebBluetoothDeviceId& device_id) { 199 const WebBluetoothDeviceId& device_id) {
205 auto device_iter = connected_devices_.find(device_id); 200 auto device_iter = connected_devices_.find(device_id);
206 if (device_iter != connected_devices_.end()) { 201 if (device_iter != connected_devices_.end()) {
207 // Remove device from the map before calling dispatchGattServerDisconnected 202 // Remove device from the map before calling dispatchGattServerDisconnected
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 // Create an associated interface ptr and pass it to the WebBluetoothService 318 // Create an associated interface ptr and pass it to the WebBluetoothService
324 // so that it can send us events without us prompting. 319 // so that it can send us events without us prompting.
325 blink::mojom::WebBluetoothServiceClientAssociatedPtrInfo ptr_info; 320 blink::mojom::WebBluetoothServiceClientAssociatedPtrInfo ptr_info;
326 binding_.Bind(&ptr_info, web_bluetooth_service_.associated_group()); 321 binding_.Bind(&ptr_info, web_bluetooth_service_.associated_group());
327 web_bluetooth_service_->SetClient(std::move(ptr_info)); 322 web_bluetooth_service_->SetClient(std::move(ptr_info));
328 } 323 }
329 return *web_bluetooth_service_; 324 return *web_bluetooth_service_;
330 } 325 }
331 326
332 } // namespace content 327 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698