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

Issue 16316004: Separate usb device handle from usb device. (deprecate) (Closed)

Created:
7 years, 6 months ago by Bei Zhang
Modified:
7 years, 4 months ago
CC:
chromium-reviews, Aaron Boodman, chromium-apps-reviews_chromium.org
Visibility:
Public.

Description

Separate usb device handle from usb device. *This CL has been splitted to four steps*: 1. Upgrade libusb and introduce a mechanism to interrupt libusb_handle_events. _Done_ 2. Separate UsbDevice and UsbDeviceHandle. 3. Introduce UsbTransfer and improve life cycle management of transfers. 4. Introduce `chrome.usb.getDevices` and `chrome.usb.openDevice` API. BUG=223817

Patch Set 1 : Separate usb device handle from usb device. #

Patch Set 2 : Fix Windows compile and a bug. #

Total comments: 1

Patch Set 3 : Fix build #

Total comments: 9

Patch Set 4 : Fix the threading mess #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1620 lines, -1113 lines) Patch
M chrome/browser/extensions/api/usb/usb_api.h View 1 2 5 chunks +60 lines, -18 lines 0 comments Download
M chrome/browser/extensions/api/usb/usb_api.cc View 1 2 3 31 chunks +263 lines, -158 lines 0 comments Download
M chrome/browser/extensions/api/usb/usb_apitest.cc View 1 2 4 chunks +37 lines, -39 lines 0 comments Download
M chrome/browser/extensions/api/usb/usb_device_resource.h View 1 2 3 3 chunks +48 lines, -7 lines 0 comments Download
M chrome/browser/extensions/api/usb/usb_device_resource.cc View 1 2 3 2 chunks +131 lines, -3 lines 0 comments Download
M chrome/browser/extensions/extension_function_histogram_value.h View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
D chrome/browser/usb/usb_device.h View 1 chunk +0 lines, -169 lines 0 comments Download
D chrome/browser/usb/usb_device.cc View 1 chunk +0 lines, -341 lines 0 comments Download
A + chrome/browser/usb/usb_device_handle.h View 1 2 3 5 chunks +64 lines, -56 lines 0 comments Download
A chrome/browser/usb/usb_device_handle.cc View 1 2 3 1 chunk +439 lines, -0 lines 0 comments Download
M chrome/browser/usb/usb_interface.h View 1 2 6 chunks +8 lines, -14 lines 0 comments Download
M chrome/browser/usb/usb_interface.cc View 1 2 7 chunks +18 lines, -23 lines 0 comments Download
M chrome/browser/usb/usb_service.h View 1 2 3 1 chunk +40 lines, -54 lines 0 comments Download
M chrome/browser/usb/usb_service.cc View 1 2 3 4 chunks +239 lines, -98 lines 0 comments Download
A chrome/browser/usb/usb_service_unittest.cc View 1 2 3 1 chunk +29 lines, -0 lines 0 comments Download
M chrome/chrome_browser.gypi View 1 2 3 1 chunk +2 lines, -2 lines 0 comments Download
M chrome/chrome_tests_unit.gypi View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M chrome/common/extensions/api/usb.idl View 1 2 3 3 chunks +81 lines, -35 lines 0 comments Download
M chrome/test/data/extensions/api_test/usb/device_handling/test.js View 1 2 1 chunk +26 lines, -23 lines 0 comments Download
M chrome/test/data/extensions/api_test/usb/invalid_length_transfer/test.js View 1 2 2 chunks +10 lines, -9 lines 0 comments Download
M chrome/test/data/extensions/api_test/usb/list_interfaces/test.js View 1 2 1 chunk +5 lines, -4 lines 0 comments Download
M chrome/test/data/extensions/api_test/usb/transfer_event/test.js View 1 2 1 chunk +45 lines, -41 lines 0 comments Download
M chrome/test/data/extensions/api_test/usb/transfer_failure/test.js View 1 2 2 chunks +11 lines, -10 lines 0 comments Download
M chrome/test/data/extensions/api_test/usb/zero_length_transfer/test.js View 1 2 1 chunk +10 lines, -9 lines 0 comments Download
M third_party/libusb/README.chromium View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
A third_party/libusb/libusb_send_event.patch View 1 2 3 1 chunk +36 lines, -0 lines 0 comments Download
M third_party/libusb/src/libusb/core.c View 1 2 3 1 chunk +9 lines, -0 lines 0 comments Download
M third_party/libusb/src/libusb/libusb.h View 1 2 3 1 chunk +5 lines, -0 lines 0 comments Download

Messages

