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

Unified Diff: chrome/browser/chromeos/bluetooth/bluetooth_device_chromeos.cc

Issue 10899037: Refactoring bluetooth API code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename to BluetoothAdapterChromeOs Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/bluetooth/bluetooth_device_chromeos.cc
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_device.cc b/chrome/browser/chromeos/bluetooth/bluetooth_device_chromeos.cc
similarity index 65%
copy from chrome/browser/chromeos/bluetooth/bluetooth_device.cc
copy to chrome/browser/chromeos/bluetooth/bluetooth_device_chromeos.cc
index ba19dc58e703c48d4eca56faae4fe98529191128..e19ba340f69b6aeb13ceab1a0454891c64e06d32 100644
--- a/chrome/browser/chromeos/bluetooth/bluetooth_device.cc
+++ b/chrome/browser/chromeos/bluetooth/bluetooth_device_chromeos.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/chromeos/bluetooth/bluetooth_device.h"
+#include "chrome/browser/chromeos/bluetooth/bluetooth_device_chromeos.h"
#include <map>
#include <string>
@@ -17,9 +17,9 @@
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h"
+#include "chrome/browser/chromeos/bluetooth/bluetooth_adapter_chromeos.h"
#include "chrome/browser/chromeos/bluetooth/bluetooth_service_record.h"
-#include "chrome/browser/chromeos/bluetooth/bluetooth_socket.h"
+#include "chrome/browser/chromeos/bluetooth/bluetooth_socket_chromeos.h"
#include "chrome/browser/chromeos/bluetooth/bluetooth_utils.h"
#include "chrome/common/chrome_switches.h"
#include "chromeos/dbus/bluetooth_adapter_client.h"
@@ -27,6 +27,7 @@
#include "chromeos/dbus/bluetooth_device_client.h"
#include "chromeos/dbus/bluetooth_input_client.h"
#include "chromeos/dbus/bluetooth_out_of_band_client.h"
+#include "chromeos/dbus/bluetooth_out_of_band_pairing_data.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/introspectable_client.h"
#include "dbus/bus.h"
@@ -37,9 +38,10 @@
namespace chromeos {
-BluetoothDevice::BluetoothDevice(BluetoothAdapter* adapter)
- : adapter_(adapter),
- bluetooth_class_(0),
+BluetoothDeviceChromeOs::BluetoothDeviceChromeOs(
+ BluetoothAdapterChromeOs* adapter)
+ : BluetoothDevice(),
+ adapter_(adapter),
visible_(false),
bonded_(false),
connected_(false),
@@ -48,12 +50,12 @@ BluetoothDevice::BluetoothDevice(BluetoothAdapter* adapter)
weak_ptr_factory_(this) {
}
-BluetoothDevice::~BluetoothDevice() {
+BluetoothDeviceChromeOs::~BluetoothDeviceChromeOs() {
}
-const std::string& BluetoothDevice::address() const { return address_; }
+const std::string& BluetoothDeviceChromeOs::address() const { return address_; }
-string16 BluetoothDevice::GetName() const {
+string16 BluetoothDeviceChromeOs::GetName() const {
if (!name_.empty()) {
return UTF8ToUTF16(name_);
} else {
@@ -61,69 +63,10 @@ string16 BluetoothDevice::GetName() const {
}
}
keybuk 2012/09/17 22:19:43 should move up to BluetoothDevice since it'll be t
youngki 2012/09/18 18:19:56 Done.
-BluetoothDevice::DeviceType BluetoothDevice::GetDeviceType() const {
- // https://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm
- switch ((bluetooth_class_ & 0x1f00) >> 8) {
- case 0x01:
- // Computer major device class.
- return DEVICE_COMPUTER;
- case 0x02:
- // Phone major device class.
- switch ((bluetooth_class_ & 0xfc) >> 2) {
- case 0x01:
- case 0x02:
- case 0x03:
- // Cellular, cordless and smart phones.
- return DEVICE_PHONE;
- case 0x04:
- case 0x05:
- // Modems: wired or voice gateway and common ISDN access.
- return DEVICE_MODEM;
- }
- break;
- case 0x05:
- // Peripheral major device class.
- switch ((bluetooth_class_ & 0xc0) >> 6) {
- case 0x00:
- // "Not a keyboard or pointing device."
- switch ((bluetooth_class_ & 0x01e) >> 2) {
- case 0x01:
- // Joystick.
- return DEVICE_JOYSTICK;
- case 0x02:
- // Gamepad.
- return DEVICE_GAMEPAD;
- default:
- return DEVICE_PERIPHERAL;
- }
- break;
- case 0x01:
- // Keyboard.
- return DEVICE_KEYBOARD;
- case 0x02:
- // Pointing device.
- switch ((bluetooth_class_ & 0x01e) >> 2) {
- case 0x05:
- // Digitizer tablet.
- return DEVICE_TABLET;
- default:
- // Mouse.
- return DEVICE_MOUSE;
- }
- break;
- case 0x03:
- // Combo device.
- return DEVICE_KEYBOARD_MOUSE_COMBO;
- }
- break;
- }
-
- return DEVICE_UNKNOWN;
-}
-
-string16 BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() const {
+string16
+BluetoothDeviceChromeOs::GetAddressWithLocalizedDeviceTypeName() const {
string16 address = UTF8ToUTF16(address_);
- DeviceType device_type = GetDeviceType();
+ BluetoothDevice::DeviceType device_type = GetDeviceType();
switch (device_type) {
case DEVICE_COMPUTER:
return l10n_util::GetStringFUTF16(IDS_BLUETOOTH_DEVICE_COMPUTER,
@@ -157,12 +100,12 @@ string16 BluetoothDevice::GetAddressWithLocalizedDeviceTypeName() const {
}
}
keybuk 2012/09/17 22:19:43 I'm tempted to say that this should move up into B
youngki 2012/09/18 18:19:56 Done.
-bool BluetoothDevice::IsSupported() const {
+bool BluetoothDeviceChromeOs::IsSupported() const {
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableUnsupportedBluetoothDevices))
return true;
- DeviceType device_type = GetDeviceType();
+ BluetoothDevice::DeviceType device_type = GetDeviceType();
return (device_type == DEVICE_JOYSTICK ||
device_type == DEVICE_GAMEPAD ||
device_type == DEVICE_KEYBOARD ||
@@ -171,52 +114,66 @@ bool BluetoothDevice::IsSupported() const {
device_type == DEVICE_KEYBOARD_MOUSE_COMBO);
}
keybuk 2012/09/17 22:19:43 this should stay in BluetoothDeviceChromeOs
youngki 2012/09/18 18:19:56 Yep IsSupported() is already Chrome OS specific.
-bool BluetoothDevice::IsPaired() const { return !object_path_.value().empty(); }
+bool BluetoothDeviceChromeOs::IsPaired() const {
+ return !object_path_.value().empty();
+}
-bool BluetoothDevice::IsBonded() const { return bonded_; }
+bool BluetoothDeviceChromeOs::IsBonded() const { return bonded_; }
-bool BluetoothDevice::IsConnected() const {
+bool BluetoothDeviceChromeOs::IsConnected() const {
// TODO(keybuk): examine protocol-specific connected state, such as Input
return connected_;
}
keybuk 2012/09/17 22:19:43 Can we not move all these up into BluetoothDevice?
youngki 2012/09/18 18:19:56 Moved IsVisible(), IsBonded(), and IsConnected() t
-void BluetoothDevice::GetServiceRecords(const ServiceRecordsCallback& callback,
- const ErrorCallback& error_callback) {
+void BluetoothDeviceChromeOs::GetServiceRecords(
+ const ServiceRecordsCallback& callback,
+ const ErrorCallback& error_callback) {
DBusThreadManager::Get()->GetBluetoothDeviceClient()->
DiscoverServices(
object_path_,
"", // empty pattern to browse all services
- base::Bind(&BluetoothDevice::CollectServiceRecordsCallback,
+ base::Bind(&BluetoothDeviceChromeOs::CollectServiceRecordsCallback,
weak_ptr_factory_.GetWeakPtr(),
callback,
error_callback));
}
-bool BluetoothDevice::ProvidesServiceWithUUID(const std::string& uuid) const {
- const BluetoothDevice::ServiceList& services = GetServices();
- for (BluetoothDevice::ServiceList::const_iterator iter = services.begin();
- iter != services.end(); ++iter) {
+bool BluetoothDeviceChromeOs::ProvidesServiceWithUUID(
+ const std::string& uuid) const {
+ const BluetoothDeviceChromeOs::ServiceList& services = GetServices();
+ for (BluetoothDeviceChromeOs::ServiceList::const_iterator iter =
+ services.begin();
+ iter != services.end(); ++iter) {
if (bluetooth_utils::CanonicalUuid(*iter) == uuid)
return true;
}
return false;
}
-void BluetoothDevice::ProvidesServiceWithName(const std::string& name,
+void BluetoothDeviceChromeOs::ProvidesServiceWithName(
+ const std::string& name,
const ProvidesServiceCallback& callback) {
GetServiceRecords(
- base::Bind(&BluetoothDevice::SearchServicesForNameCallback,
+ base::Bind(&BluetoothDeviceChromeOs::SearchServicesForNameCallback,
weak_ptr_factory_.GetWeakPtr(),
name,
callback),
- base::Bind(&BluetoothDevice::SearchServicesForNameErrorCallback,
+ base::Bind(&BluetoothDeviceChromeOs::SearchServicesForNameErrorCallback,
weak_ptr_factory_.GetWeakPtr(),
callback));
}
-void BluetoothDevice::Connect(PairingDelegate* pairing_delegate,
- const base::Closure& callback,
- const ErrorCallback& error_callback) {
+bool BluetoothDeviceChromeOs::ExpectingPinCode() const {
+ return !pincode_callback_.is_null();
+}
+
+bool BluetoothDeviceChromeOs::ExpectingPasskey() const {
+ return !passkey_callback_.is_null();
+}
+
+void BluetoothDeviceChromeOs::Connect(PairingDelegate* pairing_delegate,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
if (IsPaired() || IsBonded() || IsConnected()) {
// Connection to already paired or connected device.
ConnectApplications(callback, error_callback);
@@ -226,11 +183,11 @@ void BluetoothDevice::Connect(PairingDelegate* pairing_delegate,
DBusThreadManager::Get()->GetBluetoothAdapterClient()->
CreateDevice(adapter_->object_path_,
address_,
- base::Bind(&BluetoothDevice::ConnectCallback,
+ base::Bind(&BluetoothDeviceChromeOs::ConnectCallback,
weak_ptr_factory_.GetWeakPtr(),
callback,
error_callback),
- base::Bind(&BluetoothDevice::ConnectErrorCallback,
+ base::Bind(&BluetoothDeviceChromeOs::ConnectErrorCallback,
weak_ptr_factory_.GetWeakPtr(),
error_callback));
} else {
@@ -259,21 +216,22 @@ void BluetoothDevice::Connect(PairingDelegate* pairing_delegate,
DVLOG(1) << "Pairing: " << address_;
DBusThreadManager::Get()->GetBluetoothAdapterClient()->
- CreatePairedDevice(adapter_->object_path_,
- address_,
- agent_path,
- bluetooth_agent::kDisplayYesNoCapability,
- base::Bind(&BluetoothDevice::ConnectCallback,
- weak_ptr_factory_.GetWeakPtr(),
- callback,
- error_callback),
- base::Bind(&BluetoothDevice::ConnectErrorCallback,
- weak_ptr_factory_.GetWeakPtr(),
- error_callback));
+ CreatePairedDevice(
+ adapter_->object_path_,
+ address_,
+ agent_path,
+ bluetooth_agent::kDisplayYesNoCapability,
+ base::Bind(&BluetoothDeviceChromeOs::ConnectCallback,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback,
+ error_callback),
+ base::Bind(&BluetoothDeviceChromeOs::ConnectErrorCallback,
+ weak_ptr_factory_.GetWeakPtr(),
+ error_callback));
}
}
-void BluetoothDevice::SetPinCode(const std::string& pincode) {
+void BluetoothDeviceChromeOs::SetPinCode(const std::string& pincode) {
if (!agent_.get() || pincode_callback_.is_null())
return;
@@ -281,7 +239,7 @@ void BluetoothDevice::SetPinCode(const std::string& pincode) {
pincode_callback_.Reset();
}
-void BluetoothDevice::SetPasskey(uint32 passkey) {
+void BluetoothDeviceChromeOs::SetPasskey(uint32 passkey) {
if (!agent_.get() || passkey_callback_.is_null())
return;
@@ -289,7 +247,7 @@ void BluetoothDevice::SetPasskey(uint32 passkey) {
passkey_callback_.Reset();
}
-void BluetoothDevice::ConfirmPairing() {
+void BluetoothDeviceChromeOs::ConfirmPairing() {
if (!agent_.get() || confirmation_callback_.is_null())
return;
@@ -297,7 +255,7 @@ void BluetoothDevice::ConfirmPairing() {
confirmation_callback_.Reset();
}
-void BluetoothDevice::RejectPairing() {
+void BluetoothDeviceChromeOs::RejectPairing() {
if (!agent_.get())
return;
@@ -315,7 +273,7 @@ void BluetoothDevice::RejectPairing() {
}
}
-void BluetoothDevice::CancelPairing() {
+void BluetoothDeviceChromeOs::CancelPairing() {
if (!agent_.get())
return;
@@ -333,39 +291,40 @@ void BluetoothDevice::CancelPairing() {
}
}
-void BluetoothDevice::Disconnect(const base::Closure& callback,
- const ErrorCallback& error_callback) {
+void BluetoothDeviceChromeOs::Disconnect(const base::Closure& callback,
+ const ErrorCallback& error_callback) {
DBusThreadManager::Get()->GetBluetoothDeviceClient()->
Disconnect(object_path_,
- base::Bind(&BluetoothDevice::DisconnectCallback,
+ base::Bind(&BluetoothDeviceChromeOs::DisconnectCallback,
weak_ptr_factory_.GetWeakPtr(),
callback,
error_callback));
}
-void BluetoothDevice::Forget(const ErrorCallback& error_callback) {
+void BluetoothDeviceChromeOs::Forget(const ErrorCallback& error_callback) {
DBusThreadManager::Get()->GetBluetoothAdapterClient()->
RemoveDevice(adapter_->object_path_,
object_path_,
- base::Bind(&BluetoothDevice::ForgetCallback,
+ base::Bind(&BluetoothDeviceChromeOs::ForgetCallback,
weak_ptr_factory_.GetWeakPtr(),
error_callback));
}
-void BluetoothDevice::ConnectToService(const std::string& service_uuid,
- const SocketCallback& callback) {
+void BluetoothDeviceChromeOs::ConnectToService(const std::string& service_uuid,
+ const SocketCallback& callback) {
GetServiceRecords(
- base::Bind(&BluetoothDevice::GetServiceRecordsForConnectCallback,
+ base::Bind(&BluetoothDeviceChromeOs::GetServiceRecordsForConnectCallback,
weak_ptr_factory_.GetWeakPtr(),
service_uuid,
callback),
- base::Bind(&BluetoothDevice::GetServiceRecordsForConnectErrorCallback,
- weak_ptr_factory_.GetWeakPtr(),
- callback));
+ base::Bind(
+ &BluetoothDeviceChromeOs::GetServiceRecordsForConnectErrorCallback,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback));
}
-void BluetoothDevice::SetOutOfBandPairingData(
+void BluetoothDeviceChromeOs::SetOutOfBandPairingData(
const chromeos::BluetoothOutOfBandPairingData& data,
const base::Closure& callback,
const ErrorCallback& error_callback) {
@@ -374,36 +333,37 @@ void BluetoothDevice::SetOutOfBandPairingData(
object_path_,
address(),
data,
- base::Bind(&BluetoothDevice::OnRemoteDataCallback,
- weak_ptr_factory_.GetWeakPtr(),
- callback,
- error_callback));
+ base::Bind(&BluetoothDeviceChromeOs::OnRemoteDataCallback,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback,
+ error_callback));
}
-void BluetoothDevice::ClearOutOfBandPairingData(
+void BluetoothDeviceChromeOs::ClearOutOfBandPairingData(
const base::Closure& callback,
const ErrorCallback& error_callback) {
DBusThreadManager::Get()->GetBluetoothOutOfBandClient()->
RemoveRemoteData(
object_path_,
address(),
- base::Bind(&BluetoothDevice::OnRemoteDataCallback,
- weak_ptr_factory_.GetWeakPtr(),
- callback,
- error_callback));
+ base::Bind(&BluetoothDeviceChromeOs::OnRemoteDataCallback,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback,
+ error_callback));
}
-void BluetoothDevice::SetObjectPath(const dbus::ObjectPath& object_path) {
+void BluetoothDeviceChromeOs::SetObjectPath(
+ const dbus::ObjectPath& object_path) {
DCHECK(object_path_ == dbus::ObjectPath(""));
object_path_ = object_path;
}
-void BluetoothDevice::RemoveObjectPath() {
+void BluetoothDeviceChromeOs::RemoveObjectPath() {
DCHECK(object_path_ != dbus::ObjectPath(""));
object_path_ = dbus::ObjectPath("");
}
-void BluetoothDevice::Update(
+void BluetoothDeviceChromeOs::Update(
const BluetoothDeviceClient::Properties* properties,
bool update_state) {
std::string address = properties->address.value();
@@ -430,9 +390,10 @@ void BluetoothDevice::Update(
}
}
-void BluetoothDevice::ConnectCallback(const base::Closure& callback,
- const ErrorCallback& error_callback,
- const dbus::ObjectPath& device_path) {
+void BluetoothDeviceChromeOs::ConnectCallback(
+ const base::Closure& callback,
+ const ErrorCallback& error_callback,
+ const dbus::ObjectPath& device_path) {
DVLOG(1) << "Connection successful: " << device_path.value();
if (object_path_.value().empty()) {
object_path_ = device_path;
@@ -451,7 +412,7 @@ void BluetoothDevice::ConnectCallback(const base::Closure& callback,
DBusThreadManager::Get()->GetBluetoothDeviceClient()->
GetProperties(object_path_)->trusted.Set(
true,
- base::Bind(&BluetoothDevice::OnSetTrusted,
+ base::Bind(&BluetoothDeviceChromeOs::OnSetTrusted,
weak_ptr_factory_.GetWeakPtr(),
callback,
error_callback));
@@ -460,15 +421,16 @@ void BluetoothDevice::ConnectCallback(const base::Closure& callback,
ConnectApplications(callback, error_callback);
}
-void BluetoothDevice::ConnectErrorCallback(const ErrorCallback& error_callback,
- const std::string& error_name,
- const std::string& error_message) {
+void BluetoothDeviceChromeOs::ConnectErrorCallback(
+ const ErrorCallback& error_callback,
+ const std::string& error_name,
+ const std::string& error_message) {
LOG(WARNING) << "Connection failed: " << address_
<< ": " << error_name << ": " << error_message;
error_callback.Run();
}
-void BluetoothDevice::CollectServiceRecordsCallback(
+void BluetoothDeviceChromeOs::CollectServiceRecordsCallback(
const ServiceRecordsCallback& callback,
const ErrorCallback& error_callback,
const dbus::ObjectPath& device_path,
@@ -488,9 +450,9 @@ void BluetoothDevice::CollectServiceRecordsCallback(
callback.Run(records);
}
-void BluetoothDevice::OnSetTrusted(const base::Closure& callback,
- const ErrorCallback& error_callback,
- bool success) {
+void BluetoothDeviceChromeOs::OnSetTrusted(const base::Closure& callback,
+ const ErrorCallback& error_callback,
+ bool success) {
if (success) {
callback.Run();
} else {
@@ -499,24 +461,25 @@ void BluetoothDevice::OnSetTrusted(const base::Closure& callback,
}
}
-void BluetoothDevice::ConnectApplications(const base::Closure& callback,
- const ErrorCallback& error_callback) {
+void BluetoothDeviceChromeOs::ConnectApplications(
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
// Introspect the device object to determine supported applications.
DBusThreadManager::Get()->GetIntrospectableClient()->
Introspect(bluetooth_device::kBluetoothDeviceServiceName,
object_path_,
- base::Bind(&BluetoothDevice::OnIntrospect,
+ base::Bind(&BluetoothDeviceChromeOs::OnIntrospect,
weak_ptr_factory_.GetWeakPtr(),
callback,
error_callback));
}
-void BluetoothDevice::OnIntrospect(const base::Closure& callback,
- const ErrorCallback& error_callback,
- const std::string& service_name,
- const dbus::ObjectPath& device_path,
- const std::string& xml_data,
- bool success) {
+void BluetoothDeviceChromeOs::OnIntrospect(const base::Closure& callback,
+ const ErrorCallback& error_callback,
+ const std::string& service_name,
+ const dbus::ObjectPath& device_path,
+ const std::string& xml_data,
+ bool success) {
if (!success) {
LOG(WARNING) << "Failed to determine supported applications: " << address_;
error_callback.Run();
@@ -539,11 +502,11 @@ void BluetoothDevice::OnIntrospect(const base::Closure& callback,
// Supports Input interface.
DBusThreadManager::Get()->GetBluetoothInputClient()->
Connect(object_path_,
- base::Bind(&BluetoothDevice::OnConnect,
+ base::Bind(&BluetoothDeviceChromeOs::OnConnect,
weak_ptr_factory_.GetWeakPtr(),
callback,
*iter),
- base::Bind(&BluetoothDevice::OnConnectError,
+ base::Bind(&BluetoothDeviceChromeOs::OnConnectError,
weak_ptr_factory_.GetWeakPtr(),
error_callback, *iter));
}
@@ -558,9 +521,9 @@ void BluetoothDevice::OnIntrospect(const base::Closure& callback,
callback.Run();
}
-void BluetoothDevice::OnConnect(const base::Closure& callback,
- const std::string& interface_name,
- const dbus::ObjectPath& device_path) {
+void BluetoothDeviceChromeOs::OnConnect(const base::Closure& callback,
+ const std::string& interface_name,
+ const dbus::ObjectPath& device_path) {
DVLOG(1) << "Application connection successful: " << device_path.value()
<< ": " << interface_name;
@@ -576,20 +539,22 @@ void BluetoothDevice::OnConnect(const base::Closure& callback,
}
}
-void BluetoothDevice::OnConnectError(const ErrorCallback& error_callback,
- const std::string& interface_name,
- const dbus::ObjectPath& device_path,
- const std::string& error_name,
- const std::string& error_message) {
+void BluetoothDeviceChromeOs::OnConnectError(
+ const ErrorCallback& error_callback,
+ const std::string& interface_name,
+ const dbus::ObjectPath& device_path,
+ const std::string& error_name,
+ const std::string& error_message) {
LOG(WARNING) << "Connection failed: " << address_ << ": " << interface_name
<< ": " << error_name << ": " << error_message;
error_callback.Run();
}
-void BluetoothDevice::DisconnectCallback(const base::Closure& callback,
- const ErrorCallback& error_callback,
- const dbus::ObjectPath& device_path,
- bool success) {
+void BluetoothDeviceChromeOs::DisconnectCallback(
+ const base::Closure& callback,
+ const ErrorCallback& error_callback,
+ const dbus::ObjectPath& device_path,
+ bool success) {
DCHECK(device_path == object_path_);
if (success) {
DVLOG(1) << "Disconnection successful: " << address_;
@@ -600,9 +565,10 @@ void BluetoothDevice::DisconnectCallback(const base::Closure& callback,
}
}
-void BluetoothDevice::ForgetCallback(const ErrorCallback& error_callback,
- const dbus::ObjectPath& adapter_path,
- bool success) {
+void BluetoothDeviceChromeOs::ForgetCallback(
+ const ErrorCallback& error_callback,
+ const dbus::ObjectPath& adapter_path,
+ bool success) {
// It's quite normal that this path never gets called on success; we use a
// weak pointer, and bluetoothd might send the DeviceRemoved signal before
// the method reply, in which case this object is deleted and the
@@ -614,12 +580,12 @@ void BluetoothDevice::ForgetCallback(const ErrorCallback& error_callback,
}
}
-void BluetoothDevice::SearchServicesForNameErrorCallback(
+void BluetoothDeviceChromeOs::SearchServicesForNameErrorCallback(
const ProvidesServiceCallback& callback) {
callback.Run(false);
}
-void BluetoothDevice::SearchServicesForNameCallback(
+void BluetoothDeviceChromeOs::SearchServicesForNameCallback(
const std::string& name,
const ProvidesServiceCallback& callback,
const ServiceRecordList& list) {
@@ -633,12 +599,12 @@ void BluetoothDevice::SearchServicesForNameCallback(
callback.Run(false);
}
-void BluetoothDevice::GetServiceRecordsForConnectErrorCallback(
+void BluetoothDeviceChromeOs::GetServiceRecordsForConnectErrorCallback(
const SocketCallback& callback) {
callback.Run(NULL);
}
-void BluetoothDevice::GetServiceRecordsForConnectCallback(
+void BluetoothDeviceChromeOs::GetServiceRecordsForConnectCallback(
const std::string& service_uuid,
const SocketCallback& callback,
const ServiceRecordList& list) {
@@ -647,7 +613,7 @@ void BluetoothDevice::GetServiceRecordsForConnectCallback(
if ((*i)->uuid() == service_uuid) {
// If multiple service records are found, use the first one that works.
scoped_refptr<BluetoothSocket> socket(
- BluetoothSocket::CreateBluetoothSocket(**i));
+ BluetoothSocketChromeOs::CreateBluetoothSocket(**i));
if (socket.get() != NULL) {
callback.Run(socket);
return;
@@ -657,20 +623,22 @@ void BluetoothDevice::GetServiceRecordsForConnectCallback(
callback.Run(NULL);
}
-void BluetoothDevice::OnRemoteDataCallback(const base::Closure& callback,
- const ErrorCallback& error_callback,
- bool success) {
+void BluetoothDeviceChromeOs::OnRemoteDataCallback(
+ const base::Closure& callback,
+ const ErrorCallback& error_callback,
+ bool success) {
if (success)
callback.Run();
else
error_callback.Run();
}
-void BluetoothDevice::DisconnectRequested(const dbus::ObjectPath& object_path) {
+void BluetoothDeviceChromeOs::DisconnectRequested(
+ const dbus::ObjectPath& object_path) {
DCHECK(object_path == object_path_);
}
-void BluetoothDevice::Release() {
+void BluetoothDeviceChromeOs::Release() {
DCHECK(agent_.get());
DVLOG(1) << "Release: " << address_;
@@ -685,8 +653,9 @@ void BluetoothDevice::Release() {
agent_.reset();
}
-void BluetoothDevice::RequestPinCode(const dbus::ObjectPath& device_path,
- const PinCodeCallback& callback) {
+void BluetoothDeviceChromeOs::RequestPinCode(
+ const dbus::ObjectPath& device_path,
+ const PinCodeCallback& callback) {
DCHECK(agent_.get());
DVLOG(1) << "RequestPinCode: " << device_path.value();
@@ -696,8 +665,9 @@ void BluetoothDevice::RequestPinCode(const dbus::ObjectPath& device_path,
pairing_delegate_->RequestPinCode(this);
}
-void BluetoothDevice::RequestPasskey(const dbus::ObjectPath& device_path,
- const PasskeyCallback& callback) {
+void BluetoothDeviceChromeOs::RequestPasskey(
+ const dbus::ObjectPath& device_path,
+ const PasskeyCallback& callback) {
DCHECK(agent_.get());
DCHECK(device_path == object_path_);
DVLOG(1) << "RequestPasskey: " << device_path.value();
@@ -708,8 +678,9 @@ void BluetoothDevice::RequestPasskey(const dbus::ObjectPath& device_path,
pairing_delegate_->RequestPasskey(this);
}
-void BluetoothDevice::DisplayPinCode(const dbus::ObjectPath& device_path,
- const std::string& pincode) {
+void BluetoothDeviceChromeOs::DisplayPinCode(
+ const dbus::ObjectPath& device_path,
+ const std::string& pincode) {
DCHECK(agent_.get());
DCHECK(device_path == object_path_);
DVLOG(1) << "DisplayPinCode: " << device_path.value() << " " << pincode;
@@ -718,8 +689,9 @@ void BluetoothDevice::DisplayPinCode(const dbus::ObjectPath& device_path,
pairing_delegate_->DisplayPinCode(this, pincode);
}
-void BluetoothDevice::DisplayPasskey(const dbus::ObjectPath& device_path,
- uint32 passkey) {
+void BluetoothDeviceChromeOs::DisplayPasskey(
+ const dbus::ObjectPath& device_path,
+ uint32 passkey) {
DCHECK(agent_.get());
DCHECK(device_path == object_path_);
DVLOG(1) << "DisplayPasskey: " << device_path.value() << " " << passkey;
@@ -728,7 +700,7 @@ void BluetoothDevice::DisplayPasskey(const dbus::ObjectPath& device_path,
pairing_delegate_->DisplayPasskey(this, passkey);
}
-void BluetoothDevice::RequestConfirmation(
+void BluetoothDeviceChromeOs::RequestConfirmation(
const dbus::ObjectPath& device_path,
uint32 passkey,
const ConfirmationCallback& callback) {
@@ -742,9 +714,9 @@ void BluetoothDevice::RequestConfirmation(
pairing_delegate_->ConfirmPasskey(this, passkey);
}
-void BluetoothDevice::Authorize(const dbus::ObjectPath& device_path,
- const std::string& uuid,
- const ConfirmationCallback& callback) {
+void BluetoothDeviceChromeOs::Authorize(const dbus::ObjectPath& device_path,
+ const std::string& uuid,
+ const ConfirmationCallback& callback) {
DCHECK(agent_.get());
DCHECK(device_path == object_path_);
LOG(WARNING) << "Rejected authorization for service: " << uuid
@@ -752,15 +724,16 @@ void BluetoothDevice::Authorize(const dbus::ObjectPath& device_path,
callback.Run(REJECTED);
}
-void BluetoothDevice::ConfirmModeChange(Mode mode,
- const ConfirmationCallback& callback) {
+void BluetoothDeviceChromeOs::ConfirmModeChange(
+ Mode mode,
+ const ConfirmationCallback& callback) {
DCHECK(agent_.get());
LOG(WARNING) << "Rejected adapter-level mode change: " << mode
<< " made on agent for device: " << address_;
callback.Run(REJECTED);
}
-void BluetoothDevice::Cancel() {
+void BluetoothDeviceChromeOs::Cancel() {
DCHECK(agent_.get());
DVLOG(1) << "Cancel: " << address_;
@@ -770,8 +743,9 @@ void BluetoothDevice::Cancel() {
// static
-BluetoothDevice* BluetoothDevice::Create(BluetoothAdapter* adapter) {
- return new BluetoothDevice(adapter);
+BluetoothDeviceChromeOs* BluetoothDeviceChromeOs::Create(
+ BluetoothAdapterChromeOs* adapter) {
+ return new BluetoothDeviceChromeOs(adapter);
}
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698