[sensors] Own PlatformSensorProvider in DeviceService
This patch changes the ownership model of PlatformSensorProvider from a leaky singleton to something owned by the DeviceService instance. The motivating reason is that it means that we can create a new instance of PlatformSensorProvider for each test rather than having them be reused. This can cause various flaky test failures as demonstrated by the associated issue. To simplify this new ownership the PlatformSensorProvider is now used on the UI thread rather than the IO thread. As blocking calls are already posted to background task runners this change should have no practical effect. To prevent SensorImpl instances from leaking after the test exits (but before the Mojo connection errors are handled) they are now explicitly owned by the SensorProviderImpl that created them. This patch also fixes PlatformSensorAndProviderTestWin to use a base::ScopedCOMInitializer rather than calling CoInitialize manually. This removes another place where state leaked between tests. Bug: 939808 Change-Id: Id18926c4254c1a82310693750d84abe931e0f385 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1693763 Commit-Queue: Reilly Grant <reillyg@chromium.org> Reviewed-by:Ovidio de Jesús Ruiz-Henríquez <odejesush@chromium.org> Cr-Commit-Position: refs/heads/master@{#676110}
Showing
Please register or sign in to comment