Closed Bug 913372 Opened 11 years ago Closed 11 years ago

[B2G] [Bluetooth] Make a queue for active connection requests

Categories

(Firefox OS Graveyard :: Bluetooth, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(blocking-b2g:koi+, firefox25 wontfix, firefox26 fixed, firefox27 fixed, b2g-v1.2 fixed)

RESOLVED FIXED
1.2 C3(Oct25)
blocking-b2g koi+
Tracking Status
firefox25 --- wontfix
firefox26 --- fixed
firefox27 --- fixed
b2g-v1.2 --- fixed

People

(Reporter: gyeh, Assigned: gyeh)

References

Details

(Whiteboard: [u=devices c=BT p=5] )

Attachments

(3 files, 6 obsolete files)

12.04 KB, patch
Details | Diff | Splinter Review
7.33 KB, patch
Details | Diff | Splinter Review
4.31 KB, patch
Details | Diff | Splinter Review
Depends on: 913374
Assignee: nobody → gyeh
Target Milestone: --- → 1.2 QE2(Oct25)
Gina, Has there been any progress with this bug?
Flags: needinfo?(gyeh)
I'm working on it this week. Will update soon here.
Flags: needinfo?(gyeh)
The public interface of class BluetoothProfileController is refined. - In c-tor, aConnect is set to true for a connect request. Otherwise, set to false for a disconnect request. - Start(): Set up |mProfiles| and start connecting/disconnecting. - No return value for AddProfile() and AddProfileWithServiceClass(). - Make a union for CoD and BluetoothServiceClass.
Attachment #818934 - Flags: review?(echou)
Comment on attachment 818934 [details] [diff] [review] Patch 1(v1): Refine the architecture of BluetoothProfileController Review of attachment 818934 [details] [diff] [review]: ----------------------------------------------------------------- Gina, please see my comments below. ::: dom/bluetooth/BluetoothProfileController.cpp @@ +48,5 @@ > + /** > + * If the service uuid is not specified, either connect multiple profiles > + * based on Cod, or disconnect all connected profiles. > + */ > + bool assignServiceClass = false; This could be saved if we call SetupProfiles(true) / SetupProfiles(false) inside the if-else block. @@ +175,5 @@ > +BluetoothProfileController::Start() > +{ > + MOZ_ASSERT(NS_IsMainThread()); > + MOZ_ASSERT(!mDeviceAddress.IsEmpty()); > + MOZ_ASSERT(++mProfilesIndex == 0); Please use MOZ_ASSERT(mProfilesIndex == -1), otherwise the value of mProfilesIndex won't be the same after this line in release and debug build. @@ +195,3 @@ > > if (++mProfilesIndex < mProfiles.Length()) { > MOZ_ASSERT(!mDeviceAddress.IsEmpty()); nit: extra assertion. ::: dom/bluetooth/BluetoothProfileController.h @@ +121,5 @@ > + // Either CoD or BluetoothServiceClass is assigned. > + union { > + uint32_t mCod; > + BluetoothServiceClass mClass; > + } u; 'u' doesn't seem to be clear enough to indicate what this field means. In addition, the union name should start with 'm' since it's a member variable of BluetoothProfileController. For instance, union { uint32_t cod; // I avoid naming it "class" because 1) it's a keyword 2) 'cod' is actually 'class of device', // which is quite similar to 'class'. BluetoothServiceClass service; } mTarget; // There should be a better name than 'target' :)
Thanks for your comments, Eric. I'll update the patch soon. > @@ +175,5 @@ > > +BluetoothProfileController::Start() > > +{ > > + MOZ_ASSERT(NS_IsMainThread()); > > + MOZ_ASSERT(!mDeviceAddress.IsEmpty()); > > + MOZ_ASSERT(++mProfilesIndex == 0); > > Please use MOZ_ASSERT(mProfilesIndex == -1), otherwise the value of > mProfilesIndex won't be the same after this line in release and debug build. Nice catch ;) I didn't notice that until you pointed out. > ::: dom/bluetooth/BluetoothProfileController.h > @@ +121,5 @@ > > + // Either CoD or BluetoothServiceClass is assigned. > > + union { > > + uint32_t mCod; > > + BluetoothServiceClass mClass; > > + } u; > > 'u' doesn't seem to be clear enough to indicate what this field means. In > addition, the union name should start with 'm' since it's a member variable > of BluetoothProfileController. For instance, > > union { > uint32_t cod; > > // I avoid naming it "class" because 1) it's a keyword 2) 'cod' is > actually 'class of device', > // which is quite similar to 'class'. > BluetoothServiceClass service; > } mTarget; // There should be a better name than 'target' :) Agree. It's much clearer.
Patch is updated. Please review again. Thanks.
Attachment #818934 - Attachment is obsolete: true
Attachment #818934 - Flags: review?(echou)
Attachment #821441 - Flags: review?(echou)
Comment on attachment 821441 [details] [diff] [review] Patch 1(v2): Refine the architecture of BluetoothProfileController Review of attachment 821441 [details] [diff] [review]: ----------------------------------------------------------------- r=me with nits addressed. ::: dom/bluetooth/BluetoothProfileController.cpp @@ +174,5 @@ > +{ > + MOZ_ASSERT(NS_IsMainThread()); > + MOZ_ASSERT(!mDeviceAddress.IsEmpty()); > + MOZ_ASSERT(mProfilesIndex == -1); > + BT_LOGR_PROFILE(mProfiles[++mProfilesIndex], ""); I still have concerns about putting operations which would affect the value of variables inside macros. Can we put "++mProfilesIndex" before BT_LOGR_PROFILE()? ::: dom/bluetooth/BluetoothProfileController.h @@ +108,5 @@ > > + // Connect/Disconnect next profile in the array > + void Next(); > + > + bool mConnect; suggestion: mConnect is a very important variable and shouldn't be modified outside ctor. You could make it a const variable.
Attachment #821441 - Flags: review?(echou) → review+
Both are good suggestions. I'll make sure that these changes are included in the final patch.
Comment on attachment 818935 [details] [diff] [review] Patch 2(v1): Set mController to null before invoking callback function Review of attachment 818935 [details] [diff] [review]: ----------------------------------------------------------------- r=me with nits addressed. ::: dom/bluetooth/BluetoothOppManager.cpp @@ +1481,4 @@ > * connections. On the other hand, we do nothing for inbound connections. > */ > NS_ENSURE_TRUE_VOID(mController); > Per offline discussion, please leave explanation of why you made this change in commit message. ::: dom/bluetooth/BluetoothOppManager.h @@ -217,5 @@ > nsCOMPtr<nsIThread> mReadFileThread; > nsCOMPtr<nsIOutputStream> mOutputStream; > nsCOMPtr<nsIInputStream> mInputStream; > nsCOMPtr<nsIVolumeMountLock> mMountLock; > - nsRefPtr<BluetoothReplyRunnable> mRunnable; Thanks for cleaning up! Then the forward declaration of BluetoothReplyRunnable can be removed as well.
Attachment #818935 - Flags: review?(echou) → review+
Comment on attachment 818936 [details] [diff] [review] Patch 3(v1): Make a queue for active connection requests Review of attachment 818936 [details] [diff] [review]: ----------------------------------------------------------------- Hi Gina, please see my comments below. ::: dom/bluetooth/linux/BluetoothDBusService.cpp @@ +176,5 @@ > static nsString sAdapterPath; > static Atomic<int32_t> sIsPairing(0); > static int sConnectedDeviceCount = 0; > static StaticAutoPtr<Monitor> sStopBluetoothMonitor; > +static nsTArray<BluetoothProfileController*> sControllerArray; Please use nsTArray<nsRefPtr<BluetoothProfileController> > sControllerArray. @@ +2555,5 @@ > return result; > } > > static void > +NextBluetoothProfileController() Suggestion: the implementation of this function looks good, however I have an idea: what if we always use the first element as the next one? Then we won't need to iterate the whole array. It looks like: sControllerArray[0] = nullptr; sControllerArray.RemoveElementAt(0); if (!sControllerArray.IsEmpty()) { sControllerArray[0]->Start(); } Make sense? @@ +2588,2 @@ > > + if (sControllerArray.Length() == 1) { Please add comments to explain why checking if "sControllerArray.Length() == 1" here.
It makes sense to me. Let me refine the patch and send the review request again. Thanks.
Eric, please help to check the patch. Thanks.
Attachment #818936 - Attachment is obsolete: true
Attachment #818936 - Flags: review?(echou)
Attachment #821635 - Flags: review?(echou)
Comment on attachment 821635 [details] [diff] [review] Patch 3(v2): Make a queue for active connection requests Review of attachment 821635 [details] [diff] [review]: ----------------------------------------------------------------- Looks good. Ready to go. :)
Attachment #821635 - Flags: review?(echou) → review+
Unfortunately I had to back this out, since it caused conflicts with the backout of bug 920551. This can reland after rebase :-)
Patches have been rebased but b2g-inbound is closed. Will push them after re-opening.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: