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

Issue 980023002: Move device/usb classes from the FILE thread to UI thread. (Closed)

Created:
5 years, 9 months ago by Reilly Grant (use Gerrit)
Modified:
5 years, 7 months ago
CC:
chromium-reviews, extensions-reviews_chromium.org, tfarina, yurys, devtools-reviews_chromium.org, chromium-apps-reviews_chromium.org, aandrey+blink_chromium.org, pfeldman
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Move device/usb classes from the FILE thread to UI thread. Code that interacts with device/usb often lives on the UI thread. As with the recent migration of device/hid (issue 422540) moving ownership of these classes to the UI thread makes calling code substancially simplier. Blocking operations are handled internally by posting tasks to the FILE thread and returning a result to the UI thread asynchronously. This change paves the way for replacing libusb with platform-specific implementations of these classes that may have different thread usage requirements (as is the case in the device/hid code). BUG=427985 Committed: https://crrev.com/b87cb277526092e101ce29f2ad0393f6247cc39e Cr-Commit-Position: refs/heads/master@{#325491}

Patch Set 1 : #

Total comments: 10

Patch Set 2 : Addressed first round of rocket@ feedback. #

Total comments: 6

Patch Set 3 : Second round of comments from rockot@. #

Patch Set 4 : Allow USB transfer calls from any thread again. #

Total comments: 8

Patch Set 5 : Switch back to calling PostTask in BulkTransfer callbacks. #

Patch Set 6 : Assert UI message loop is idle. #

Total comments: 12

Patch Set 7 : Add more thread assertions. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+2887 lines, -2869 lines) Patch
M chrome/browser/chrome_device_client.cc View 1 chunk +6 lines, -4 lines 0 comments Download
M chrome/browser/devtools/device/usb/android_usb_browsertest.cc View 1 2 3 4 5 18 chunks +101 lines, -167 lines 0 comments Download
M chrome/browser/devtools/device/usb/android_usb_device.h View 1 2 3 3 chunks +3 lines, -4 lines 0 comments Download
M chrome/browser/devtools/device/usb/android_usb_device.cc View 1 2 3 4 5 6 17 chunks +213 lines, -189 lines 0 comments Download
M chrome/browser/extensions/api/device_permissions_manager_unittest.cc View 1 4 chunks +122 lines, -166 lines 0 comments Download
M device/hid/hid_connection_unittest.cc View 4 chunks +8 lines, -29 lines 0 comments Download
M device/hid/hid_service.cc View 2 chunks +6 lines, -4 lines 0 comments Download
M device/test/usb_test_gadget.h View 3 chunks +7 lines, -2 lines 0 comments Download
M device/test/usb_test_gadget_impl.cc View 6 chunks +420 lines, -340 lines 0 comments Download
M device/usb/usb_context.cc View 3 chunks +13 lines, -15 lines 0 comments Download
M device/usb/usb_device.h View 1 3 chunks +21 lines, -24 lines 0 comments Download
M device/usb/usb_device.cc View 1 1 chunk +12 lines, -2 lines 0 comments Download
M device/usb/usb_device_filter_unittest.cc View 1 7 chunks +20 lines, -8 lines 0 comments Download
M device/usb/usb_device_handle.h View 1 2 3 2 chunks +23 lines, -24 lines 0 comments Download
M device/usb/usb_device_handle_impl.h View 1 2 3 6 chunks +98 lines, -39 lines 0 comments Download
M device/usb/usb_device_handle_impl.cc View 1 2 3 19 chunks +440 lines, -318 lines 0 comments Download
M device/usb/usb_device_handle_unittest.cc View 1 8 chunks +106 lines, -51 lines 0 comments Download
M device/usb/usb_device_impl.h View 1 5 chunks +21 lines, -24 lines 0 comments Download
M device/usb/usb_device_impl.cc View 1 6 chunks +38 lines, -167 lines 0 comments Download
M device/usb/usb_service.h View 1 4 chunks +11 lines, -14 lines 0 comments Download
M device/usb/usb_service.cc View 3 chunks +8 lines, -38 lines 0 comments Download
M device/usb/usb_service_impl.h View 3 chunks +73 lines, -20 lines 0 comments Download
M device/usb/usb_service_impl.cc View 7 chunks +421 lines, -193 lines 0 comments Download
M device/usb/usb_service_unittest.cc View 2 chunks +14 lines, -13 lines 0 comments Download
M extensions/browser/api/device_permissions_manager.h View 1 2 7 chunks +14 lines, -32 lines 0 comments Download
M extensions/browser/api/device_permissions_manager.cc View 1 2 13 chunks +29 lines, -84 lines 0 comments Download
M extensions/browser/api/device_permissions_prompt.h View 1 2 6 chunks +13 lines, -28 lines 0 comments Download
M extensions/browser/api/device_permissions_prompt.cc View 1 2 7 chunks +34 lines, -107 lines 0 comments Download
M extensions/browser/api/usb/usb_api.h View 1 5 chunks +134 lines, -153 lines 0 comments Download
M extensions/browser/api/usb/usb_api.cc View 1 26 chunks +371 lines, -453 lines 0 comments Download
M extensions/browser/api/usb/usb_apitest.cc View 1 2 3 10 chunks +51 lines, -83 lines 0 comments Download
M extensions/browser/api/usb/usb_device_resource.h View 1 chunk +1 line, -1 line 0 comments Download
M extensions/browser/api/usb/usb_event_router.h View 4 chunks +9 lines, -8 lines 0 comments Download
M extensions/browser/api/usb/usb_event_router.cc View 7 chunks +17 lines, -58 lines 0 comments Download
M extensions/shell/browser/shell_device_client.cc View 2 chunks +6 lines, -4 lines 0 comments Download
M extensions/test/data/api_test/usb/reset_device/test.js View 1 chunk +3 lines, -3 lines 0 comments Download

Messages

Total messages: 36 (11 generated)
Reilly Grant (use Gerrit)
Please take a look at the //device/usb parts of this Ken. I'm so sorry for ...
5 years, 8 months ago (2015-04-06 23:45:01 UTC) #6
Ken Rockot(use gerrit already)
Partial review - still need to look at UsbService; I don't mind doing the extensions ...
5 years, 8 months ago (2015-04-07 22:09:44 UTC) #7
Ken Rockot(use gerrit already)
https://codereview.chromium.org/980023002/diff/100001/extensions/browser/api/device_permissions_manager.h File extensions/browser/api/device_permissions_manager.h (right): https://codereview.chromium.org/980023002/diff/100001/extensions/browser/api/device_permissions_manager.h#newcode164 extensions/browser/api/device_permissions_manager.h:164: DevicePermissions* Get(const std::string& extension_id) const; nit: I find Get ...
5 years, 8 months ago (2015-04-08 07:45:57 UTC) #8
Reilly Grant (use Gerrit)
https://codereview.chromium.org/980023002/diff/80001/device/usb/usb_device.h File device/usb/usb_device.h (right): https://codereview.chromium.org/980023002/diff/80001/device/usb/usb_device.h#newcode25 device/usb/usb_device.h:25: typedef base::Callback<void(scoped_refptr<UsbDeviceHandle>)> OpenCallback; On 2015/04/07 22:09:43, Ken Rockot wrote: ...
5 years, 8 months ago (2015-04-08 21:39:04 UTC) #9
Ken Rockot(use gerrit already)
cool, lgtm On 2015/04/08 21:39:04, reillyg wrote: > It's helpful to have access to ExtensionFunction ...
5 years, 8 months ago (2015-04-08 21:52:26 UTC) #10
Reilly Grant (use Gerrit)
Adding dgozman@ to review the DevTools parts.
5 years, 8 months ago (2015-04-08 22:12:07 UTC) #12
dgozman
I'am wondering how does this make calling code easier? Judging by chrome/browser/devtools/device/usb/android_usb_device.{h,cc}, code is approximately ...
5 years, 8 months ago (2015-04-09 13:21:10 UTC) #13
Reilly Grant (use Gerrit)
On 2015/04/09 13:21:10, dgozman wrote: > I'am wondering how does this make calling code easier? ...
5 years, 8 months ago (2015-04-09 16:57:37 UTC) #14
dgozman
> I've considered keeping UsbService and UsbDevice on the UI thread while handing > UsbDeviceHandle ...
5 years, 8 months ago (2015-04-10 11:34:47 UTC) #15
Reilly Grant (use Gerrit)
On 2015/04/10 11:34:47, dgozman wrote: > > I've considered keeping UsbService and UsbDevice on the ...
5 years, 8 months ago (2015-04-10 18:25:17 UTC) #16
dgozman
> USB uses the FILE thread under the hood to call platform APIs that provide ...
5 years, 8 months ago (2015-04-13 15:52:19 UTC) #17
Reilly Grant (use Gerrit)
On 2015/04/13 15:52:19, dgozman wrote: > > USB uses the FILE thread under the hood ...
5 years, 8 months ago (2015-04-13 18:01:07 UTC) #18
Reilly Grant (use Gerrit)
I've added back the code to allow USB transfer calls from any thread. Let's revisit ...
5 years, 8 months ago (2015-04-13 23:30:24 UTC) #19
vkuzkokov
https://codereview.chromium.org/980023002/diff/140001/chrome/browser/devtools/device/usb/android_usb_browsertest.cc File chrome/browser/devtools/device/usb/android_usb_browsertest.cc (right): https://codereview.chromium.org/980023002/diff/140001/chrome/browser/devtools/device/usb/android_usb_browsertest.cc#newcode427 chrome/browser/devtools/device/usb/android_usb_browsertest.cc:427: bool Close(scoped_refptr<UsbDeviceHandle> handle) override { return true; } nit: ...
5 years, 8 months ago (2015-04-15 14:15:46 UTC) #21
Reilly Grant (use Gerrit)
https://codereview.chromium.org/980023002/diff/140001/chrome/browser/devtools/device/usb/android_usb_browsertest.cc File chrome/browser/devtools/device/usb/android_usb_browsertest.cc (right): https://codereview.chromium.org/980023002/diff/140001/chrome/browser/devtools/device/usb/android_usb_browsertest.cc#newcode427 chrome/browser/devtools/device/usb/android_usb_browsertest.cc:427: bool Close(scoped_refptr<UsbDeviceHandle> handle) override { return true; } On ...
5 years, 8 months ago (2015-04-15 20:03:47 UTC) #22
vkuzkokov
https://codereview.chromium.org/980023002/diff/140001/chrome/browser/devtools/device/usb/android_usb_browsertest.cc File chrome/browser/devtools/device/usb/android_usb_browsertest.cc (right): https://codereview.chromium.org/980023002/diff/140001/chrome/browser/devtools/device/usb/android_usb_browsertest.cc#newcode628 chrome/browser/devtools/device/usb/android_usb_browsertest.cc:628: void Shutdown() { base::MessageLoop::current()->Quit(); } On 2015/04/15 20:03:47, reillyg ...
5 years, 8 months ago (2015-04-15 21:58:06 UTC) #23
Reilly Grant (use Gerrit)
https://codereview.chromium.org/980023002/diff/140001/chrome/browser/devtools/device/usb/android_usb_browsertest.cc File chrome/browser/devtools/device/usb/android_usb_browsertest.cc (right): https://codereview.chromium.org/980023002/diff/140001/chrome/browser/devtools/device/usb/android_usb_browsertest.cc#newcode628 chrome/browser/devtools/device/usb/android_usb_browsertest.cc:628: void Shutdown() { base::MessageLoop::current()->Quit(); } On 2015/04/15 21:58:06, vkuzkokov ...
5 years, 8 months ago (2015-04-15 22:26:45 UTC) #24
vkuzkokov
On 2015/04/15 22:26:45, reillyg wrote: > https://codereview.chromium.org/980023002/diff/140001/chrome/browser/devtools/device/usb/android_usb_browsertest.cc > File chrome/browser/devtools/device/usb/android_usb_browsertest.cc (right): > > https://codereview.chromium.org/980023002/diff/140001/chrome/browser/devtools/device/usb/android_usb_browsertest.cc#newcode628 > ...
5 years, 8 months ago (2015-04-16 12:06:03 UTC) #25
dgozman
lgtm modulo comments Vladislav will follow up with devtools-side cleanup to remove unnecessary thread-hopping here. ...
5 years, 8 months ago (2015-04-16 12:47:18 UTC) #26
Reilly Grant (use Gerrit)
James, please take a look at the change to chrome_device_client.cc. https://codereview.chromium.org/980023002/diff/180001/chrome/browser/devtools/device/usb/android_usb_device.cc File chrome/browser/devtools/device/usb/android_usb_device.cc (right): https://codereview.chromium.org/980023002/diff/180001/chrome/browser/devtools/device/usb/android_usb_device.cc#newcode158 ...
5 years, 8 months ago (2015-04-16 16:24:14 UTC) #28
James Hawkins
lgtm
5 years, 8 months ago (2015-04-16 16:44:17 UTC) #29
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/980023002/200001
5 years, 8 months ago (2015-04-16 18:28:36 UTC) #32
commit-bot: I haz the power
Committed patchset #7 (id:200001)
5 years, 8 months ago (2015-04-16 19:11:13 UTC) #33
commit-bot: I haz the power
Patchset 7 (id:??) landed as https://crrev.com/b87cb277526092e101ce29f2ad0393f6247cc39e Cr-Commit-Position: refs/heads/master@{#325491}
5 years, 8 months ago (2015-04-16 19:12:47 UTC) #34
angiegvalg
5 years, 7 months ago (2015-05-03 03:20:47 UTC) #36
Message was sent while issue was closed.
lgtm

Check my phone

Powered by Google App Engine
This is Rietveld 408576698