Closed Bug 1195604 Opened 9 years ago Closed 9 years ago

[cleanup] Integrate similar BluetoothResultHandlers into basic one

Categories

(Firefox OS Graveyard :: Bluetooth, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(firefox43 fixed)

RESOLVED FIXED
FxOS-S5 (21Aug)
Tracking Status
firefox43 --- fixed

People

(Reporter: ben.tian, Assigned: ben.tian)

References

Details

Attachments

(1 file, 1 obsolete file)

Integrate the following result handlers into |BasicResultHandler| since they behave the same:
- CancelDiscoveryResultHandler
- CreateBondResultHandler
- GetRemoteServicesResultHandler
- RemoveBondResultHandler
- SetAdapterPropertyResultHandler
- StartDiscoveryResultHandler
Assignee: nobody → btian
Attachment #8649068 - Flags: review?(tzimmermann)
Comment on attachment 8649068 [details] [diff] [review]
Patch 1 (v1): Integrate similar BluetoothResultHandlers into basic one

Review of attachment 8649068 [details] [diff] [review]:
-----------------------------------------------------------------

Hi! There's a bug in the patch and the current code. So r- for now.

::: dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
@@ +705,5 @@
>  
>    return NS_OK;
>  }
>  
> +class BluetoothServiceBluedroid::BasicResultHandler final

Please call this |DispatchReplyErrorResultHandler| to indicate what it actually does.

@@ +714,3 @@
>      nsTArray<nsRefPtr<BluetoothReplyRunnable>>& aRunnableArray,
>      BluetoothReplyRunnable* aRunnable)
>    : mRunnableArray(aRunnableArray)

Field initializers should have an indention of 4 spaces here.

@@ +715,5 @@
>      BluetoothReplyRunnable* aRunnable)
>    : mRunnableArray(aRunnableArray)
>    , mRunnable(aRunnable)
> +  {
> +    MOZ_ASSERT(mRunnable);

That's not correct AFAICT. Users push a runnable pointer into an array, even if the pointer is |nullptr|. On errors, we have to remove the nullptr pointer as well.

@@ +727,5 @@
>      DispatchReplyError(mRunnable, aStatus);
>    }
>  
>  private:
>    nsTArray<nsRefPtr<BluetoothReplyRunnable>> mRunnableArray;

This line looks like a bug, doesn't it?

|OnError| is supposed to remove the runnable from the |m*Array| in |BluetoothServiceBluedroid|, but this code doesn't do that. This line should be a reference to the array: 'nsTArray<nsRefPtr<BluetoothReplyRunnable>>& mRunnableArray'.
Attachment #8649068 - Flags: review?(tzimmermann) → review-
Changes:
- rename |BasicResultHandler| to |DispatchReplyErrorResultHandler|
- fix indention of field initializers
- handle case that runnable pointer is |nullptr|
- keep reference to the runnable and GetDeviceRequest array in result handler
Attachment #8649068 - Attachment is obsolete: true
Attachment #8649148 - Flags: review?(tzimmermann)
Comment on attachment 8649148 [details] [diff] [review]
[final] Patch 1: Integrate similar BluetoothResultHandlers into basic one, r=tzimmermann

Review of attachment 8649148 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks for fixing all indention. r+ with the one final bug fixes.

::: dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
@@ +724,2 @@
>      mRunnableArray.RemoveElement(mRunnable);
> +    if (mRunnable) {

The previous version was correct here. You might have pushed nullptr into the array. In case of an error, you also have to remove it.
Attachment #8649148 - Flags: review?(tzimmermann) → review+
Sorry, I mis-read the patch. The current version is correct. Please land it! :)
Attachment #8649148 - Attachment description: Patch 1 (v2): Integrate similar BluetoothResultHandlers into basic one → [final] Patch 1: Integrate similar BluetoothResultHandlers into basic one, r=tzimmermann
Set dependency to avoid code landing conflict.
Blocks: 1195608
https://hg.mozilla.org/mozilla-central/rev/83d57a912d96
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → FxOS-S5 (21Aug)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: