Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Issue 2752663002: Remove RemoteServerDisconnect() from web_bluetooth.mojom (Closed)

Created:
3 years, 9 months ago by juncai
Modified:
3 years, 8 months ago
Reviewers:
scheib, ortuno, dcheng
CC:
Aaron Boodman, abarth-chromium, blink-reviews, blink-reviews-api_chromium.org, chromium-reviews, darin (slow to review), darin-cc_chromium.org, dglazkov+blink, haraken, jam, ortuno+watch_chromium.org, qsr+mojo_chromium.org, scheib+watch_chromium.org, viettrungluu+watch_chromium.org, yzshen+watch_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Remove RemoteServerDisconnect() from web_bluetooth.mojom When either of the following happens: 1. When a device is disconnected on the browser side. 2. When the renderer intentionally wants to disconnect from a device. It is currently handled by RemoteServerDisconnect() which is implemented on the browser side and called on the renderer side. This CL removes RemoteServerDisconnect() from web_bluetooth.mojom and uses error handlers on both browser and renderer side instead. It cleans up the code and make the disconnection logic simpler and more straightforward. BUG=697700

Patch Set 1 : remove RemoteServerDisconnect() from web_bluetooth.mojom #

Patch Set 2 : updated function name #

Patch Set 3 : update comment #

Patch Set 4 : rebase #

Patch Set 5 : rebase #

Patch Set 6 : rebase #

Patch Set 7 : rebase #

Total comments: 10

Patch Set 8 : address scheib@'s comments #

Total comments: 15

Patch Set 9 : rebase #

Patch Set 10 : rebase #

Patch Set 11 : rebase #

Patch Set 12 : merge master #

Patch Set 13 : code cleanup #

Patch Set 14 : address scheib@'s comments #

Total comments: 17

Patch Set 15 : address ortuno@'s comments #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+100 lines, -71 lines) Patch
M content/browser/bluetooth/web_bluetooth_service_impl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +7 lines, -1 line 0 comments Download
M content/browser/bluetooth/web_bluetooth_service_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 3 chunks +17 lines, -12 lines 1 comment Download
M third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.h View 1 2 3 1 chunk +2 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp View 1 2 3 1 chunk +1 line, -2 lines 0 comments Download
M third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.h View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +7 lines, -13 lines 0 comments Download
M third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 4 chunks +66 lines, -36 lines 0 comments Download
M third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.mojom View 1 2 3 4 1 chunk +0 lines, -4 lines 0 comments Download

Messages

