Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1475)

Side by Side Diff: chrome/browser/geolocation/wifi_data_provider_win.h

Issue 604019: Refactor the state-machine & threading out of the windows wifi provider into ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_WIN_H_ 5 #ifndef CHROME_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_WIN_H_
6 #define CHROME_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_WIN_H_ 6 #define CHROME_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_WIN_H_
7 7
8 #include "base/task.h" 8 #include "chrome/browser/geolocation/wifi_data_provider_common.h"
9 #include "base/thread.h"
10 #include "chrome/browser/geolocation/device_data_provider.h"
11 9
12 class PollingPolicyInterface; 10 class PollingPolicyInterface;
13 11
14 class Win32WifiDataProvider 12 class Win32WifiDataProvider : public WifiDataProviderCommon {
15 : public WifiDataProviderImplBase,
16 private base::Thread {
17 public: 13 public:
18 // Interface to abstract the low level data OS library call, and to allow
19 // mocking (hence public).
20 class WlanApiInterface {
21 public:
22 virtual ~WlanApiInterface() {}
23 // Gets wifi data for all visible access points.
24 virtual bool GetAccessPointData(WifiData::AccessPointDataSet *data) = 0;
25 };
26
27 Win32WifiDataProvider(); 14 Win32WifiDataProvider();
28 15
29 // Takes ownership of wlan_api. Must be called before Start().
30 void inject_mock_wlan_api(WlanApiInterface* wlan_api);
31
32 // Takes ownership of polic. Must be called before Start().
33 void inject_mock_polling_policy(PollingPolicyInterface* policy);
34
35 // WifiDataProviderImplBase implementation
36 virtual bool StartDataProvider();
37 virtual void StopDataProvider();
38 virtual bool GetData(WifiData *data);
39
40 private: 16 private:
41 virtual ~Win32WifiDataProvider(); 17 virtual ~Win32WifiDataProvider();
42 18
43 // Thread implementation 19 // WifiDataProviderCommon
44 virtual void Init(); 20 virtual WlanApiInterface* NewWlanApi();
45 virtual void CleanUp(); 21 virtual PollingPolicyInterface* NewPolicyPolicy();
46
47 // Task which run in the child thread.
48 void DoWifiScanTask();
49
50 // Will schedule a scan; i.e. enqueue DoWifiScanTask deferred task.
51 void ScheduleNextScan();
52
53 WifiData wifi_data_;
54 Lock data_mutex_;
55
56 // Whether we've successfully completed a scan for WiFi data (or the polling
57 // thread has terminated early).
58 bool is_first_scan_complete_;
59
60 // Underlying OS wifi API.
61 scoped_ptr<WlanApiInterface> wlan_api_;
62
63 // Controls the polling update interval.
64 scoped_ptr<PollingPolicyInterface> polling_policy_;
65
66 // Holder for the tasks which run on the thread; takes care of cleanup.
67 ScopedRunnableMethodFactory<Win32WifiDataProvider> task_factory_;
68 22
69 DISALLOW_COPY_AND_ASSIGN(Win32WifiDataProvider); 23 DISALLOW_COPY_AND_ASSIGN(Win32WifiDataProvider);
70 }; 24 };
71 25
72 #endif // CHROME_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_WIN_H_ 26 #endif // CHROME_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698