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

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

Issue 1926623002: bluetooth: Remove the device info and device class fields from BluetoothDevice. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 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/bluetooth_dispatcher.h" 5 #include "content/renderer/bluetooth/bluetooth_dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 base::LazyInstance<base::ThreadLocalPointer<void>>::Leaky g_dispatcher_tls = 54 base::LazyInstance<base::ThreadLocalPointer<void>>::Leaky g_dispatcher_tls =
55 LAZY_INSTANCE_INITIALIZER; 55 LAZY_INSTANCE_INITIALIZER;
56 56
57 void* const kHasBeenDeleted = reinterpret_cast<void*>(0x1); 57 void* const kHasBeenDeleted = reinterpret_cast<void*>(0x1);
58 58
59 int CurrentWorkerId() { 59 int CurrentWorkerId() {
60 return WorkerThread::GetCurrentId(); 60 return WorkerThread::GetCurrentId();
61 } 61 }
62 62
63 WebBluetoothDevice::VendorIDSource GetWebVendorIdSource(
64 device::BluetoothDevice::VendorIDSource vendor_id_source) {
65 switch (vendor_id_source) {
66 case device::BluetoothDevice::VENDOR_ID_UNKNOWN:
67 return WebBluetoothDevice::VendorIDSource::Unknown;
68 case device::BluetoothDevice::VENDOR_ID_BLUETOOTH:
69 return WebBluetoothDevice::VendorIDSource::Bluetooth;
70 case device::BluetoothDevice::VENDOR_ID_USB:
71 return WebBluetoothDevice::VendorIDSource::USB;
72 }
73 NOTREACHED();
74 return WebBluetoothDevice::VendorIDSource::Unknown;
75 }
76
77 } // namespace 63 } // namespace
78 64
79 BluetoothDispatcher::BluetoothDispatcher(ThreadSafeSender* sender) 65 BluetoothDispatcher::BluetoothDispatcher(ThreadSafeSender* sender)
80 : thread_safe_sender_(sender) { 66 : thread_safe_sender_(sender) {
81 g_dispatcher_tls.Pointer()->Set(static_cast<void*>(this)); 67 g_dispatcher_tls.Pointer()->Set(static_cast<void*>(this));
82 } 68 }
83 69
84 BluetoothDispatcher::~BluetoothDispatcher() { 70 BluetoothDispatcher::~BluetoothDispatcher() {
85 g_dispatcher_tls.Pointer()->Set(kHasBeenDeleted); 71 g_dispatcher_tls.Pointer()->Set(kHasBeenDeleted);
86 } 72 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 const BluetoothDevice& device) { 175 const BluetoothDevice& device) {
190 DCHECK(pending_requests_.Lookup(request_id)) << request_id; 176 DCHECK(pending_requests_.Lookup(request_id)) << request_id;
191 177
192 WebVector<WebString> uuids(device.uuids.size()); 178 WebVector<WebString> uuids(device.uuids.size());
193 for (size_t i = 0; i < device.uuids.size(); ++i) 179 for (size_t i = 0; i < device.uuids.size(); ++i)
194 uuids[i] = WebString::fromUTF8(device.uuids[i].c_str()); 180 uuids[i] = WebString::fromUTF8(device.uuids[i].c_str());
195 181
196 pending_requests_.Lookup(request_id) 182 pending_requests_.Lookup(request_id)
197 ->onSuccess(base::WrapUnique(new WebBluetoothDevice( 183 ->onSuccess(base::WrapUnique(new WebBluetoothDevice(
198 WebString::fromUTF8(device.id), WebString(device.name), 184 WebString::fromUTF8(device.id), WebString(device.name),
199 device.tx_power, device.rssi, device.device_class, 185 device.tx_power, device.rssi, uuids)));
200 GetWebVendorIdSource(device.vendor_id_source), device.vendor_id,
201 device.product_id, device.product_version, uuids)));
202 pending_requests_.Remove(request_id); 186 pending_requests_.Remove(request_id);
203 } 187 }
204 188
205 void BluetoothDispatcher::OnRequestDeviceError(int thread_id, 189 void BluetoothDispatcher::OnRequestDeviceError(int thread_id,
206 int request_id, 190 int request_id,
207 WebBluetoothError error) { 191 WebBluetoothError error) {
208 DCHECK(pending_requests_.Lookup(request_id)) << request_id; 192 DCHECK(pending_requests_.Lookup(request_id)) << request_id;
209 pending_requests_.Lookup(request_id)->onError(WebBluetoothError(error)); 193 pending_requests_.Lookup(request_id)->onError(WebBluetoothError(error));
210 pending_requests_.Remove(request_id); 194 pending_requests_.Remove(request_id);
211 } 195 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 int request_id, 228 int request_id,
245 WebBluetoothError error) { 229 WebBluetoothError error) {
246 DCHECK(pending_primary_service_requests_.Lookup(request_id)) << request_id; 230 DCHECK(pending_primary_service_requests_.Lookup(request_id)) << request_id;
247 231
248 pending_primary_service_requests_.Lookup(request_id) 232 pending_primary_service_requests_.Lookup(request_id)
249 ->callbacks->onError(WebBluetoothError(error)); 233 ->callbacks->onError(WebBluetoothError(error));
250 pending_primary_service_requests_.Remove(request_id); 234 pending_primary_service_requests_.Remove(request_id);
251 } 235 }
252 236
253 } // namespace content 237 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698