Total messages: 65 (48 generated)
juncai
Please take a look.
3 years, 9 months ago (2017-03-14 20:23:21 UTC) #9
juncai
Please take a look.
3 years, 9 months ago (2017-03-20 20:33:15 UTC) #30
scheib
Explain more in the change description about what is being changed. I read up some ...
3 years, 9 months ago (2017-03-20 21:39:14 UTC) #31
juncai
https://codereview.chromium.org/2752663002/diff/120001/content/browser/bluetooth/web_bluetooth_service_impl.cc File content/browser/bluetooth/web_bluetooth_service_impl.cc (right): https://codereview.chromium.org/2752663002/diff/120001/content/browser/bluetooth/web_bluetooth_service_impl.cc#newcode358 content/browser/bluetooth/web_bluetooth_service_impl.cc:358: void WebBluetoothServiceImpl::HandleServerClientError( On 2017/03/20 21:39:13, scheib wrote: > Keep ...
3 years, 9 months ago (2017-03-21 00:52:35 UTC) #37
ortuno
Fwiw a lot of these functions are pretty much copies of the spec functions so ...
3 years, 9 months ago (2017-03-21 01:58:13 UTC) #40
ortuno
Fwiw a lot of these functions are pretty much copies of the spec functions so ...
3 years, 9 months ago (2017-03-21 01:58:14 UTC) #41
scheib
https://codereview.chromium.org/2752663002/diff/140001/content/browser/bluetooth/web_bluetooth_service_impl.cc File content/browser/bluetooth/web_bluetooth_service_impl.cc (right): https://codereview.chromium.org/2752663002/diff/140001/content/browser/bluetooth/web_bluetooth_service_impl.cc#newcode842 content/browser/bluetooth/web_bluetooth_service_impl.cc:842: UMAWebBluetoothFunction::REMOTE_GATT_SERVER_DISCONNECT); This UMA was intended to count how often ...
3 years, 9 months ago (2017-03-22 01:11:08 UTC) #42
juncai
https://codereview.chromium.org/2752663002/diff/140001/content/browser/bluetooth/web_bluetooth_service_impl.cc File content/browser/bluetooth/web_bluetooth_service_impl.cc (right): https://codereview.chromium.org/2752663002/diff/140001/content/browser/bluetooth/web_bluetooth_service_impl.cc#newcode842 content/browser/bluetooth/web_bluetooth_service_impl.cc:842: UMAWebBluetoothFunction::REMOTE_GATT_SERVER_DISCONNECT); On 2017/03/22 01:11:07, scheib wrote: > This UMA ...
3 years, 9 months ago (2017-03-27 20:44:46 UTC) #49
scheib
https://codereview.chromium.org/2752663002/diff/260001/content/browser/bluetooth/web_bluetooth_service_impl.cc File content/browser/bluetooth/web_bluetooth_service_impl.cc (right): https://codereview.chromium.org/2752663002/diff/260001/content/browser/bluetooth/web_bluetooth_service_impl.cc#newcode841 content/browser/bluetooth/web_bluetooth_service_impl.cc:841: RecordWebBluetoothFunctionCall( This will incorrectly record UMA for disconnects that ...
3 years, 9 months ago (2017-03-27 21:51:46 UTC) #52
juncai
https://codereview.chromium.org/2752663002/diff/260001/content/browser/bluetooth/web_bluetooth_service_impl.cc File content/browser/bluetooth/web_bluetooth_service_impl.cc (right): https://codereview.chromium.org/2752663002/diff/260001/content/browser/bluetooth/web_bluetooth_service_impl.cc#newcode841 content/browser/bluetooth/web_bluetooth_service_impl.cc:841: RecordWebBluetoothFunctionCall( On 2017/03/27 21:51:46, scheib wrote: > This will ...
3 years, 9 months ago (2017-03-27 23:21:14 UTC) #53
juncai
dcheng@chromium.org, please review changes in: third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.mojom This CL also addresses the comment at: https://codereview.chromium.org/2718583002/ by ...
3 years, 9 months ago (2017-03-27 23:43:35 UTC) #55
dcheng
lgtm https://codereview.chromium.org/2752663002/diff/260001/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp File third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp (right): https://codereview.chromium.org/2752663002/diff/260001/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp#newcode146 third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp:146: ClearActiveAlgorithms(); Just curious: how come we need to ...
3 years, 9 months ago (2017-03-28 02:25:01 UTC) #56
scheib
https://codereview.chromium.org/2752663002/diff/260001/content/browser/bluetooth/web_bluetooth_service_impl.cc File content/browser/bluetooth/web_bluetooth_service_impl.cc (right): https://codereview.chromium.org/2752663002/diff/260001/content/browser/bluetooth/web_bluetooth_service_impl.cc#newcode841 content/browser/bluetooth/web_bluetooth_service_impl.cc:841: RecordWebBluetoothFunctionCall( On 2017/03/27 23:21:14, juncai wrote: > On 2017/03/27 ...
3 years, 9 months ago (2017-03-28 03:48:06 UTC) #57
ortuno
https://codereview.chromium.org/2752663002/diff/260001/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp File third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp (right): https://codereview.chromium.org/2752663002/diff/260001/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp#newcode41 third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp:41: // |m_clientBinding| can only be bound if |m_connected| is ...
3 years, 8 months ago (2017-03-30 04:20:48 UTC) #58
juncai
https://codereview.chromium.org/2752663002/diff/260001/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp File third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp (right): https://codereview.chromium.org/2752663002/diff/260001/third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp#newcode41 third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp:41: // |m_clientBinding| can only be bound if |m_connected| is ...
3 years, 8 months ago (2017-03-30 18:44:58 UTC) #61
scheib
https://codereview.chromium.org/2752663002/diff/280001/content/browser/bluetooth/web_bluetooth_service_impl.cc File content/browser/bluetooth/web_bluetooth_service_impl.cc (right): https://codereview.chromium.org/2752663002/diff/280001/content/browser/bluetooth/web_bluetooth_service_impl.cc#newcode841 content/browser/bluetooth/web_bluetooth_service_impl.cc:841: RecordWebBluetoothFunctionCall( Please address the UMA patch, and make this ...
3 years, 8 months ago (2017-03-30 22:45:51 UTC) #64
ortuno
3 years, 8 months ago (2017-03-31 06:07:29 UTC) #65
https://codereview.chromium.org/2752663002/diff/260001/third_party/WebKit/Sou...
File third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp
(right):

