OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "device/bluetooth/bluetooth_device_chromeos.h" | 5 #include "device/bluetooth/bluetooth_device_chromeos.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 | 425 |
426 void BluetoothDeviceChromeOS::ConnectToService( | 426 void BluetoothDeviceChromeOS::ConnectToService( |
427 const BluetoothUUID& uuid, | 427 const BluetoothUUID& uuid, |
428 const ConnectToServiceCallback& callback, | 428 const ConnectToServiceCallback& callback, |
429 const ConnectToServiceErrorCallback& error_callback) { | 429 const ConnectToServiceErrorCallback& error_callback) { |
430 VLOG(1) << object_path_.value() << ": Connecting to service: " | 430 VLOG(1) << object_path_.value() << ": Connecting to service: " |
431 << uuid.canonical_value(); | 431 << uuid.canonical_value(); |
432 scoped_refptr<BluetoothSocketChromeOS> socket = | 432 scoped_refptr<BluetoothSocketChromeOS> socket = |
433 BluetoothSocketChromeOS::CreateBluetoothSocket( | 433 BluetoothSocketChromeOS::CreateBluetoothSocket( |
434 ui_task_runner_, socket_thread_); | 434 ui_task_runner_, socket_thread_); |
435 socket->Connect(this, uuid, base::Bind(callback, socket), error_callback); | 435 socket->Connect(this, uuid, BluetoothSocketChromeOS::SECURITY_LEVEL_MEDIUM, |
| 436 base::Bind(callback, socket), error_callback); |
| 437 } |
| 438 |
| 439 void BluetoothDeviceChromeOS::ConnectToServiceInsecurely( |
| 440 const BluetoothUUID& uuid, |
| 441 const ConnectToServiceCallback& callback, |
| 442 const ConnectToServiceErrorCallback& error_callback) { |
| 443 VLOG(1) << object_path_.value() << ": Connecting insecurely to service: " |
| 444 << uuid.canonical_value(); |
| 445 scoped_refptr<BluetoothSocketChromeOS> socket = |
| 446 BluetoothSocketChromeOS::CreateBluetoothSocket( |
| 447 ui_task_runner_, socket_thread_); |
| 448 socket->Connect(this, uuid, BluetoothSocketChromeOS::SECURITY_LEVEL_LOW, |
| 449 base::Bind(callback, socket), error_callback); |
436 } | 450 } |
437 | 451 |
438 void BluetoothDeviceChromeOS::CreateGattConnection( | 452 void BluetoothDeviceChromeOS::CreateGattConnection( |
439 const GattConnectionCallback& callback, | 453 const GattConnectionCallback& callback, |
440 const ConnectErrorCallback& error_callback) { | 454 const ConnectErrorCallback& error_callback) { |
441 // TODO(armansito): Until there is a way to create a reference counted GATT | 455 // TODO(armansito): Until there is a way to create a reference counted GATT |
442 // connection in bluetoothd, simply do a regular connect. | 456 // connection in bluetoothd, simply do a regular connect. |
443 Connect(NULL, | 457 Connect(NULL, |
444 base::Bind(&BluetoothDeviceChromeOS::OnCreateGattConnection, | 458 base::Bind(&BluetoothDeviceChromeOS::OnCreateGattConnection, |
445 weak_ptr_factory_.GetWeakPtr(), | 459 weak_ptr_factory_.GetWeakPtr(), |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 void BluetoothDeviceChromeOS::OnForgetError( | 714 void BluetoothDeviceChromeOS::OnForgetError( |
701 const ErrorCallback& error_callback, | 715 const ErrorCallback& error_callback, |
702 const std::string& error_name, | 716 const std::string& error_name, |
703 const std::string& error_message) { | 717 const std::string& error_message) { |
704 LOG(WARNING) << object_path_.value() << ": Failed to remove device: " | 718 LOG(WARNING) << object_path_.value() << ": Failed to remove device: " |
705 << error_name << ": " << error_message; | 719 << error_name << ": " << error_message; |
706 error_callback.Run(); | 720 error_callback.Run(); |
707 } | 721 } |
708 | 722 |
709 } // namespace chromeos | 723 } // namespace chromeos |
OLD | NEW |