Chromium Code Reviews| Index: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc |
| diff --git a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc |
| index c10703a4d84bf186fc5c4f5f61600c81d491e068..ad63289cfc1762c598fa86c32e1c4542e01ee976 100644 |
| --- a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc |
| +++ b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc |
| @@ -70,11 +70,6 @@ extensions::BluetoothLowEnergyEventRouter* GetEventRouter( |
| return extensions::BluetoothLowEnergyAPI::Get(context)->event_router(); |
| } |
|
armansito
2014/07/18 03:26:37
Does this code actually compile? The reason these
Ilya Sherman
2014/07/18 21:37:00
Oh, wow: EXTENSION_FUNCTION_VALIDATE returns a val
|
| -void DoWorkCallback(const base::Callback<bool()>& callback) { |
| - DCHECK(!callback.is_null()); |
| - callback.Run(); |
| -} |
| - |
| } // namespace |
| @@ -129,10 +124,8 @@ bool BluetoothLowEnergyExtensionFunction::RunAsync() { |
| return false; |
| } |
| - // It is safe to pass |this| here as ExtensionFunction is refcounted. |
| - if (!event_router->InitializeAdapterAndInvokeCallback(base::Bind( |
| - &DoWorkCallback, |
| - base::Bind(&BluetoothLowEnergyExtensionFunction::DoWork, this)))) { |
| + if (!event_router->InitializeAdapterAndInvokeCallback( |
| + base::Bind(&BluetoothLowEnergyExtensionFunction::DoWork, this))) { |
| SetError(kErrorAdapterNotInitialized); |
| return false; |
| } |
| @@ -140,7 +133,7 @@ bool BluetoothLowEnergyExtensionFunction::RunAsync() { |
| return true; |
| } |
| -bool BluetoothLowEnergyConnectFunction::DoWork() { |
| +void BluetoothLowEnergyConnectFunction::DoWork() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| BluetoothLowEnergyEventRouter* event_router = |
| @@ -151,7 +144,7 @@ bool BluetoothLowEnergyConnectFunction::DoWork() { |
| if (!event_router->HasAdapter()) { |
| SetError(kErrorAdapterNotInitialized); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| scoped_ptr<apibtle::Connect::Params> params( |
| @@ -169,8 +162,6 @@ bool BluetoothLowEnergyConnectFunction::DoWork() { |
| params->device_address, |
| base::Bind(&BluetoothLowEnergyConnectFunction::SuccessCallback, this), |
| base::Bind(&BluetoothLowEnergyConnectFunction::ErrorCallback, this)); |
| - |
| - return true; |
| } |
| void BluetoothLowEnergyConnectFunction::SuccessCallback() { |
| @@ -183,7 +174,7 @@ void BluetoothLowEnergyConnectFunction::ErrorCallback( |
| SendResponse(false); |
| } |
| -bool BluetoothLowEnergyDisconnectFunction::DoWork() { |
| +void BluetoothLowEnergyDisconnectFunction::DoWork() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| BluetoothLowEnergyEventRouter* event_router = |
| @@ -194,7 +185,7 @@ bool BluetoothLowEnergyDisconnectFunction::DoWork() { |
| if (!event_router->HasAdapter()) { |
| SetError(kErrorAdapterNotInitialized); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| scoped_ptr<apibtle::Disconnect::Params> params( |
| @@ -206,8 +197,6 @@ bool BluetoothLowEnergyDisconnectFunction::DoWork() { |
| params->device_address, |
| base::Bind(&BluetoothLowEnergyDisconnectFunction::SuccessCallback, this), |
| base::Bind(&BluetoothLowEnergyDisconnectFunction::ErrorCallback, this)); |
| - |
| - return true; |
| } |
| void BluetoothLowEnergyDisconnectFunction::SuccessCallback() { |
| @@ -220,7 +209,7 @@ void BluetoothLowEnergyDisconnectFunction::ErrorCallback( |
| SendResponse(false); |
| } |
| -bool BluetoothLowEnergyGetServiceFunction::DoWork() { |
| +void BluetoothLowEnergyGetServiceFunction::DoWork() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| BluetoothLowEnergyEventRouter* event_router = |
| @@ -231,7 +220,7 @@ bool BluetoothLowEnergyGetServiceFunction::DoWork() { |
| if (!event_router->HasAdapter()) { |
| SetError(kErrorAdapterNotInitialized); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| scoped_ptr<apibtle::GetService::Params> params( |
| @@ -244,16 +233,14 @@ bool BluetoothLowEnergyGetServiceFunction::DoWork() { |
| if (status != BluetoothLowEnergyEventRouter::kStatusSuccess) { |
| SetError(StatusToString(status)); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| results_ = apibtle::GetService::Results::Create(service); |
| SendResponse(true); |
| - |
| - return true; |
| } |
| -bool BluetoothLowEnergyGetServicesFunction::DoWork() { |
| +void BluetoothLowEnergyGetServicesFunction::DoWork() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| BluetoothLowEnergyEventRouter* event_router = |
| @@ -264,7 +251,7 @@ bool BluetoothLowEnergyGetServicesFunction::DoWork() { |
| if (!event_router->HasAdapter()) { |
| SetError(kErrorAdapterNotInitialized); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| scoped_ptr<apibtle::GetServices::Params> params( |
| @@ -275,16 +262,14 @@ bool BluetoothLowEnergyGetServicesFunction::DoWork() { |
| if (!event_router->GetServices(params->device_address, &service_list)) { |
| SetError(kErrorNotFound); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| results_ = apibtle::GetServices::Results::Create(service_list); |
| SendResponse(true); |
| - |
| - return true; |
| } |
| -bool BluetoothLowEnergyGetCharacteristicFunction::DoWork() { |
| +void BluetoothLowEnergyGetCharacteristicFunction::DoWork() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| BluetoothLowEnergyEventRouter* event_router = |
| @@ -295,7 +280,7 @@ bool BluetoothLowEnergyGetCharacteristicFunction::DoWork() { |
| if (!event_router->HasAdapter()) { |
| SetError(kErrorAdapterNotInitialized); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| scoped_ptr<apibtle::GetCharacteristic::Params> params( |
| @@ -309,7 +294,7 @@ bool BluetoothLowEnergyGetCharacteristicFunction::DoWork() { |
| if (status != BluetoothLowEnergyEventRouter::kStatusSuccess) { |
| SetError(StatusToString(status)); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| // Manually construct the result instead of using |
| @@ -317,11 +302,9 @@ bool BluetoothLowEnergyGetCharacteristicFunction::DoWork() { |
| // enums correctly. |
| SetResult(apibtle::CharacteristicToValue(&characteristic).release()); |
| SendResponse(true); |
| - |
| - return true; |
| } |
| -bool BluetoothLowEnergyGetCharacteristicsFunction::DoWork() { |
| +void BluetoothLowEnergyGetCharacteristicsFunction::DoWork() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| BluetoothLowEnergyEventRouter* event_router = |
| @@ -332,7 +315,7 @@ bool BluetoothLowEnergyGetCharacteristicsFunction::DoWork() { |
| if (!event_router->HasAdapter()) { |
| SetError(kErrorAdapterNotInitialized); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| scoped_ptr<apibtle::GetCharacteristics::Params> params( |
| @@ -346,7 +329,7 @@ bool BluetoothLowEnergyGetCharacteristicsFunction::DoWork() { |
| if (status != BluetoothLowEnergyEventRouter::kStatusSuccess) { |
| SetError(StatusToString(status)); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| // Manually construct the result instead of using |
| @@ -361,11 +344,9 @@ bool BluetoothLowEnergyGetCharacteristicsFunction::DoWork() { |
| SetResult(result.release()); |
| SendResponse(true); |
| - |
| - return true; |
| } |
| -bool BluetoothLowEnergyGetIncludedServicesFunction::DoWork() { |
| +void BluetoothLowEnergyGetIncludedServicesFunction::DoWork() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| BluetoothLowEnergyEventRouter* event_router = |
| @@ -376,7 +357,7 @@ bool BluetoothLowEnergyGetIncludedServicesFunction::DoWork() { |
| if (!event_router->HasAdapter()) { |
| SetError(kErrorAdapterNotInitialized); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| scoped_ptr<apibtle::GetIncludedServices::Params> params( |
| @@ -389,16 +370,14 @@ bool BluetoothLowEnergyGetIncludedServicesFunction::DoWork() { |
| if (status != BluetoothLowEnergyEventRouter::kStatusSuccess) { |
| SetError(StatusToString(status)); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| results_ = apibtle::GetIncludedServices::Results::Create(service_list); |
| SendResponse(true); |
| - |
| - return true; |
| } |
| -bool BluetoothLowEnergyGetDescriptorFunction::DoWork() { |
| +void BluetoothLowEnergyGetDescriptorFunction::DoWork() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| BluetoothLowEnergyEventRouter* event_router = |
| @@ -409,7 +388,7 @@ bool BluetoothLowEnergyGetDescriptorFunction::DoWork() { |
| if (!event_router->HasAdapter()) { |
| SetError(kErrorAdapterNotInitialized); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| scoped_ptr<apibtle::GetDescriptor::Params> params( |
| @@ -422,7 +401,7 @@ bool BluetoothLowEnergyGetDescriptorFunction::DoWork() { |
| if (status != BluetoothLowEnergyEventRouter::kStatusSuccess) { |
| SetError(StatusToString(status)); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| // Manually construct the result instead of using |
| @@ -430,11 +409,9 @@ bool BluetoothLowEnergyGetDescriptorFunction::DoWork() { |
| // correctly. |
| SetResult(apibtle::DescriptorToValue(&descriptor).release()); |
| SendResponse(true); |
| - |
| - return true; |
| } |
| -bool BluetoothLowEnergyGetDescriptorsFunction::DoWork() { |
| +void BluetoothLowEnergyGetDescriptorsFunction::DoWork() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| BluetoothLowEnergyEventRouter* event_router = |
| @@ -445,7 +422,7 @@ bool BluetoothLowEnergyGetDescriptorsFunction::DoWork() { |
| if (!event_router->HasAdapter()) { |
| SetError(kErrorAdapterNotInitialized); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| scoped_ptr<apibtle::GetDescriptors::Params> params( |
| @@ -458,7 +435,7 @@ bool BluetoothLowEnergyGetDescriptorsFunction::DoWork() { |
| if (status != BluetoothLowEnergyEventRouter::kStatusSuccess) { |
| SetError(StatusToString(status)); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| // Manually construct the result instead of using |
| @@ -473,11 +450,9 @@ bool BluetoothLowEnergyGetDescriptorsFunction::DoWork() { |
| SetResult(result.release()); |
| SendResponse(true); |
| - |
| - return true; |
| } |
| -bool BluetoothLowEnergyReadCharacteristicValueFunction::DoWork() { |
| +void BluetoothLowEnergyReadCharacteristicValueFunction::DoWork() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| BluetoothLowEnergyEventRouter* event_router = |
| @@ -488,7 +463,7 @@ bool BluetoothLowEnergyReadCharacteristicValueFunction::DoWork() { |
| if (!event_router->HasAdapter()) { |
| SetError(kErrorAdapterNotInitialized); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| scoped_ptr<apibtle::ReadCharacteristicValue::Params> params( |
| @@ -505,8 +480,6 @@ bool BluetoothLowEnergyReadCharacteristicValueFunction::DoWork() { |
| base::Bind( |
| &BluetoothLowEnergyReadCharacteristicValueFunction::ErrorCallback, |
| this)); |
| - |
| - return true; |
| } |
| void BluetoothLowEnergyReadCharacteristicValueFunction::SuccessCallback() { |
| @@ -535,7 +508,7 @@ void BluetoothLowEnergyReadCharacteristicValueFunction::ErrorCallback( |
| SendResponse(false); |
| } |
| -bool BluetoothLowEnergyWriteCharacteristicValueFunction::DoWork() { |
| +void BluetoothLowEnergyWriteCharacteristicValueFunction::DoWork() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| BluetoothLowEnergyEventRouter* event_router = |
| @@ -546,7 +519,7 @@ bool BluetoothLowEnergyWriteCharacteristicValueFunction::DoWork() { |
| if (!event_router->HasAdapter()) { |
| SetError(kErrorAdapterNotInitialized); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| scoped_ptr<apibtle::WriteCharacteristicValue::Params> params( |
| @@ -564,8 +537,6 @@ bool BluetoothLowEnergyWriteCharacteristicValueFunction::DoWork() { |
| base::Bind( |
| &BluetoothLowEnergyWriteCharacteristicValueFunction::ErrorCallback, |
| this)); |
| - |
| - return true; |
| } |
| void BluetoothLowEnergyWriteCharacteristicValueFunction::SuccessCallback() { |
| @@ -579,7 +550,7 @@ void BluetoothLowEnergyWriteCharacteristicValueFunction::ErrorCallback( |
| SendResponse(false); |
| } |
| -bool BluetoothLowEnergyStartCharacteristicNotificationsFunction::DoWork() { |
| +void BluetoothLowEnergyStartCharacteristicNotificationsFunction::DoWork() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| BluetoothLowEnergyEventRouter* event_router = |
| @@ -590,7 +561,7 @@ bool BluetoothLowEnergyStartCharacteristicNotificationsFunction::DoWork() { |
| if (!event_router->HasAdapter()) { |
| SetError(kErrorAdapterNotInitialized); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| scoped_ptr<apibtle::StartCharacteristicNotifications::Params> params( |
| @@ -612,8 +583,6 @@ bool BluetoothLowEnergyStartCharacteristicNotificationsFunction::DoWork() { |
| base::Bind(&BluetoothLowEnergyStartCharacteristicNotificationsFunction:: |
| ErrorCallback, |
| this)); |
| - |
| - return true; |
| } |
| void |
| @@ -627,7 +596,7 @@ void BluetoothLowEnergyStartCharacteristicNotificationsFunction::ErrorCallback( |
| SendResponse(false); |
| } |
| -bool BluetoothLowEnergyStopCharacteristicNotificationsFunction::DoWork() { |
| +void BluetoothLowEnergyStopCharacteristicNotificationsFunction::DoWork() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| BluetoothLowEnergyEventRouter* event_router = |
| @@ -638,7 +607,7 @@ bool BluetoothLowEnergyStopCharacteristicNotificationsFunction::DoWork() { |
| if (!event_router->HasAdapter()) { |
| SetError(kErrorAdapterNotInitialized); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| scoped_ptr<apibtle::StopCharacteristicNotifications::Params> params( |
| @@ -654,8 +623,6 @@ bool BluetoothLowEnergyStopCharacteristicNotificationsFunction::DoWork() { |
| base::Bind(&BluetoothLowEnergyStopCharacteristicNotificationsFunction:: |
| ErrorCallback, |
| this)); |
| - |
| - return true; |
| } |
| void |
| @@ -669,7 +636,7 @@ void BluetoothLowEnergyStopCharacteristicNotificationsFunction::ErrorCallback( |
| SendResponse(false); |
| } |
| -bool BluetoothLowEnergyReadDescriptorValueFunction::DoWork() { |
| +void BluetoothLowEnergyReadDescriptorValueFunction::DoWork() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| BluetoothLowEnergyEventRouter* event_router = |
| @@ -680,7 +647,7 @@ bool BluetoothLowEnergyReadDescriptorValueFunction::DoWork() { |
| if (!event_router->HasAdapter()) { |
| SetError(kErrorAdapterNotInitialized); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| scoped_ptr<apibtle::ReadDescriptorValue::Params> params( |
| @@ -696,8 +663,6 @@ bool BluetoothLowEnergyReadDescriptorValueFunction::DoWork() { |
| this), |
| base::Bind(&BluetoothLowEnergyReadDescriptorValueFunction::ErrorCallback, |
| this)); |
| - |
| - return true; |
| } |
| void BluetoothLowEnergyReadDescriptorValueFunction::SuccessCallback() { |
| @@ -726,7 +691,7 @@ void BluetoothLowEnergyReadDescriptorValueFunction::ErrorCallback( |
| SendResponse(false); |
| } |
| -bool BluetoothLowEnergyWriteDescriptorValueFunction::DoWork() { |
| +void BluetoothLowEnergyWriteDescriptorValueFunction::DoWork() { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| BluetoothLowEnergyEventRouter* event_router = |
| @@ -737,7 +702,7 @@ bool BluetoothLowEnergyWriteDescriptorValueFunction::DoWork() { |
| if (!event_router->HasAdapter()) { |
| SetError(kErrorAdapterNotInitialized); |
| SendResponse(false); |
| - return false; |
| + return; |
| } |
| scoped_ptr<apibtle::WriteDescriptorValue::Params> params( |
| @@ -754,8 +719,6 @@ bool BluetoothLowEnergyWriteDescriptorValueFunction::DoWork() { |
| this), |
| base::Bind(&BluetoothLowEnergyWriteDescriptorValueFunction::ErrorCallback, |
| this)); |
| - |
| - return true; |
| } |
| void BluetoothLowEnergyWriteDescriptorValueFunction::SuccessCallback() { |