https://codereview.chromium.org/2752663002/diff/260001/third_party/WebKit/Sou...
third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp:124:
if (m_connected) {
On 2017/03/30 at 18:44:57, juncai wrote:
> On 2017/03/30 04:20:48, ortuno wrote:
> > hmm I think this is breaking spec'ed behavior e.g.
> > 
> > connect().then(() => {
> >   connect();
> >   disconnect();
> > });
> > 
> > Based on the spec'ed algorithm the second call to connect should reject:
Step
> > 5.2 says to queue a task, at which point disconnect runs, the algorithm for
> > disconnect immediately removes the promise from the active algorithms map so
> > when step 5.2.1 runs the promise should reject.
> > 
> >
https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver...
> 
> hmm... I am not sure I understand it. When the second connect() is called, the
connect() code is not aware of the following code has a disconnect() call, so it
can't act upon it. Similar to the following:
> connect().then(() => {
>   connect();
>   ...
>   ...
> });
> And since this is the second call connect(), it makes sense to just resolve
the promise if |m_connected| is true.

According to step 5.2 of the connect() algorithm in the spec we *have* to post a
task before resolving the promise. If we don't then the bug I described before
will happen.

This is what should happen in the code above based on the spec'ed functions:

// When the second connect is called:
1. Steps 1, 2, 3, 4, and 5.1 of the connect()[1] algorithm run
2. Step 5.2 queues a task to execute steps 5.2.*
// disconnect is called
3. Step 1 of the disconnect()[2] algorithm immediately clears the active
algorithms map
4. Steps 2, 3, 4, 5 of the disconnect() algorithm run
5. The task posted by 5.2 of the connect() algorithm starts running
6. Step 5.2.1 checks the active algorithms map and since the connect() promise
is no longer there (it was removed by step 1 of the disconnect() algorithm),
then the promise rejects.

But as is this code will resolve the promise immediately and the spec'ed
behavior will not happen. Before the "queue a task" part of the algorithm was
being done by calling RemoteGATTServerConnect.

[1]
https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver...
[2]
https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver...

https://codereview.chromium.org/2752663002/diff/260001/third_party/WebKit/Sou...
third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTServer.cpp:131:
m_clientBinding.set_connection_error_handler(convertToBaseCallback(
On 2017/03/30 at 18:44:57, juncai wrote:
> On 2017/03/30 04:20:48, ortuno wrote:
> > Since you are binding this here and in the browser wouldn't you get a
> > notification if the connection fails since you are closing the binding?
> 
> Yes, only if |m_connected| is true. And in that situation, a notification is
necessary, right?

I think the fact that the client is receiving connection notifications before an
actual connection is made doesn't make much sense, is very subtle and could end
up causing bugs. We should refactor the code so that we only get notifications
after the connection is made.

Powered by Google App Engine
This is Rietveld 408576698