Commit 779a78fb authored by robliao@chromium.org's avatar robliao@chromium.org

Initial Geolocation Wifi Scan Checking Fix for CrOS

The ChromeOS Wifi provider was erronously reporting an initial
scan of 0 wifi access points when the shill's scanning had not
yet completed. This resulted in a fallback to IP geo for the
first request and then proper Wifi based location on the
second request.

BUG=236418

Review URL: https://chromiumcodereview.appspot.com/23889009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221737 0039d316-1c4b-4281-b951-d872f2087c98
parent 8b0e097b
......@@ -70,14 +70,14 @@ void WifiDataProviderChromeOs::DoWifiScanTaskOnUIThread() {
WifiData new_data;
if (!GetAccessPointData(&new_data.access_point_data)) {
if (GetAccessPointData(&new_data.access_point_data)) {
client_loop()->PostTask(
FROM_HERE,
base::Bind(&WifiDataProviderChromeOs::DidWifiScanTaskNoResults, this));
base::Bind(&WifiDataProviderChromeOs::DidWifiScanTask, this, new_data));
} else {
client_loop()->PostTask(
FROM_HERE,
base::Bind(&WifiDataProviderChromeOs::DidWifiScanTask, this, new_data));
base::Bind(&WifiDataProviderChromeOs::DidWifiScanTaskNoResults, this));
}
}
......@@ -87,7 +87,6 @@ void WifiDataProviderChromeOs::DidWifiScanTaskNoResults() {
// in between DoWifiScanTaskOnUIThread and this method).
if (started_)
ScheduleNextScan(polling_policy_->NoWifiInterval());
MaybeRunCallbacks(false);
}
void WifiDataProviderChromeOs::DidWifiScanTask(const WifiData& new_data) {
......@@ -100,10 +99,7 @@ void WifiDataProviderChromeOs::DidWifiScanTask(const WifiData& new_data) {
polling_policy_->UpdatePollingInterval(update_available);
ScheduleNextScan(polling_policy_->PollingInterval());
}
MaybeRunCallbacks(update_available);
}
void WifiDataProviderChromeOs::MaybeRunCallbacks(bool update_available) {
if (update_available || !is_first_scan_complete_) {
is_first_scan_complete_ = true;
RunCallbacks();
......@@ -140,9 +136,12 @@ void WifiDataProviderChromeOs::ScheduleStart() {
bool WifiDataProviderChromeOs::GetAccessPointData(
WifiData::AccessPointDataSet* result) {
chromeos::WifiAccessPointVector access_points;
// If wifi isn't enabled, we've effectively completed the task.
// Return true to indicate an empty access point list.
if (!chromeos::NetworkHandler::Get()->geolocation_handler()->wifi_enabled())
return false;
return true;
chromeos::WifiAccessPointVector access_points;
int64 age_ms = 0;
if (!chromeos::NetworkHandler::Get()->geolocation_handler()->
GetWifiAccessPoints(&access_points, &age_ms)) {
......
......@@ -31,7 +31,6 @@ class CONTENT_EXPORT WifiDataProviderChromeOs
// Client thread
void DidWifiScanTaskNoResults();
void DidWifiScanTask(const WifiData& new_data);
void MaybeRunCallbacks(bool update_available);
// Will schedule a scan; i.e. enqueue DoWifiScanTask deferred task.
void ScheduleNextScan(int interval);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment