summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/extensions/api/bluetooth/bluetooth_api.cc34
-rw-r--r--chrome/browser/extensions/api/bluetooth/bluetooth_api.h1
2 files changed, 5 insertions, 30 deletions
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
index b1e34ba..a8d92c5 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
@@ -100,10 +100,8 @@ void BluetoothGetDevicesFunction::AddDeviceIfTrueCallback(
list->Append(experimental_bluetooth::BluetoothDeviceToValue(*device));
callbacks_pending_--;
- if (callbacks_pending_ == -1) {
+ if (callbacks_pending_ == -1)
SendResponse(true);
- Release(); // Added in RunImpl
- }
}
bool BluetoothGetDevicesFunction::RunImpl() {
@@ -118,11 +116,6 @@ bool BluetoothGetDevicesFunction::RunImpl() {
CHECK_EQ(0, callbacks_pending_);
- // This will be released when callbacks_pending_ == -1. The count is checked
- // for -1 because of the extra decrement after the for-loop, which ensures
- // that all requests have been made before the Release happens.
- AddRef();
-
chromeos::BluetoothAdapter::DeviceList devices =
GetMutableAdapter(profile())->GetDevices();
for (chromeos::BluetoothAdapter::DeviceList::iterator i = devices.begin();
@@ -148,10 +141,11 @@ bool BluetoothGetDevicesFunction::RunImpl() {
}
callbacks_pending_--;
- if (callbacks_pending_ == -1) {
+ // The count is checked for -1 because of the extra decrement after the
+ // for-loop, which ensures that all requests have been made before
+ // SendResponse happens.
+ if (callbacks_pending_ == -1)
SendResponse(true);
- Release();
- }
return true;
}
@@ -170,13 +164,11 @@ void BluetoothGetServicesFunction::GetServiceRecordsCallback(
}
SendResponse(true);
- Release(); // Added in RunImpl
}
void BluetoothGetServicesFunction::OnErrorCallback() {
SetError(kServiceDiscoveryFailed);
SendResponse(false);
- Release(); // Added in RunImpl
}
bool BluetoothGetServicesFunction::RunImpl() {
@@ -195,7 +187,6 @@ bool BluetoothGetServicesFunction::RunImpl() {
ListValue* services = new ListValue;
result_.reset(services);
- AddRef(); // Released in GetServiceRecordsCallback or OnErrorCallback
device->GetServiceRecords(
base::Bind(&BluetoothGetServicesFunction::GetServiceRecordsCallback,
this,
@@ -224,8 +215,6 @@ void BluetoothConnectFunction::ConnectToServiceCallback(
SetError(kFailedToConnect);
SendResponse(false);
}
-
- Release(); // Added in RunImpl
}
bool BluetoothConnectFunction::RunImpl() {
@@ -241,7 +230,6 @@ bool BluetoothConnectFunction::RunImpl() {
return false;
}
- AddRef(); // Released in ConnectToServiceCallback
device->ConnectToService(options.service_uuid,
base::Bind(&BluetoothConnectFunction::ConnectToServiceCallback,
this,
@@ -361,13 +349,11 @@ bool BluetoothWriteFunction::Respond() {
void BluetoothSetOutOfBandPairingDataFunction::OnSuccessCallback() {
SendResponse(true);
- Release(); // Added in RunImpl
}
void BluetoothSetOutOfBandPairingDataFunction::OnErrorCallback() {
SetError(kCouldNotSetOutOfBandPairingData);
SendResponse(false);
- Release(); // Added in RunImpl
}
bool BluetoothSetOutOfBandPairingDataFunction::RunImpl() {
@@ -386,7 +372,6 @@ bool BluetoothSetOutOfBandPairingDataFunction::RunImpl() {
return false;
}
- AddRef(); // Released in OnSuccessCallback or OnErrorCallback
if (options->HasKey("data")) {
DictionaryValue* data_in;
EXTENSION_FUNCTION_VALIDATE(options->GetDictionary("data", &data_in));
@@ -443,17 +428,14 @@ void BluetoothGetLocalOutOfBandPairingDataFunction::ReadCallback(
result_.reset(result);
SendResponse(true);
- Release(); // Added in RunImpl
}
void BluetoothGetLocalOutOfBandPairingDataFunction::ErrorCallback() {
SetError(kCouldNotGetLocalOutOfBandPairingData);
SendResponse(false);
- Release(); // Added in RunImpl
}
bool BluetoothGetLocalOutOfBandPairingDataFunction::RunImpl() {
- AddRef(); // Released in one of the callbacks below
GetMutableAdapter(profile())->ReadLocalOutOfBandPairingData(
base::Bind(&BluetoothGetLocalOutOfBandPairingDataFunction::ReadCallback,
this),
@@ -464,13 +446,11 @@ bool BluetoothGetLocalOutOfBandPairingDataFunction::RunImpl() {
void BluetoothStartDiscoveryFunction::OnSuccessCallback() {
SendResponse(true);
- Release(); // Added in RunImpl
}
void BluetoothStartDiscoveryFunction::OnErrorCallback() {
SetError(kStartDiscoveryFailed);
SendResponse(false);
- Release(); // Added in RunImpl
}
bool BluetoothStartDiscoveryFunction::RunImpl() {
@@ -483,7 +463,6 @@ bool BluetoothStartDiscoveryFunction::RunImpl() {
return true;
}
- AddRef(); // Removed in whichever callback is called.
GetMutableAdapter(profile())->SetDiscovering(true,
base::Bind(&BluetoothStartDiscoveryFunction::OnSuccessCallback, this),
base::Bind(&BluetoothStartDiscoveryFunction::OnErrorCallback, this));
@@ -492,18 +471,15 @@ bool BluetoothStartDiscoveryFunction::RunImpl() {
void BluetoothStopDiscoveryFunction::OnSuccessCallback() {
SendResponse(true);
- Release(); // Added in RunImpl
}
void BluetoothStopDiscoveryFunction::OnErrorCallback() {
SetError(kStopDiscoveryFailed);
SendResponse(false);
- Release(); // Added in RunImpl
}
bool BluetoothStopDiscoveryFunction::RunImpl() {
GetEventRouter(profile())->SetSendDiscoveryEvents(false);
- AddRef(); // Removed in whichever callback is called.
GetMutableAdapter(profile())->SetDiscovering(false,
base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this),
base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this));
diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.h b/chrome/browser/extensions/api/bluetooth/bluetooth_api.h
index 97c90ff..aa9da47 100644
--- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.h
+++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.h
@@ -94,7 +94,6 @@ class BluetoothGetServicesFunction : public AsyncExtensionFunction {
// ExtensionFunction:
virtual bool RunImpl() OVERRIDE;
-
#if defined(OS_CHROMEOS)
private:
void GetServiceRecordsCallback(