| 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 CHROME_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_CHROMEOS_H_ | 5 #ifndef CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_CHROMEOS_H_ |
| 6 #define CHROME_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_CHROMEOS_H_ | 6 #define CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "content/browser/geolocation/wifi_data_provider_common.h" | 9 #include "content/browser/geolocation/wifi_data_provider_common.h" |
| 10 | 10 |
| 11 namespace chromeos { | 11 namespace content { |
| 12 class NetworkLibrary; | |
| 13 } | |
| 14 | 12 |
| 15 class WifiDataProviderChromeOs : public content::WifiDataProviderImplBase { | 13 class CONTENT_EXPORT WifiDataProviderChromeOs |
| 14 : public WifiDataProviderImplBase { |
| 16 public: | 15 public: |
| 17 WifiDataProviderChromeOs(); | 16 WifiDataProviderChromeOs(); |
| 18 | 17 |
| 19 // WifiDataProviderImplBase | 18 // WifiDataProviderImplBase |
| 20 virtual bool StartDataProvider() OVERRIDE; | 19 virtual bool StartDataProvider() OVERRIDE; |
| 21 virtual void StopDataProvider() OVERRIDE; | 20 virtual void StopDataProvider() OVERRIDE; |
| 22 virtual bool GetData(content::WifiData* data) OVERRIDE; | 21 virtual bool GetData(WifiData* data) OVERRIDE; |
| 23 | |
| 24 // Allows injection of |lib| for testing. | |
| 25 static content::WifiDataProviderCommon::WlanApiInterface* NewWlanApi( | |
| 26 chromeos::NetworkLibrary* lib); | |
| 27 | 22 |
| 28 private: | 23 private: |
| 24 friend class GeolocationChromeOsWifiDataProviderTest; |
| 29 virtual ~WifiDataProviderChromeOs(); | 25 virtual ~WifiDataProviderChromeOs(); |
| 30 | 26 |
| 31 // UI thread | 27 // UI thread |
| 32 void DoWifiScanTaskOnUIThread(); // The polling task | 28 void DoWifiScanTaskOnUIThread(); // The polling task |
| 33 void DoStartTaskOnUIThread(); | 29 void DoStartTaskOnUIThread(); |
| 34 void DoStopTaskOnUIThread(); | |
| 35 | 30 |
| 36 // Client thread | 31 // Client thread |
| 37 void DidWifiScanTaskNoResults(); | 32 void DidWifiScanTaskNoResults(); |
| 38 void DidWifiScanTask(const content::WifiData& new_data); | 33 void DidWifiScanTask(const WifiData& new_data); |
| 39 void MaybeNotifyListeners(bool update_available); | 34 void MaybeNotifyListeners(bool update_available); |
| 40 void DidStartFailed(); | |
| 41 | |
| 42 // WifiDataProviderCommon | |
| 43 virtual content::WifiDataProviderCommon::WlanApiInterface* NewWlanApi(); | |
| 44 virtual content::PollingPolicyInterface* NewPollingPolicy(); | |
| 45 | 35 |
| 46 // Will schedule a scan; i.e. enqueue DoWifiScanTask deferred task. | 36 // Will schedule a scan; i.e. enqueue DoWifiScanTask deferred task. |
| 47 void ScheduleNextScan(int interval); | 37 void ScheduleNextScan(int interval); |
| 48 | 38 |
| 49 // Will schedule starting of the scanning process. | 39 // Will schedule starting of the scanning process. |
| 50 void ScheduleStart(); | 40 void ScheduleStart(); |
| 51 | 41 |
| 52 // Will schedule stopping of the scanning process. | 42 // Will schedule stopping of the scanning process. |
| 53 void ScheduleStop(); | 43 void ScheduleStop(); |
| 54 | 44 |
| 45 // Get access point data from chromeos. |
| 46 bool GetAccessPointData(WifiData::AccessPointDataSet* data); |
| 47 |
| 55 // Underlying OS wifi API. (UI thread) | 48 // Underlying OS wifi API. (UI thread) |
| 56 scoped_ptr<content::WifiDataProviderCommon::WlanApiInterface> wlan_api_; | 49 scoped_ptr<WifiDataProviderCommon::WlanApiInterface> wlan_api_; |
| 57 | 50 |
| 58 // Controls the polling update interval. (client thread) | 51 // Controls the polling update interval. (client thread) |
| 59 scoped_ptr<content::PollingPolicyInterface> polling_policy_; | 52 scoped_ptr<PollingPolicyInterface> polling_policy_; |
| 60 | 53 |
| 61 // The latest wifi data. (client thread) | 54 // The latest wifi data. (client thread) |
| 62 content::WifiData wifi_data_; | 55 WifiData wifi_data_; |
| 63 | 56 |
| 64 // Whether we have strated the data provider. (client thread) | 57 // Whether we have strated the data provider. (client thread) |
| 65 bool started_; | 58 bool started_; |
| 66 | 59 |
| 67 // Whether we've successfully completed a scan for WiFi data. (client thread) | 60 // Whether we've successfully completed a scan for WiFi data. (client thread) |
| 68 bool is_first_scan_complete_; | 61 bool is_first_scan_complete_; |
| 69 | 62 |
| 70 DISALLOW_COPY_AND_ASSIGN(WifiDataProviderChromeOs); | 63 DISALLOW_COPY_AND_ASSIGN(WifiDataProviderChromeOs); |
| 71 }; | 64 }; |
| 72 | 65 |
| 73 #endif // CHROME_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_CHROMEOS_H_ | 66 } // namespace content |
| 67 |
| 68 #endif // CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_CHROMEOS_H_ |
| OLD | NEW |