blob: 04ad9c43b4480d4f2405a91e4858f61383622207 [file] [log] [blame]
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "device/geolocation/wifi_data_provider.h"
#include "device/geolocation/wifi_polling_policy.h"
namespace base {
class SingleThreadTaskRunner;
namespace device {
class DEVICE_GEOLOCATION_EXPORT WifiDataProviderChromeOs
: public WifiDataProvider {
// WifiDataProvider
void StartDataProvider() override;
void StopDataProvider() override;
bool GetData(WifiData* data) override;
friend class GeolocationChromeOsWifiDataProviderTest;
~WifiDataProviderChromeOs() override;
// UI thread
void DoWifiScanTaskOnUIThread(); // The polling task
void DoStartTaskOnUIThread();
// Client thread
void DidWifiScanTaskNoResults();
void DidWifiScanTask(const WifiData& new_data);
// Will schedule a scan; i.e. enqueue DoWifiScanTask deferred task.
void ScheduleNextScan(int interval);
// Will schedule starting of the scanning process.
void ScheduleStart();
// Will schedule stopping of the scanning process.
void ScheduleStop();
// Get access point data from chromeos.
bool GetAccessPointData(WifiData::AccessPointDataSet* data);
// Controls the polling update interval. (client thread)
std::unique_ptr<WifiPollingPolicy> polling_policy_;
// The latest wifi data. (client thread)
WifiData wifi_data_;
// Whether we have strated the data provider. (client thread)
bool started_;
// Whether we've successfully completed a scan for WiFi data. (client thread)
bool is_first_scan_complete_;
// Used to PostTask()s from the geolocation thread to creation thread.
const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
} // namespace device