Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend WebBluetooth with discovery session and dialog #11269

Merged
merged 2 commits into from May 26, 2016

Conversation

dati91
Copy link
Contributor

@dati91 dati91 commented May 19, 2016

Thank you for contributing to Servo! Please replace each [ ] by [X] when the step is complete, and replace __ with appropriate data:

  • ./mach build -d does not report any errors
  • ./mach test-tidy --faster does not report any errors
  • These changes fix #__ (github issue number if applicable).

Either:

  • There are tests for these changes OR
  • These changes do not require tests because the there are no webbluetooth tests ye.

Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process.


This change is Reviewable

@highfive
Copy link

Heads up! This PR modifies the following files:

  • @KiChjang: components/net/bluetooth_thread.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label May 19, 2016
@highfive
Copy link

warning Warning warning

  • These commits modify net code, but no tests are modified. Please consider adding a test!

@wafflespeanut
Copy link
Contributor

r? @jdm

@highfive highfive assigned jdm and unassigned wafflespeanut May 19, 2016
@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 25, 2016
@jdm
Copy link
Member

jdm commented May 25, 2016

-S-awaiting-review +S-needs-code-changes

Previously, Wafflespeanut (Ravi Shankar) wrote…

r? @jdm


Reviewed 1 of 1 files at r1, 4 of 4 files at r2.
Review status: all files reviewed at latest revision, 4 unresolved discussions.


components/net/bluetooth_thread.rs, line 32 [r1] (raw file):

const VALUE_ERROR: &'static str = "No characteristic or descriptor found with that id";
// The discovery session needs some time to find any nearby devices
const DISCOVERY_TIMEOUT: u64 = 1500;

Let's call this DISCOVERY_TIMEOUT_MS for clarity.


components/net/bluetooth_thread.rs, line 382 [r1] (raw file):

                                     rssi: device.get_rssi().ok().map(|p| p as i8),
                                 });
                session.map(|ref s| s.stop_discovery());

Let's use if let.


components/net/bluetooth_thread.rs, line 386 [r1] (raw file):

            }
        }
        session.map(|ref s| s.stop_discovery());

Could we avoid the duplication by calling stop_discovery before the for?


components/net/bluetooth_thread.rs, line 236 [r2] (raw file):

            // The device string format will be "Address|Name".
            // We need the first part, therefore we reverse the split and use the last item.
            return device.rsplit("|").map(|s| s.to_string()).collect::<Vec<String>>().pop();

Isn't this equivalent to calling first() on the result of the map?


Comments from Reviewable

@dati91
Copy link
Contributor Author

dati91 commented May 26, 2016

components/net/bluetooth_thread.rs, line 236 [r2] (raw file):

Previously, jdm (Josh Matthews) wrote…

Isn't this equivalent to calling first() on the result of the map?

`first()` and `get(0)` will give you `Option<&T>`, while `pop()` will give `Option`

Comments from Reviewable

@highfive highfive removed the S-needs-code-changes Changes have not yet been made that were requested by a reviewer. label May 26, 2016
@highfive
Copy link

New code was committed to pull request.

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label May 26, 2016
@jdm
Copy link
Member

jdm commented May 26, 2016

Go ahead and squash the review comment changes into the second commit.
-S-awaiting-review +S-needs-code-changes +S-needs-squash

Previously, highfive wrote…

New code was committed to pull request.


Reviewed 1 of 1 files at r3.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


components/net/bluetooth_thread.rs, line 236 [r2] (raw file):

Previously, dati91 (Attila Dusnoki) wrote…

first() and get(0) will give you Option<&T>, while pop() will give Option<T>

I think this would be clearer as `device.split("|").first().map(|s| s.to_string())`, in that case.

Comments from Reviewable

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. S-needs-squash Some (or all) of the commits in the PR should be combined. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 26, 2016
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels May 26, 2016
@highfive
Copy link

New code was committed to pull request.

@KiChjang
Copy link
Contributor

-S-awaiting-review -S-needs-squash +S-needs-code-changes

Previously, highfive wrote…

New code was committed to pull request.


Review status: 0 of 4 files reviewed at latest revision, 2 unresolved discussions.


components/net/bluetooth_thread.rs, line 235 [r5] (raw file):

                                                           Some(dialog_rows)) {
            // The device string format will be "Address|Name". We need the first part of it.
            return device.split("|").collect::<Vec<&str>>().first().map(|s| s.to_string());

device.split("|").next().map(|s| s.to_string())


Comments from Reviewable

@KiChjang KiChjang added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-needs-squash Some (or all) of the commits in the PR should be combined. S-awaiting-review There is new code that needs to be reviewed. labels May 26, 2016
@highfive
Copy link

New code was committed to pull request.

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels May 26, 2016
@jdm
Copy link
Member

jdm commented May 26, 2016

@bors-servo: r+

@bors-servo
Copy link
Contributor

📌 Commit 6048f0f has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 26, 2016
@bors-servo
Copy link
Contributor

⌛ Testing commit 6048f0f with merge c4bb543...

bors-servo pushed a commit that referenced this pull request May 26, 2016
Extend WebBluetooth with discovery session and dialog

Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data:
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy --faster` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

Either:
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because the there are no webbluetooth tests ye.

Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11269)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows

@bors-servo bors-servo merged commit 6048f0f into servo:master May 26, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label May 26, 2016
@dati91 dati91 deleted the discovery branch May 30, 2016 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants