DeviceMonitorMac: move CrAVFoundationDeviceObserver and most of SuspendObserverDelega...
commita0188671ebf998dd14c46b1be0e1bbb817dd0480
authormcasas@chromium.org <mcasas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Fri, 11 Jul 2014 22:56:39 +0000 (11 22:56 +0000)
committermcasas@chromium.org <mcasas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Fri, 11 Jul 2014 22:56:39 +0000 (11 22:56 +0000)
tree82de9744ff57c742d4d388a4cd98a6328a21ad79
parentec5297c664c3275bd5386664b69459831f4230a6
DeviceMonitorMac: move CrAVFoundationDeviceObserver and most of SuspendObserverDelegate to UI Thread

(tl; dr : Move all operations to UI thread except device enumerations.)

CrAVFoundationObserver was located in Device Thread based
on the assumption that OS KVO callbacks would come on that
thread too, but instead they come from UI thread.
-observeValueForKeyPath:... is then called in UI thread, and since
the rest of the actions of the class are small, this CL moves the
whole class to UI thread.

Its overlord SuspendObserverDelegate (best not use acronyms
for its name :) ), however, lives a mixed life in UI and Device
 threads. The model is simplified by making it work always in
UI thread _except_ for device enumerations (done via
[AVCaptureDeviceglue devices]).

AVFoundationMonitorImpl will destroy SuspendObserverDelegate
in UI thread and that in turn destroys CrAVFoundationObserver
in that very thread, thus cleaning up the multi threading and
hopefully addressing the bug reports of a small but consistent
crash rate (~2 crashes every four canaries or so).

UI Thread checks are added everywhere.

The code around CrAVFoundationDeviceObserver::dealloc and
-stopObserving is refactored in order to avoid a redundant
search-for-device in |monitoredDevices_|.

BUG=366087

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282723 0039d316-1c4b-4281-b951-d872f2087c98
content/browser/device_monitor_mac.mm