Fix a race in the creation of HidConnectionLinux::Helper.
commitbbbc0a493972898fb447022f18b6f05868c33fdd
authorreillyg <reillyg@chromium.org>
Thu, 11 Dec 2014 03:25:59 +0000 (10 19:25 -0800)
committerCommit bot <commit-bot@chromium.org>
Thu, 11 Dec 2014 03:26:30 +0000 (11 03:26 +0000)
treed179a5e94e9c74247584dd40ca3584f7e4911621
parent3dbe3520f4a2a6c3204382443f500f3b651f51f4
Fix a race in the creation of HidConnectionLinux::Helper.

The creation of this object on the FILE thread races with the possible
destruction of the object on the UI thread. The scoped_ptr<> that owns
the pointer may try to destroy the object on the UI thread if the
connection is closed before the helper is started. Generally, updating
the helper_ pointer from the FILE thread is a bad idea.

This patch moves creation of the helper to the UI thread, it is then
detached from that thread when it is started. The HidConnectionLinux no
longer uses a scoped_ptr<> to hold it and instead must always free it
explicitly with DeleteSoon.

BUG=

Review URL: https://codereview.chromium.org/786343003

Cr-Commit-Position: refs/heads/master@{#307850}
device/hid/hid_connection_linux.cc
device/hid/hid_connection_linux.h