summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-08 16:20:03 +0000
committerjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-08 16:20:03 +0000
commita23cbcf1bc19f92bee07971e27fd481adc6f24f8 (patch)
treef88228fce43526bce6251282faf98946e80fb65f
parentc0df4c5d2ed5b2f4e1358476aba914399bccc306 (diff)
downloadchromium_src-a23cbcf1bc19f92bee07971e27fd481adc6f24f8.zip
chromium_src-a23cbcf1bc19f92bee07971e27fd481adc6f24f8.tar.gz
chromium_src-a23cbcf1bc19f92bee07971e27fd481adc6f24f8.tar.bz2
Fix flaky win32 wifi provider test.
There was a race condition in provider startup; first call back might arrive before the listener was registerd. This was previous hidden by fact that - until r37850 - an empty wifi result set was always condidered 'different' to another set and so it would create constant stream of update callbacks (hiding the fact the first one maybe missed) BUG=http://crbug.com/34832 TEST=unit_tests.exe --gtest_filter=Win32* --gtest_repeat=10000 --gtest_break_on_failure Review URL: http://codereview.chromium.org/577047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38364 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/geolocation/device_data_provider.h6
-rw-r--r--chrome/browser/geolocation/wifi_data_provider_unittest_win.cc4
-rw-r--r--chrome/browser/geolocation/wifi_data_provider_win.cc2
3 files changed, 7 insertions, 5 deletions
diff --git a/chrome/browser/geolocation/device_data_provider.h b/chrome/browser/geolocation/device_data_provider.h
index 9463636..a03011b 100644
--- a/chrome/browser/geolocation/device_data_provider.h
+++ b/chrome/browser/geolocation/device_data_provider.h
@@ -296,6 +296,10 @@ class DeviceDataProvider {
DCHECK(instance_);
instance_->Ref();
instance_->AddListener(listener);
+ // Start the provider after adding the listener, to avoid any race in
+ // it receiving an early callback.
+ bool started = instance_->impl_->StartDataProvider();
+ DCHECK(started);
return instance_;
}
@@ -327,8 +331,6 @@ class DeviceDataProvider {
DCHECK(factory_function_);
impl_.reset((*factory_function_)());
impl_->SetContainer(this);
- bool started = impl_->StartDataProvider();
- DCHECK(started);
}
virtual ~DeviceDataProvider() {}
diff --git a/chrome/browser/geolocation/wifi_data_provider_unittest_win.cc b/chrome/browser/geolocation/wifi_data_provider_unittest_win.cc
index c97f417..c6a3b60 100644
--- a/chrome/browser/geolocation/wifi_data_provider_unittest_win.cc
+++ b/chrome/browser/geolocation/wifi_data_provider_unittest_win.cc
@@ -138,9 +138,9 @@ TEST_F(Win32WifiDataProviderTest, DoScanWithResults) {
provider_->RemoveListener(&quit_listener);
}
-TEST_F(Win32WifiDataProviderTest, DISABLED_StartThreadViaDeviceDataProvider) {
+TEST_F(Win32WifiDataProviderTest, StartThreadViaDeviceDataProvider) {
MessageLoopQuitListener quit_listener(&main_message_loop_);
- DeviceDataProvider<WifiData>::SetFactory(CreateWin32WifiDataProviderStatic);
+ WifiDataProvider::SetFactory(CreateWin32WifiDataProviderStatic);
DeviceDataProvider<WifiData>::Register(&quit_listener);
main_message_loop_.Run();
DeviceDataProvider<WifiData>::Unregister(&quit_listener);
diff --git a/chrome/browser/geolocation/wifi_data_provider_win.cc b/chrome/browser/geolocation/wifi_data_provider_win.cc
index c8f9ff9..60a1e9b 100644
--- a/chrome/browser/geolocation/wifi_data_provider_win.cc
+++ b/chrome/browser/geolocation/wifi_data_provider_win.cc
@@ -155,7 +155,7 @@ bool GetSystemDirectory(string16 *path);
} // namespace
template<>
-WifiDataProviderImplBase *WifiDataProvider::DefaultFactoryFunction() {
+WifiDataProviderImplBase* WifiDataProvider::DefaultFactoryFunction() {
return new Win32WifiDataProvider();
}