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

Side by Side Diff: components/arc/bluetooth/arc_bluetooth_bridge.cc

Issue 1885683005: Add module suffix in .mojom files for components/arc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 "components/arc/bluetooth/arc_bluetooth_bridge.h" 5 #include "components/arc/bluetooth/arc_bluetooth_bridge.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <iomanip> 10 #include <iomanip>
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 bluetooth_adapter_->RemoveObserver(this); 55 bluetooth_adapter_->RemoveObserver(this);
56 } 56 }
57 57
58 void ArcBluetoothBridge::OnAdapterInitialized( 58 void ArcBluetoothBridge::OnAdapterInitialized(
59 scoped_refptr<BluetoothAdapter> adapter) { 59 scoped_refptr<BluetoothAdapter> adapter) {
60 bluetooth_adapter_ = adapter; 60 bluetooth_adapter_ = adapter;
61 bluetooth_adapter_->AddObserver(this); 61 bluetooth_adapter_->AddObserver(this);
62 } 62 }
63 63
64 void ArcBluetoothBridge::OnBluetoothInstanceReady() { 64 void ArcBluetoothBridge::OnBluetoothInstanceReady() {
65 BluetoothInstance* bluetooth_instance = 65 mojom::BluetoothInstance* bluetooth_instance =
66 arc_bridge_service()->bluetooth_instance(); 66 arc_bridge_service()->bluetooth_instance();
67 if (!bluetooth_instance) { 67 if (!bluetooth_instance) {
68 LOG(ERROR) << "OnBluetoothInstanceReady called, " 68 LOG(ERROR) << "OnBluetoothInstanceReady called, "
69 << "but no bluetooth instance found"; 69 << "but no bluetooth instance found";
70 return; 70 return;
71 } 71 }
72 72
73 arc_bridge_service()->bluetooth_instance()->Init( 73 arc_bridge_service()->bluetooth_instance()->Init(
74 binding_.CreateInterfacePtrAndBind()); 74 binding_.CreateInterfacePtrAndBind());
75 } 75 }
(...skipping 17 matching lines...) Expand all
93 } 93 }
94 94
95 void ArcBluetoothBridge::DeviceAdded(BluetoothAdapter* adapter, 95 void ArcBluetoothBridge::DeviceAdded(BluetoothAdapter* adapter,
96 BluetoothDevice* device) { 96 BluetoothDevice* device) {
97 if (!HasBluetoothInstance()) 97 if (!HasBluetoothInstance())
98 return; 98 return;
99 99
100 if (device->IsConnected()) 100 if (device->IsConnected())
101 return; 101 return;
102 102
103 mojo::Array<BluetoothPropertyPtr> properties = 103 mojo::Array<mojom::BluetoothPropertyPtr> properties =
104 GetDeviceProperties(BluetoothPropertyType::ALL, device); 104 GetDeviceProperties(mojom::BluetoothPropertyType::ALL, device);
105 105
106 arc_bridge_service()->bluetooth_instance()->OnDeviceFound( 106 arc_bridge_service()->bluetooth_instance()->OnDeviceFound(
107 std::move(properties)); 107 std::move(properties));
108 } 108 }
109 109
110 void ArcBluetoothBridge::DeviceChanged(BluetoothAdapter* adapter, 110 void ArcBluetoothBridge::DeviceChanged(BluetoothAdapter* adapter,
111 BluetoothDevice* device) { 111 BluetoothDevice* device) {
112 // TODO(smbarber): device properties changed; inform the container. 112 // TODO(smbarber): device properties changed; inform the container.
113 } 113 }
114 114
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 void ArcBluetoothBridge::DisableAdapter( 201 void ArcBluetoothBridge::DisableAdapter(
202 const DisableAdapterCallback& callback) { 202 const DisableAdapterCallback& callback) {
203 DCHECK(bluetooth_adapter_); 203 DCHECK(bluetooth_adapter_);
204 bluetooth_adapter_->SetPowered( 204 bluetooth_adapter_->SetPowered(
205 false, base::Bind(&ArcBluetoothBridge::OnPoweredOff, 205 false, base::Bind(&ArcBluetoothBridge::OnPoweredOff,
206 weak_factory_.GetWeakPtr(), callback), 206 weak_factory_.GetWeakPtr(), callback),
207 base::Bind(&ArcBluetoothBridge::OnPoweredError, 207 base::Bind(&ArcBluetoothBridge::OnPoweredError,
208 weak_factory_.GetWeakPtr(), callback)); 208 weak_factory_.GetWeakPtr(), callback));
209 } 209 }
210 210
211 void ArcBluetoothBridge::GetAdapterProperty(BluetoothPropertyType type) { 211 void ArcBluetoothBridge::GetAdapterProperty(mojom::BluetoothPropertyType type) {
212 DCHECK(bluetooth_adapter_); 212 DCHECK(bluetooth_adapter_);
213 if (!HasBluetoothInstance()) 213 if (!HasBluetoothInstance())
214 return; 214 return;
215 215
216 mojo::Array<BluetoothPropertyPtr> properties = GetAdapterProperties(type); 216 mojo::Array<mojom::BluetoothPropertyPtr> properties =
217 GetAdapterProperties(type);
217 218
218 arc_bridge_service()->bluetooth_instance()->OnAdapterProperties( 219 arc_bridge_service()->bluetooth_instance()->OnAdapterProperties(
219 BluetoothStatus::SUCCESS, std::move(properties)); 220 mojom::BluetoothStatus::SUCCESS, std::move(properties));
220 } 221 }
221 222
222 void ArcBluetoothBridge::SetAdapterProperty(BluetoothPropertyPtr property) { 223 void ArcBluetoothBridge::SetAdapterProperty(
224 mojom::BluetoothPropertyPtr property) {
223 DCHECK(bluetooth_adapter_); 225 DCHECK(bluetooth_adapter_);
224 if (!HasBluetoothInstance()) 226 if (!HasBluetoothInstance())
225 return; 227 return;
226 228
227 // TODO(smbarber): Implement SetAdapterProperty 229 // TODO(smbarber): Implement SetAdapterProperty
228 arc_bridge_service()->bluetooth_instance()->OnAdapterProperties( 230 arc_bridge_service()->bluetooth_instance()->OnAdapterProperties(
229 BluetoothStatus::FAIL, mojo::Array<BluetoothPropertyPtr>::New(0)); 231 mojom::BluetoothStatus::FAIL,
232 mojo::Array<mojom::BluetoothPropertyPtr>::New(0));
230 } 233 }
231 234
232 void ArcBluetoothBridge::GetRemoteDeviceProperty( 235 void ArcBluetoothBridge::GetRemoteDeviceProperty(
233 BluetoothAddressPtr remote_addr, 236 mojom::BluetoothAddressPtr remote_addr,
234 BluetoothPropertyType type) { 237 mojom::BluetoothPropertyType type) {
235 DCHECK(bluetooth_adapter_); 238 DCHECK(bluetooth_adapter_);
236 if (!HasBluetoothInstance()) 239 if (!HasBluetoothInstance())
237 return; 240 return;
238 241
239 std::string addr_str = remote_addr->To<std::string>(); 242 std::string addr_str = remote_addr->To<std::string>();
240 BluetoothDevice* device = bluetooth_adapter_->GetDevice(addr_str); 243 BluetoothDevice* device = bluetooth_adapter_->GetDevice(addr_str);
241 244
242 mojo::Array<BluetoothPropertyPtr> properties = 245 mojo::Array<mojom::BluetoothPropertyPtr> properties =
243 GetDeviceProperties(type, device); 246 GetDeviceProperties(type, device);
244 247
245 arc_bridge_service()->bluetooth_instance()->OnRemoteDeviceProperties( 248 arc_bridge_service()->bluetooth_instance()->OnRemoteDeviceProperties(
246 BluetoothStatus::SUCCESS, std::move(remote_addr), std::move(properties)); 249 mojom::BluetoothStatus::SUCCESS, std::move(remote_addr),
250 std::move(properties));
247 } 251 }
248 252
249 void ArcBluetoothBridge::SetRemoteDeviceProperty( 253 void ArcBluetoothBridge::SetRemoteDeviceProperty(
250 BluetoothAddressPtr remote_addr, 254 mojom::BluetoothAddressPtr remote_addr,
251 BluetoothPropertyPtr property) { 255 mojom::BluetoothPropertyPtr property) {
252 DCHECK(bluetooth_adapter_); 256 DCHECK(bluetooth_adapter_);
253 if (!HasBluetoothInstance()) 257 if (!HasBluetoothInstance())
254 return; 258 return;
255 259
256 // TODO(smbarber): Implement SetRemoteDeviceProperty 260 // TODO(smbarber): Implement SetRemoteDeviceProperty
257 arc_bridge_service()->bluetooth_instance()->OnRemoteDeviceProperties( 261 arc_bridge_service()->bluetooth_instance()->OnRemoteDeviceProperties(
258 BluetoothStatus::FAIL, std::move(remote_addr), 262 mojom::BluetoothStatus::FAIL, std::move(remote_addr),
259 mojo::Array<BluetoothPropertyPtr>::New(0)); 263 mojo::Array<mojom::BluetoothPropertyPtr>::New(0));
260 } 264 }
261 265
262 void ArcBluetoothBridge::GetRemoteServiceRecord(BluetoothAddressPtr remote_addr, 266 void ArcBluetoothBridge::GetRemoteServiceRecord(
263 BluetoothUUIDPtr uuid) { 267 mojom::BluetoothAddressPtr remote_addr,
268 mojom::BluetoothUUIDPtr uuid) {
264 // TODO(smbarber): Implement GetRemoteServiceRecord 269 // TODO(smbarber): Implement GetRemoteServiceRecord
265 } 270 }
266 271
267 void ArcBluetoothBridge::GetRemoteServices(BluetoothAddressPtr remote_addr) { 272 void ArcBluetoothBridge::GetRemoteServices(
273 mojom::BluetoothAddressPtr remote_addr) {
268 // TODO(smbarber): Implement GetRemoteServices 274 // TODO(smbarber): Implement GetRemoteServices
269 } 275 }
270 276
271 void ArcBluetoothBridge::StartDiscovery() { 277 void ArcBluetoothBridge::StartDiscovery() {
272 DCHECK(bluetooth_adapter_); 278 DCHECK(bluetooth_adapter_);
273 // TODO(smbarber): Add timeout 279 // TODO(smbarber): Add timeout
274 if (discovery_session_) { 280 if (discovery_session_) {
275 LOG(ERROR) << "Discovery session already running; leaving alone"; 281 LOG(ERROR) << "Discovery session already running; leaving alone";
276 SendCachedDevicesFound(); 282 SendCachedDevicesFound();
277 return; 283 return;
(...skipping 11 matching lines...) Expand all
289 return; 295 return;
290 } 296 }
291 297
292 discovery_session_->Stop(base::Bind(&ArcBluetoothBridge::OnDiscoveryStopped, 298 discovery_session_->Stop(base::Bind(&ArcBluetoothBridge::OnDiscoveryStopped,
293 weak_factory_.GetWeakPtr()), 299 weak_factory_.GetWeakPtr()),
294 base::Bind(&ArcBluetoothBridge::OnDiscoveryError, 300 base::Bind(&ArcBluetoothBridge::OnDiscoveryError,
295 weak_factory_.GetWeakPtr())); 301 weak_factory_.GetWeakPtr()));
296 } 302 }
297 303
298 void ArcBluetoothBridge::OnPoweredOn( 304 void ArcBluetoothBridge::OnPoweredOn(
299 const mojo::Callback<void(BluetoothAdapterState)>& callback) const { 305 const mojo::Callback<void(mojom::BluetoothAdapterState)>& callback) const {
300 callback.Run(BluetoothAdapterState::ON); 306 callback.Run(mojom::BluetoothAdapterState::ON);
301 } 307 }
302 308
303 void ArcBluetoothBridge::OnPoweredOff( 309 void ArcBluetoothBridge::OnPoweredOff(
304 const mojo::Callback<void(BluetoothAdapterState)>& callback) const { 310 const mojo::Callback<void(mojom::BluetoothAdapterState)>& callback) const {
305 callback.Run(BluetoothAdapterState::OFF); 311 callback.Run(mojom::BluetoothAdapterState::OFF);
306 } 312 }
307 313
308 void ArcBluetoothBridge::OnPoweredError( 314 void ArcBluetoothBridge::OnPoweredError(
309 const mojo::Callback<void(BluetoothAdapterState)>& callback) const { 315 const mojo::Callback<void(mojom::BluetoothAdapterState)>& callback) const {
310 LOG(WARNING) << "failed to change power state"; 316 LOG(WARNING) << "failed to change power state";
311 317
312 callback.Run(bluetooth_adapter_->IsPowered() ? BluetoothAdapterState::ON 318 callback.Run(bluetooth_adapter_->IsPowered()
313 : BluetoothAdapterState::OFF); 319 ? mojom::BluetoothAdapterState::ON
320 : mojom::BluetoothAdapterState::OFF);
314 } 321 }
315 322
316 void ArcBluetoothBridge::OnDiscoveryStarted( 323 void ArcBluetoothBridge::OnDiscoveryStarted(
317 scoped_ptr<BluetoothDiscoverySession> session) { 324 scoped_ptr<BluetoothDiscoverySession> session) {
318 if (!HasBluetoothInstance()) 325 if (!HasBluetoothInstance())
319 return; 326 return;
320 327
321 discovery_session_ = std::move(session); 328 discovery_session_ = std::move(session);
322 329
323 arc_bridge_service()->bluetooth_instance()->OnDiscoveryStateChanged( 330 arc_bridge_service()->bluetooth_instance()->OnDiscoveryStateChanged(
324 BluetoothDiscoveryState::STARTED); 331 mojom::BluetoothDiscoveryState::STARTED);
325 332
326 SendCachedDevicesFound(); 333 SendCachedDevicesFound();
327 } 334 }
328 335
329 void ArcBluetoothBridge::OnDiscoveryStopped() { 336 void ArcBluetoothBridge::OnDiscoveryStopped() {
330 if (!HasBluetoothInstance()) 337 if (!HasBluetoothInstance())
331 return; 338 return;
332 339
333 discovery_session_.reset(); 340 discovery_session_.reset();
334 341
335 arc_bridge_service()->bluetooth_instance()->OnDiscoveryStateChanged( 342 arc_bridge_service()->bluetooth_instance()->OnDiscoveryStateChanged(
336 BluetoothDiscoveryState::STOPPED); 343 mojom::BluetoothDiscoveryState::STOPPED);
337 } 344 }
338 345
339 void ArcBluetoothBridge::CreateBond(BluetoothAddressPtr addr, 346 void ArcBluetoothBridge::CreateBond(mojom::BluetoothAddressPtr addr,
340 int32_t transport) { 347 int32_t transport) {
341 // TODO(smbarber): Implement CreateBond 348 // TODO(smbarber): Implement CreateBond
342 } 349 }
343 350
344 void ArcBluetoothBridge::RemoveBond(BluetoothAddressPtr addr) { 351 void ArcBluetoothBridge::RemoveBond(mojom::BluetoothAddressPtr addr) {
345 // TODO(smbarber): Implement RemoveBond 352 // TODO(smbarber): Implement RemoveBond
346 } 353 }
347 354
348 void ArcBluetoothBridge::CancelBond(BluetoothAddressPtr addr) { 355 void ArcBluetoothBridge::CancelBond(mojom::BluetoothAddressPtr addr) {
349 // TODO(smbarber): Implement CancelBond 356 // TODO(smbarber): Implement CancelBond
350 } 357 }
351 358
352 void ArcBluetoothBridge::GetConnectionState( 359 void ArcBluetoothBridge::GetConnectionState(
353 BluetoothAddressPtr addr, 360 mojom::BluetoothAddressPtr addr,
354 const GetConnectionStateCallback& callback) { 361 const GetConnectionStateCallback& callback) {
355 if (!bluetooth_adapter_) { 362 if (!bluetooth_adapter_) {
356 callback.Run(false); 363 callback.Run(false);
357 return; 364 return;
358 } 365 }
359 366
360 std::string addr_str = addr->To<std::string>(); 367 std::string addr_str = addr->To<std::string>();
361 BluetoothDevice* device = bluetooth_adapter_->GetDevice(addr_str); 368 BluetoothDevice* device = bluetooth_adapter_->GetDevice(addr_str);
362 if (!device) { 369 if (!device) {
363 callback.Run(false); 370 callback.Run(false);
364 return; 371 return;
365 } 372 }
366 373
367 callback.Run(device->IsConnected()); 374 callback.Run(device->IsConnected());
368 } 375 }
369 376
370 void ArcBluetoothBridge::OnDiscoveryError() { 377 void ArcBluetoothBridge::OnDiscoveryError() {
371 LOG(WARNING) << "failed to change discovery state"; 378 LOG(WARNING) << "failed to change discovery state";
372 } 379 }
373 380
374 mojo::Array<BluetoothPropertyPtr> ArcBluetoothBridge::GetDeviceProperties( 381 mojo::Array<mojom::BluetoothPropertyPtr>
375 BluetoothPropertyType type, 382 ArcBluetoothBridge::GetDeviceProperties(mojom::BluetoothPropertyType type,
376 BluetoothDevice* device) { 383 BluetoothDevice* device) {
377 mojo::Array<BluetoothPropertyPtr> properties; 384 mojo::Array<mojom::BluetoothPropertyPtr> properties;
378 385
379 if (!device) { 386 if (!device) {
380 return properties; 387 return properties;
381 } 388 }
382 389
383 if (type == BluetoothPropertyType::ALL || 390 if (type == mojom::BluetoothPropertyType::ALL ||
384 type == BluetoothPropertyType::BDNAME) { 391 type == mojom::BluetoothPropertyType::BDNAME) {
385 BluetoothPropertyPtr btp = BluetoothProperty::New(); 392 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
386 btp->set_bdname(mojo::String::From(base::UTF16ToUTF8(device->GetName()))); 393 btp->set_bdname(mojo::String::From(base::UTF16ToUTF8(device->GetName())));
387 properties.push_back(std::move(btp)); 394 properties.push_back(std::move(btp));
388 } 395 }
389 if (type == BluetoothPropertyType::ALL || 396 if (type == mojom::BluetoothPropertyType::ALL ||
390 type == BluetoothPropertyType::BDADDR) { 397 type == mojom::BluetoothPropertyType::BDADDR) {
391 BluetoothPropertyPtr btp = BluetoothProperty::New(); 398 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
392 btp->set_bdaddr(BluetoothAddress::From(device->GetAddress())); 399 btp->set_bdaddr(mojom::BluetoothAddress::From(device->GetAddress()));
393 properties.push_back(std::move(btp)); 400 properties.push_back(std::move(btp));
394 } 401 }
395 if (type == BluetoothPropertyType::ALL || 402 if (type == mojom::BluetoothPropertyType::ALL ||
396 type == BluetoothPropertyType::UUIDS) { 403 type == mojom::BluetoothPropertyType::UUIDS) {
397 BluetoothPropertyPtr btp = BluetoothProperty::New(); 404 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
398 std::vector<device::BluetoothUUID> uuids = device->GetUUIDs(); 405 std::vector<device::BluetoothUUID> uuids = device->GetUUIDs();
399 mojo::Array<BluetoothUUIDPtr> uuid_results = 406 mojo::Array<mojom::BluetoothUUIDPtr> uuid_results =
400 mojo::Array<BluetoothUUIDPtr>::New(0); 407 mojo::Array<mojom::BluetoothUUIDPtr>::New(0);
401 408
402 for (size_t i = 0; i < uuids.size(); i++) { 409 for (size_t i = 0; i < uuids.size(); i++) {
403 uuid_results.push_back(BluetoothUUID::From(uuids[i])); 410 uuid_results.push_back(mojom::BluetoothUUID::From(uuids[i]));
404 } 411 }
405 412
406 btp->set_uuids(std::move(uuid_results)); 413 btp->set_uuids(std::move(uuid_results));
407 properties.push_back(std::move(btp)); 414 properties.push_back(std::move(btp));
408 } 415 }
409 if (type == BluetoothPropertyType::ALL || 416 if (type == mojom::BluetoothPropertyType::ALL ||
410 type == BluetoothPropertyType::CLASS_OF_DEVICE) { 417 type == mojom::BluetoothPropertyType::CLASS_OF_DEVICE) {
411 BluetoothPropertyPtr btp = BluetoothProperty::New(); 418 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
412 btp->set_device_class(device->GetBluetoothClass()); 419 btp->set_device_class(device->GetBluetoothClass());
413 properties.push_back(std::move(btp)); 420 properties.push_back(std::move(btp));
414 } 421 }
415 if (type == BluetoothPropertyType::ALL || 422 if (type == mojom::BluetoothPropertyType::ALL ||
416 type == BluetoothPropertyType::TYPE_OF_DEVICE) { 423 type == mojom::BluetoothPropertyType::TYPE_OF_DEVICE) {
417 // TODO(smbarber): This needs to be populated with the actual device type 424 // TODO(smbarber): This needs to be populated with the actual device type
418 BluetoothPropertyPtr btp = BluetoothProperty::New(); 425 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
419 btp->set_device_type(BluetoothDeviceType::DUAL); 426 btp->set_device_type(mojom::BluetoothDeviceType::DUAL);
420 properties.push_back(std::move(btp)); 427 properties.push_back(std::move(btp));
421 } 428 }
422 if (type == BluetoothPropertyType::ALL || 429 if (type == mojom::BluetoothPropertyType::ALL ||
423 type == BluetoothPropertyType::REMOTE_FRIENDLY_NAME) { 430 type == mojom::BluetoothPropertyType::REMOTE_FRIENDLY_NAME) {
424 BluetoothPropertyPtr btp = BluetoothProperty::New(); 431 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
425 btp->set_bdname(mojo::String::From(base::UTF16ToUTF8(device->GetName()))); 432 btp->set_bdname(mojo::String::From(base::UTF16ToUTF8(device->GetName())));
426 properties.push_back(std::move(btp)); 433 properties.push_back(std::move(btp));
427 } 434 }
428 if (type == BluetoothPropertyType::ALL || 435 if (type == mojom::BluetoothPropertyType::ALL ||
429 type == BluetoothPropertyType::REMOTE_RSSI) { 436 type == mojom::BluetoothPropertyType::REMOTE_RSSI) {
430 BluetoothPropertyPtr btp = BluetoothProperty::New(); 437 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
431 btp->set_remote_rssi(device->GetInquiryRSSI()); 438 btp->set_remote_rssi(device->GetInquiryRSSI());
432 properties.push_back(std::move(btp)); 439 properties.push_back(std::move(btp));
433 } 440 }
434 // TODO(smbarber): Add remote version info 441 // TODO(smbarber): Add remote version info
435 442
436 return properties; 443 return properties;
437 } 444 }
438 445
439 mojo::Array<BluetoothPropertyPtr> ArcBluetoothBridge::GetAdapterProperties( 446 mojo::Array<mojom::BluetoothPropertyPtr>
440 BluetoothPropertyType type) { 447 ArcBluetoothBridge::GetAdapterProperties(mojom::BluetoothPropertyType type) {
441 mojo::Array<BluetoothPropertyPtr> properties; 448 mojo::Array<mojom::BluetoothPropertyPtr> properties;
442 449
443 if (type == BluetoothPropertyType::ALL || 450 if (type == mojom::BluetoothPropertyType::ALL ||
444 type == BluetoothPropertyType::BDNAME) { 451 type == mojom::BluetoothPropertyType::BDNAME) {
445 BluetoothPropertyPtr btp = BluetoothProperty::New(); 452 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
446 std::string name = bluetooth_adapter_->GetName(); 453 std::string name = bluetooth_adapter_->GetName();
447 btp->set_bdname(mojo::String(name)); 454 btp->set_bdname(mojo::String(name));
448 properties.push_back(std::move(btp)); 455 properties.push_back(std::move(btp));
449 } 456 }
450 if (type == BluetoothPropertyType::ALL || 457 if (type == mojom::BluetoothPropertyType::ALL ||
451 type == BluetoothPropertyType::BDADDR) { 458 type == mojom::BluetoothPropertyType::BDADDR) {
452 BluetoothPropertyPtr btp = BluetoothProperty::New(); 459 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
453 btp->set_bdaddr(BluetoothAddress::From(bluetooth_adapter_->GetAddress())); 460 btp->set_bdaddr(
461 mojom::BluetoothAddress::From(bluetooth_adapter_->GetAddress()));
454 properties.push_back(std::move(btp)); 462 properties.push_back(std::move(btp));
455 } 463 }
456 if (type == BluetoothPropertyType::ALL || 464 if (type == mojom::BluetoothPropertyType::ALL ||
457 type == BluetoothPropertyType::UUIDS) { 465 type == mojom::BluetoothPropertyType::UUIDS) {
458 // TODO(smbarber): Fill in once GetUUIDs is available for the adapter. 466 // TODO(smbarber): Fill in once GetUUIDs is available for the adapter.
459 } 467 }
460 if (type == BluetoothPropertyType::ALL || 468 if (type == mojom::BluetoothPropertyType::ALL ||
461 type == BluetoothPropertyType::CLASS_OF_DEVICE) { 469 type == mojom::BluetoothPropertyType::CLASS_OF_DEVICE) {
462 // TODO(smbarber): Populate with the actual adapter class 470 // TODO(smbarber): Populate with the actual adapter class
463 BluetoothPropertyPtr btp = BluetoothProperty::New(); 471 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
464 btp->set_device_class(0); 472 btp->set_device_class(0);
465 properties.push_back(std::move(btp)); 473 properties.push_back(std::move(btp));
466 } 474 }
467 if (type == BluetoothPropertyType::ALL || 475 if (type == mojom::BluetoothPropertyType::ALL ||
468 type == BluetoothPropertyType::TYPE_OF_DEVICE) { 476 type == mojom::BluetoothPropertyType::TYPE_OF_DEVICE) {
469 // TODO(smbarber): Populate with the actual device type 477 // TODO(smbarber): Populate with the actual device type
470 BluetoothPropertyPtr btp = BluetoothProperty::New(); 478 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
471 btp->set_device_type(BluetoothDeviceType::DUAL); 479 btp->set_device_type(mojom::BluetoothDeviceType::DUAL);
472 properties.push_back(std::move(btp)); 480 properties.push_back(std::move(btp));
473 } 481 }
474 if (type == BluetoothPropertyType::ALL || 482 if (type == mojom::BluetoothPropertyType::ALL ||
475 type == BluetoothPropertyType::ADAPTER_SCAN_MODE) { 483 type == mojom::BluetoothPropertyType::ADAPTER_SCAN_MODE) {
476 BluetoothPropertyPtr btp = BluetoothProperty::New(); 484 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
477 BluetoothScanMode scan_mode = BluetoothScanMode::CONNECTABLE; 485 mojom::BluetoothScanMode scan_mode = mojom::BluetoothScanMode::CONNECTABLE;
478 486
479 if (bluetooth_adapter_->IsDiscoverable()) 487 if (bluetooth_adapter_->IsDiscoverable())
480 scan_mode = BluetoothScanMode::CONNECTABLE_DISCOVERABLE; 488 scan_mode = mojom::BluetoothScanMode::CONNECTABLE_DISCOVERABLE;
481 489
482 btp->set_adapter_scan_mode(scan_mode); 490 btp->set_adapter_scan_mode(scan_mode);
483 properties.push_back(std::move(btp)); 491 properties.push_back(std::move(btp));
484 } 492 }
485 if (type == BluetoothPropertyType::ALL || 493 if (type == mojom::BluetoothPropertyType::ALL ||
486 type == BluetoothPropertyType::ADAPTER_BONDED_DEVICES) { 494 type == mojom::BluetoothPropertyType::ADAPTER_BONDED_DEVICES) {
487 BluetoothPropertyPtr btp = BluetoothProperty::New(); 495 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
488 BluetoothAdapter::DeviceList devices = bluetooth_adapter_->GetDevices(); 496 BluetoothAdapter::DeviceList devices = bluetooth_adapter_->GetDevices();
489 497
490 mojo::Array<BluetoothAddressPtr> bonded_devices = 498 mojo::Array<mojom::BluetoothAddressPtr> bonded_devices =
491 mojo::Array<BluetoothAddressPtr>::New(0); 499 mojo::Array<mojom::BluetoothAddressPtr>::New(0);
492 500
493 for (size_t i = 0; i < devices.size(); i++) { 501 for (size_t i = 0; i < devices.size(); i++) {
494 if (!devices[i]->IsPaired()) 502 if (!devices[i]->IsPaired())
495 continue; 503 continue;
496 504
497 BluetoothAddressPtr addr = 505 mojom::BluetoothAddressPtr addr =
498 BluetoothAddress::From(devices[i]->GetAddress()); 506 mojom::BluetoothAddress::From(devices[i]->GetAddress());
499 bonded_devices.push_back(std::move(addr)); 507 bonded_devices.push_back(std::move(addr));
500 } 508 }
501 509
502 btp->set_bonded_devices(std::move(bonded_devices)); 510 btp->set_bonded_devices(std::move(bonded_devices));
503 properties.push_back(std::move(btp)); 511 properties.push_back(std::move(btp));
504 } 512 }
505 if (type == BluetoothPropertyType::ALL || 513 if (type == mojom::BluetoothPropertyType::ALL ||
506 type == BluetoothPropertyType::ADAPTER_DISCOVERY_TIMEOUT) { 514 type == mojom::BluetoothPropertyType::ADAPTER_DISCOVERY_TIMEOUT) {
507 BluetoothPropertyPtr btp = BluetoothProperty::New(); 515 mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New();
508 btp->set_discovery_timeout(120); 516 btp->set_discovery_timeout(120);
509 properties.push_back(std::move(btp)); 517 properties.push_back(std::move(btp));
510 } 518 }
511 519
512 return properties; 520 return properties;
513 } 521 }
514 522
515 void ArcBluetoothBridge::SendCachedDevicesFound() { 523 void ArcBluetoothBridge::SendCachedDevicesFound() {
516 // Send devices that have already been discovered, but aren't connected. 524 // Send devices that have already been discovered, but aren't connected.
517 if (!HasBluetoothInstance()) 525 if (!HasBluetoothInstance())
518 return; 526 return;
519 527
520 BluetoothAdapter::DeviceList devices = bluetooth_adapter_->GetDevices(); 528 BluetoothAdapter::DeviceList devices = bluetooth_adapter_->GetDevices();
521 for (size_t i = 0; i < devices.size(); i++) { 529 for (size_t i = 0; i < devices.size(); i++) {
522 if (devices[i]->IsPaired()) 530 if (devices[i]->IsPaired())
523 continue; 531 continue;
524 532
525 mojo::Array<BluetoothPropertyPtr> properties = 533 mojo::Array<mojom::BluetoothPropertyPtr> properties =
526 GetDeviceProperties(BluetoothPropertyType::ALL, devices[i]); 534 GetDeviceProperties(mojom::BluetoothPropertyType::ALL, devices[i]);
527 535
528 arc_bridge_service()->bluetooth_instance()->OnDeviceFound( 536 arc_bridge_service()->bluetooth_instance()->OnDeviceFound(
529 std::move(properties)); 537 std::move(properties));
530 } 538 }
531 } 539 }
532 540
533 bool ArcBluetoothBridge::HasBluetoothInstance() { 541 bool ArcBluetoothBridge::HasBluetoothInstance() {
534 if (!arc_bridge_service()->bluetooth_instance()) { 542 if (!arc_bridge_service()->bluetooth_instance()) {
535 LOG(WARNING) << "no Bluetooth instance available"; 543 LOG(WARNING) << "no Bluetooth instance available";
536 return false; 544 return false;
537 } 545 }
538 546
539 return true; 547 return true;
540 } 548 }
541 549
542 } // namespace arc 550 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698