| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_GEOLOCATION_WIFI_DATA_PROVIDER_CHROMEOS_H_ | 5 #ifndef DEVICE_GEOLOCATION_WIFI_DATA_PROVIDER_CHROMEOS_H_ |
| 6 #define DEVICE_GEOLOCATION_WIFI_DATA_PROVIDER_CHROMEOS_H_ | 6 #define DEVICE_GEOLOCATION_WIFI_DATA_PROVIDER_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "device/geolocation/wifi_data_provider.h" | 12 #include "device/geolocation/wifi_data_provider.h" |
| 13 #include "device/geolocation/wifi_polling_policy.h" | 13 #include "device/geolocation/wifi_polling_policy.h" |
| 14 | 14 |
| 15 namespace base { | |
| 16 class SingleThreadTaskRunner; | |
| 17 } | |
| 18 | |
| 19 namespace device { | 15 namespace device { |
| 20 | 16 |
| 21 class DEVICE_GEOLOCATION_EXPORT WifiDataProviderChromeOs | 17 class DEVICE_GEOLOCATION_EXPORT WifiDataProviderChromeOs |
| 22 : public WifiDataProvider { | 18 : public WifiDataProvider { |
| 23 public: | 19 public: |
| 24 WifiDataProviderChromeOs(); | 20 WifiDataProviderChromeOs(); |
| 25 | 21 |
| 26 // WifiDataProvider | 22 // WifiDataProvider |
| 27 void StartDataProvider() override; | 23 void StartDataProvider() override; |
| 28 void StopDataProvider() override; | 24 void StopDataProvider() override; |
| 29 bool GetData(WifiData* data) override; | 25 bool GetData(WifiData* data) override; |
| 30 | 26 |
| 31 private: | 27 private: |
| 32 friend class GeolocationChromeOsWifiDataProviderTest; | 28 friend class GeolocationChromeOsWifiDataProviderTest; |
| 33 ~WifiDataProviderChromeOs() override; | 29 ~WifiDataProviderChromeOs() override; |
| 34 | 30 |
| 35 // UI thread | 31 // NetworkHandler thread |
| 36 void DoWifiScanTaskOnUIThread(); // The polling task | 32 void DoWifiScanTaskOnNetworkHandlerThread(); |
| 37 void DoStartTaskOnUIThread(); | |
| 38 | 33 |
| 39 // Client thread | 34 // Client thread |
| 40 void DidWifiScanTaskNoResults(); | 35 void DidWifiScanTaskNoResults(); |
| 41 void DidWifiScanTask(const WifiData& new_data); | 36 void DidWifiScanTask(const WifiData& new_data); |
| 42 | 37 |
| 43 // Will schedule a scan; i.e. enqueue DoWifiScanTask deferred task. | 38 // Will schedule a scan; i.e. enqueue DoWifiScanTask deferred task. |
| 44 void ScheduleNextScan(int interval); | 39 void ScheduleNextScan(int interval); |
| 45 | 40 |
| 46 // Will schedule starting of the scanning process. | 41 // Will schedule starting of the scanning process. |
| 47 void ScheduleStart(); | 42 void ScheduleStart(); |
| 48 | 43 |
| 49 // Will schedule stopping of the scanning process. | 44 // Will schedule stopping of the scanning process. |
| 50 void ScheduleStop(); | 45 void ScheduleStop(); |
| 51 | 46 |
| 52 // Get access point data from chromeos. | 47 // Get access point data from chromeos. |
| 53 bool GetAccessPointData(WifiData::AccessPointDataSet* data); | 48 bool GetAccessPointData(WifiData::AccessPointDataSet* data); |
| 54 | 49 |
| 55 // Controls the polling update interval. (client thread) | 50 // Controls the polling update interval. (client thread) |
| 56 std::unique_ptr<WifiPollingPolicy> polling_policy_; | 51 std::unique_ptr<WifiPollingPolicy> polling_policy_; |
| 57 | 52 |
| 58 // The latest wifi data. (client thread) | 53 // The latest wifi data. (client thread) |
| 59 WifiData wifi_data_; | 54 WifiData wifi_data_; |
| 60 | 55 |
| 61 // Whether we have strated the data provider. (client thread) | 56 // Whether we have strated the data provider. (client thread) |
| 62 bool started_; | 57 bool started_; |
| 63 | 58 |
| 64 // Whether we've successfully completed a scan for WiFi data. (client thread) | 59 // Whether we've successfully completed a scan for WiFi data. (client thread) |
| 65 bool is_first_scan_complete_; | 60 bool is_first_scan_complete_; |
| 66 | 61 |
| 67 // Used to PostTask()s from the geolocation thread to creation thread. | |
| 68 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(WifiDataProviderChromeOs); | 62 DISALLOW_COPY_AND_ASSIGN(WifiDataProviderChromeOs); |
| 71 }; | 63 }; |
| 72 | 64 |
| 73 } // namespace device | 65 } // namespace device |
| 74 | 66 |
| 75 #endif // DEVICE_GEOLOCATION_WIFI_DATA_PROVIDER_CHROMEOS_H_ | 67 #endif // DEVICE_GEOLOCATION_WIFI_DATA_PROVIDER_CHROMEOS_H_ |
| OLD | NEW |