Total messages: 11 (0 generated)
Bei Zhang
Hi Antoney, Please review. Thanks, Bei
7 years, 6 months ago (2013-06-05 23:38:19 UTC) #1
asargent_no_longer_on_chrome
https://codereview.chromium.org/16316004/diff/24001/chrome/common/extensions/api/usb.idl File chrome/common/extensions/api/usb.idl (right): https://codereview.chromium.org/16316004/diff/24001/chrome/common/extensions/api/usb.idl#newcode33 chrome/common/extensions/api/usb.idl:33: }; Because this API is now released to stable, ...
7 years, 6 months ago (2013-06-06 21:57:29 UTC) #2
akalin
Drive-by https://codereview.chromium.org/16316004/diff/97002/chrome/browser/usb/usb_device_handle.h File chrome/browser/usb/usb_device_handle.h (right): https://codereview.chromium.org/16316004/diff/97002/chrome/browser/usb/usb_device_handle.h#newcode47 chrome/browser/usb/usb_device_handle.h:47: class UsbDeviceHandle : public base::RefCountedThreadSafe<UsbDeviceHandle>, This doesn't make ...
7 years, 6 months ago (2013-06-13 21:53:12 UTC) #3
Bei Zhang
https://codereview.chromium.org/16316004/diff/97002/chrome/browser/usb/usb_service.cc File chrome/browser/usb/usb_service.cc (right): https://codereview.chromium.org/16316004/diff/97002/chrome/browser/usb/usb_service.cc#newcode56 chrome/browser/usb/usb_service.cc:56: volatile bool running_; I thought about this very carefully ...
7 years, 6 months ago (2013-06-13 22:36:22 UTC) #4
akalin
On 2013/06/13 22:36:22, Bei Zhang wrote: > https://codereview.chromium.org/16316004/diff/97002/chrome/browser/usb/usb_service.cc > File chrome/browser/usb/usb_service.cc (right): > > https://codereview.chromium.org/16316004/diff/97002/chrome/browser/usb/usb_service.cc#newcode56 ...
7 years, 6 months ago (2013-06-14 00:40:05 UTC) #5
akalin
https://codereview.chromium.org/16316004/diff/97002/chrome/browser/usb/usb_service.cc File chrome/browser/usb/usb_service.cc (right): https://codereview.chromium.org/16316004/diff/97002/chrome/browser/usb/usb_service.cc#newcode200 chrome/browser/usb/usb_service.cc:200: to_release.swap(it->second); What's going on here? You shouldn't have to ...
7 years, 6 months ago (2013-06-14 00:43:24 UTC) #6
Bei Zhang
On 2013/06/14 00:40:05, akalin wrote: > On 2013/06/13 22:36:22, Bei Zhang wrote: > > > ...
7 years, 6 months ago (2013-06-14 04:59:07 UTC) #7
Bei Zhang
Whoops. Mis-clicked the button. ... NonThreadSafe is used to indicate non-thread-safe objects that are appears ...
7 years, 6 months ago (2013-06-14 05:06:01 UTC) #8
Bei Zhang
Hi Akalin, I managed to remove the swap-and-ReleaseSoon code (among another fix on the running_ ...
7 years, 6 months ago (2013-06-14 05:58:24 UTC) #9
akalin
https://codereview.chromium.org/16316004/diff/97002/chrome/browser/usb/usb_service.cc File chrome/browser/usb/usb_service.cc (right): https://codereview.chromium.org/16316004/diff/97002/chrome/browser/usb/usb_service.cc#newcode200 chrome/browser/usb/usb_service.cc:200: to_release.swap(it->second); On 2013/06/14 05:06:02, Bei Zhang wrote: > On ...
7 years, 6 months ago (2013-06-14 06:24:38 UTC) #10
akalin
7 years, 6 months ago (2013-06-14 06:35:26 UTC) #11
On 2013/06/14 05:06:01, Bei Zhang wrote:
> Whoops. Mis-clicked the button.
> ... NonThreadSafe is used to indicate non-thread-safe objects that are appears
> to be thread safe:
> 
>
https://code.google.com/p/chromium/codesearch#chromium/src/base/threading/non...
> 
> RCTS makes AddRef and Release thread safe but not effecting any other methods.
I
> think an otherwise non-thread-safe object can have thread-safe methods, and
> which doesn't make it thread-safe. On in other words, RCTS is an orthogonal to
> NonThreadSafe.

What you say is technically true, but it's still a code smell. There is a strong
convention/implication that a class inheriting from NonThreadSafe is completely
non-thread-safe, i.e. that CalledOnValidThread() is asserted for each member
function.

On the other hand, inheriting from RCTS means that AddRef/Release are
thread-safe. Either you pass around pointers to your objects from multiple
threads or you don't. If you don't, then you don't need RCTS. If you do pass
them around, then you either use them from multiple threads or you don't. If you
do, then that's an error. If you don't, i.e. you always end up using the object
on the correct thread, then you can almost always find an owner for your object
on that thread, and you don't need ref-counting at all (because the owner can
manage your object's lifetime by itself).

I hope that clears things up.

Powered by Google App Engine
This is Rietveld 408576698