From fa968566aec6a7e007792c112b16060748b63fa9 Mon Sep 17 00:00:00 2001 From: reillyg Date: Wed, 23 Mar 2016 14:02:55 -0700 Subject: Fix IPC loop in DeviceManager::GetDeviceChanges. DeviceManagerImpl::MaybeRunDeviceChangesCallback is supposed to wait until there are changes to the set of connected devices before calling the stored callback. A bug introduced in r379393 removed this check which meant that calls to GetDeviceChanges would return immediately. As most callers issue another call to this method when it returns this would lead to an infinite loop. This change adds a test case exercising this case. BUG=None Review URL: https://codereview.chromium.org/1826883002 Cr-Commit-Position: refs/heads/master@{#382924} --- device/usb/mojo/device_manager_impl_unittest.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'device/usb/mojo/device_manager_impl_unittest.cc') diff --git a/device/usb/mojo/device_manager_impl_unittest.cc b/device/usb/mojo/device_manager_impl_unittest.cc index 9fc01df..3a0d50c 100644 --- a/device/usb/mojo/device_manager_impl_unittest.cc +++ b/device/usb/mojo/device_manager_impl_unittest.cc @@ -210,6 +210,21 @@ TEST_F(USBDeviceManagerImplTest, GetDeviceChanges) { loop.QuitClosure())); loop.Run(); } + + { + std::set added_guids; + std::set removed_guids; + added_guids.insert(device0->guid()); + base::RunLoop loop; + device_manager->GetDeviceChanges(base::Bind(&ExpectDeviceChangesAndThen, + added_guids, removed_guids, + loop.QuitClosure())); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, + base::Bind(&MockUsbService::AddDevice, + base::Unretained(device_client_.usb_service()), device0)); + loop.Run(); + } } } // namespace usb -- cgit v1.1