| Index: device/bluetooth/test/bluetooth_test.cc
|
| diff --git a/device/bluetooth/test/bluetooth_test.cc b/device/bluetooth/test/bluetooth_test.cc
|
| index 45425fa2ccb41e711329589a2545dd288f2c7a89..188aaa9ae7155a44defc9beff18d04f5722ca6a6 100644
|
| --- a/device/bluetooth/test/bluetooth_test.cc
|
| +++ b/device/bluetooth/test/bluetooth_test.cc
|
| @@ -25,12 +25,15 @@ const std::string BluetoothTestBase::kTestUUIDGenericAttribute = "1801";
|
| const std::string BluetoothTestBase::kTestUUIDImmediateAlert = "1802";
|
| const std::string BluetoothTestBase::kTestUUIDLinkLoss = "1803";
|
|
|
| -BluetoothTestBase::BluetoothTestBase() {
|
| -}
|
| +BluetoothTestBase::BluetoothTestBase() : weak_factory_(this) {}
|
|
|
| BluetoothTestBase::~BluetoothTestBase() {
|
| }
|
|
|
| +void BluetoothTestBase::DeleteDevice(BluetoothDevice* device) {
|
| + adapter_->DeleteDeviceForTesting(device->GetAddress());
|
| +}
|
| +
|
| void BluetoothTestBase::Callback() {
|
| ++callback_count_;
|
| }
|
| @@ -41,22 +44,47 @@ void BluetoothTestBase::DiscoverySessionCallback(
|
| discovery_sessions_.push_back(discovery_session.release());
|
| }
|
|
|
| +void BluetoothTestBase::GattConnectionCallback(
|
| + scoped_ptr<BluetoothGattConnection> connection) {
|
| + ++callback_count_;
|
| + gatt_connections_.push_back(connection.release());
|
| +}
|
| +
|
| void BluetoothTestBase::ErrorCallback() {
|
| ++error_callback_count_;
|
| }
|
|
|
| +void BluetoothTestBase::ConnectErrorCallback(
|
| + enum BluetoothDevice::ConnectErrorCode error_code) {
|
| + ++error_callback_count_;
|
| + last_connect_error_code_ = error_code;
|
| +}
|
| +
|
| base::Closure BluetoothTestBase::GetCallback() {
|
| - return base::Bind(&BluetoothTestBase::Callback, base::Unretained(this));
|
| + return base::Bind(&BluetoothTestBase::Callback, weak_factory_.GetWeakPtr());
|
| }
|
|
|
| BluetoothAdapter::DiscoverySessionCallback
|
| BluetoothTestBase::GetDiscoverySessionCallback() {
|
| return base::Bind(&BluetoothTestBase::DiscoverySessionCallback,
|
| - base::Unretained(this));
|
| + weak_factory_.GetWeakPtr());
|
| +}
|
| +
|
| +BluetoothDevice::GattConnectionCallback
|
| +BluetoothTestBase::GetGattConnectionCallback() {
|
| + return base::Bind(&BluetoothTestBase::GattConnectionCallback,
|
| + weak_factory_.GetWeakPtr());
|
| }
|
|
|
| BluetoothAdapter::ErrorCallback BluetoothTestBase::GetErrorCallback() {
|
| - return base::Bind(&BluetoothTestBase::ErrorCallback, base::Unretained(this));
|
| + return base::Bind(&BluetoothTestBase::ErrorCallback,
|
| + weak_factory_.GetWeakPtr());
|
| +}
|
| +
|
| +BluetoothDevice::ConnectErrorCallback
|
| +BluetoothTestBase::GetConnectErrorCallback() {
|
| + return base::Bind(&BluetoothTestBase::ConnectErrorCallback,
|
| + weak_factory_.GetWeakPtr());
|
| }
|
|
|
| } // namespace device
|
|
|