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 CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_COMMON_H_ | 5 #ifndef CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_COMMON_H_ |
6 #define CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_COMMON_H_ | 6 #define CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_COMMON_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <assert.h> | 9 #include <assert.h> |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 class WlanApiInterface { | 75 class WlanApiInterface { |
76 public: | 76 public: |
77 virtual ~WlanApiInterface() {} | 77 virtual ~WlanApiInterface() {} |
78 // Gets wifi data for all visible access points. | 78 // Gets wifi data for all visible access points. |
79 virtual bool GetAccessPointData(WifiData::AccessPointDataSet* data) = 0; | 79 virtual bool GetAccessPointData(WifiData::AccessPointDataSet* data) = 0; |
80 }; | 80 }; |
81 | 81 |
82 WifiDataProviderCommon(); | 82 WifiDataProviderCommon(); |
83 | 83 |
84 // WifiDataProviderImplBase implementation | 84 // WifiDataProviderImplBase implementation |
85 virtual bool StartDataProvider(); | 85 virtual bool StartDataProvider() OVERRIDE; |
86 virtual void StopDataProvider(); | 86 virtual void StopDataProvider() OVERRIDE; |
87 virtual bool GetData(WifiData* data); | 87 virtual bool GetData(WifiData* data) OVERRIDE; |
88 | 88 |
89 protected: | 89 protected: |
90 virtual ~WifiDataProviderCommon(); | 90 virtual ~WifiDataProviderCommon(); |
91 | 91 |
92 // Returns ownership. Will be called from the worker thread. | 92 // Returns ownership. Will be called from the worker thread. |
93 virtual WlanApiInterface* NewWlanApi() = 0; | 93 virtual WlanApiInterface* NewWlanApi() = 0; |
94 | 94 |
95 // Returns ownership. Will be called from the worker thread. | 95 // Returns ownership. Will be called from the worker thread. |
96 virtual PollingPolicyInterface* NewPollingPolicy() = 0; | 96 virtual PollingPolicyInterface* NewPollingPolicy() = 0; |
97 | 97 |
98 private: | 98 private: |
99 // Thread implementation | 99 // Thread implementation |
100 virtual void Init(); | 100 virtual void Init() OVERRIDE; |
101 virtual void CleanUp(); | 101 virtual void CleanUp() OVERRIDE; |
102 | 102 |
103 // Task which run in the child thread. | 103 // Task which run in the child thread. |
104 void DoWifiScanTask(); | 104 void DoWifiScanTask(); |
105 | 105 |
106 // Will schedule a scan; i.e. enqueue DoWifiScanTask deferred task. | 106 // Will schedule a scan; i.e. enqueue DoWifiScanTask deferred task. |
107 void ScheduleNextScan(int interval); | 107 void ScheduleNextScan(int interval); |
108 | 108 |
109 WifiData wifi_data_; | 109 WifiData wifi_data_; |
110 base::Lock data_mutex_; | 110 base::Lock data_mutex_; |
111 | 111 |
112 // Whether we've successfully completed a scan for WiFi data (or the polling | 112 // Whether we've successfully completed a scan for WiFi data (or the polling |
113 // thread has terminated early). | 113 // thread has terminated early). |
114 bool is_first_scan_complete_; | 114 bool is_first_scan_complete_; |
115 | 115 |
116 // Underlying OS wifi API. | 116 // Underlying OS wifi API. |
117 scoped_ptr<WlanApiInterface> wlan_api_; | 117 scoped_ptr<WlanApiInterface> wlan_api_; |
118 | 118 |
119 // Controls the polling update interval. | 119 // Controls the polling update interval. |
120 scoped_ptr<PollingPolicyInterface> polling_policy_; | 120 scoped_ptr<PollingPolicyInterface> polling_policy_; |
121 | 121 |
122 // Holder for the tasks which run on the thread; takes care of cleanup. | 122 // Holder for the tasks which run on the thread; takes care of cleanup. |
123 base::WeakPtrFactory<WifiDataProviderCommon> weak_factory_; | 123 base::WeakPtrFactory<WifiDataProviderCommon> weak_factory_; |
124 | 124 |
125 DISALLOW_COPY_AND_ASSIGN(WifiDataProviderCommon); | 125 DISALLOW_COPY_AND_ASSIGN(WifiDataProviderCommon); |
126 }; | 126 }; |
127 | 127 |
128 #endif // CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_COMMON_H_ | 128 #endif // CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_COMMON_H_ |
OLD | NEW |