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